Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require('Base.ActionResult');
- SingleSeatChair = ActionableObject:new();
- SingleSeatChair = {
- seat_occupied = false
- }
- function SingleSeatChair:sit_begin()
- if self.seat_occupied == false then
- return {
- action_result_type = "PlayerPositionRequirements",
- position = self.sit_entry_position,
- rotation = self.sit_entry_rotation,
- complete_function = SingleSeatChair:sit};
- else
- return action_result_type = ActionResult.Failed;
- end
- end
- function SingleSeatChair:sit()
- return {
- action_result_type = "PlayerAnimation",
- animation_name = "SitDown",
- interruptable = true,
- interruptable_function = SingleSeatChair:sit_interrupt,
- complete_function = SingleSeatChair:sit_final};
- end
- function SingleSeatChair:sit_interrupt()
- return {
- action_result_type = "MorphAnimation",
- animation_name = "Standing",
- ending_player_position = sit_entry_position,
- ending_player_rotation = sit_entry_rotation,
- interruptable = false,
- complete_function = SingleSeatChair:sit_interrupt_final};
- end
- function SingleSeatChair:sit_interrupt_final()
- return ActionResult.Completed;
- end
- function SingleSeatChair:sit_final()
- self.seat_occupied = true;
- return ActionResult.Completed;
- end
- function SingleSeatChair:get_up()
- return {
- action_result_type = "PlayerAnimation",
- animation_name = "GetUpFromSitting",
- interruptable = false,
- complete_function = SingleSeatChair:get_up_final};
- end
- function SingleSeatChair:get_up_final()
- self.seat_occupied = false;
- return ActionResult.Completed;
- end
- function SingleSeatChair:get_actions()
- if self.seat_occupied then
- return {
- object_actions = {{name = "Sit", handler = SingleSeatChair:sit_begin}},
- general_actions = {}
- }
- else
- return {
- object_actions = {{name = "Get Up", handler = SingleSeatChair:get_up}},
- general_actions = {{name = "Get Up", handler = SingleSeatChair:get_up}}
- }
- end
- end
- add_entities = {
- {
- -- Minimal required game object declarations
- script_name = 'comfy_chair',
- nice_name = "Comfy Chair",
- handler_object = SingleSeatChair,
- move_style = 'drag',
- collision_box = {{-0.49, -0.49}, {0.49, 0.49}},
- selection_box = {{-0.5, -0.5}, {0.5, 0.5}},
- model = "__base__/models/sofa1",
- -- Required by handler_object base class ActionableObject
- action_list_generate = SingleSeatChair:get_actions,
- -- Required by handler_object SingleSeatChair
- sit_position = {-0.1, 0.0, 0.3}
- sit_entry_position = {0.6, 0.0, 0.0},
- sit_entry_rotation = 0.0
- },
- {
- -- Minimal required game object declarations
- script_name = 'bar_stool',
- nice_name = "Bar Stool",
- handler_object = SingleSeatChair,
- move_style = 'both_hands_carry',
- collision_box = {{-0.3, -0.3}, {0.3, 0.3}},
- selection_box = {{-0.31, -0.31}, {0.31, 0.31}},
- model = "__base__/models/barstool",
- -- Required by handler_object base class ActionableObject
- action_list_generate = SingleSeatChair:get_actions,
- -- Required by handler_object SingleSeatChair
- sit_position = {-0.0, 0.0, 0.36}
- sit_entry_position = {0.2, 0.0, 0.0},
- sit_entry_rotation = 0.0
- },
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement