Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.47 KB | None | 0 0
  1. require('Base.ActionResult');
  2.  
  3. SingleSeatChair = ActionableObject:new();
  4.  
  5. SingleSeatChair = {
  6.     seat_occupied = false
  7. }
  8.  
  9. function SingleSeatChair:sit_begin()
  10.     if self.seat_occupied == false then
  11.     return {
  12.         action_result_type = "PlayerPositionRequirements",
  13.         position = self.sit_entry_position,
  14.         rotation = self.sit_entry_rotation,
  15.         complete_function = SingleSeatChair:sit};
  16.     else
  17.         return action_result_type = ActionResult.Failed;
  18.     end
  19. end
  20.  
  21. function SingleSeatChair:sit()
  22.     return {
  23.         action_result_type = "PlayerAnimation",
  24.         animation_name = "SitDown",
  25.         interruptable = true,
  26.         interruptable_function = SingleSeatChair:sit_interrupt,
  27.         complete_function = SingleSeatChair:sit_final};
  28. end
  29.  
  30. function SingleSeatChair:sit_interrupt()
  31.     return {
  32.         action_result_type = "MorphAnimation",
  33.         animation_name = "Standing",
  34.         ending_player_position = sit_entry_position,
  35.         ending_player_rotation = sit_entry_rotation,
  36.         interruptable = false,
  37.         complete_function = SingleSeatChair:sit_interrupt_final};
  38. end
  39.  
  40. function SingleSeatChair:sit_interrupt_final()
  41.     return ActionResult.Completed;
  42. end
  43.  
  44. function SingleSeatChair:sit_final()
  45.     self.seat_occupied = true;
  46.     return ActionResult.Completed;
  47. end
  48.  
  49. function SingleSeatChair:get_up()
  50.     return {
  51.         action_result_type = "PlayerAnimation",
  52.         animation_name = "GetUpFromSitting",
  53.         interruptable = false,
  54.         complete_function = SingleSeatChair:get_up_final};
  55. end
  56.  
  57. function SingleSeatChair:get_up_final()
  58.     self.seat_occupied = false;
  59.     return ActionResult.Completed;
  60. end
  61.  
  62. function SingleSeatChair:get_actions()
  63.     if self.seat_occupied then
  64.         return {
  65.             object_actions = {{name = "Sit", handler = SingleSeatChair:sit_begin}},
  66.             general_actions = {}
  67.         }
  68.     else
  69.         return {
  70.             object_actions = {{name = "Get Up", handler = SingleSeatChair:get_up}},
  71.             general_actions = {{name = "Get Up", handler = SingleSeatChair:get_up}}
  72.         }
  73.     end
  74. end
  75.  
  76. add_entities = {
  77.     {
  78.         -- Minimal required game object declarations
  79.         script_name = 'comfy_chair',
  80.         nice_name = "Comfy Chair",
  81.         handler_object = SingleSeatChair,
  82.         move_style = 'drag',
  83.         collision_box = {{-0.49, -0.49}, {0.49, 0.49}},
  84.         selection_box = {{-0.5, -0.5}, {0.5, 0.5}},
  85.         model = "__base__/models/sofa1",
  86.  
  87.         -- Required by handler_object base class ActionableObject
  88.         action_list_generate = SingleSeatChair:get_actions,
  89.  
  90.         -- Required by handler_object SingleSeatChair
  91.         sit_position = {-0.1, 0.0, 0.3}
  92.         sit_entry_position = {0.6, 0.0, 0.0},
  93.         sit_entry_rotation = 0.0
  94.     },
  95.     {
  96.         -- Minimal required game object declarations
  97.         script_name = 'bar_stool',
  98.         nice_name = "Bar Stool",
  99.         handler_object = SingleSeatChair,
  100.         move_style = 'both_hands_carry',
  101.         collision_box = {{-0.3, -0.3}, {0.3, 0.3}},
  102.         selection_box = {{-0.31, -0.31}, {0.31, 0.31}},
  103.         model = "__base__/models/barstool",
  104.  
  105.         -- Required by handler_object base class ActionableObject
  106.         action_list_generate = SingleSeatChair:get_actions,
  107.  
  108.         -- Required by handler_object SingleSeatChair
  109.         sit_position = {-0.0, 0.0, 0.36}
  110.         sit_entry_position = {0.2, 0.0, 0.0},
  111.         sit_entry_rotation = 0.0
  112.     },
  113.  
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement