Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- chest = {
- init = function(this)
- setScriptState(this, "ChestClosedState")
- disableComponent(this, "InteractionComponent")
- end,
- GraphicsComponent = {
- filename = "res/images/chest.png",
- animated = true,
- defaultAnimation = "closed",
- z = 0,
- animations = {
- closed = {
- frame = {0, 0, 16, 16},
- numOfFrames = 1,
- frameTime = 0,
- looped = false
- },
- opened = {
- frame = {16, 0, 16, 16},
- numOfFrames = 1,
- frameTime = 0,
- looped = false
- }
- }
- },
- CollisionComponent = {
- type = "Solid",
- boundingBox = { 0, 0, 16, 16 }
- },
- InteractionComponent = {
- type = "Open",
- interactionRect = { -8, 16, 32, 16 },
- interact = function (this, second)
- if(getScriptState(this) == "ChestClosedState") then
- setInteractionType(this, "None")
- setScriptState(this, "ChestOpeningState")
- end
- end
- },
- InventoryComponent = {
- },
- NpcComponent = {
- textFile = "chest.lua",
- talks = {
- {
- {
- text = "got_item",
- endFunc = function() -- gets called when player closes "got item" window
- setState(playerEntity, "IdleState")
- hideOverlaySprite() -- hides item which appears from the chest
- end
- }
- },
- }
- },
- ScriptStateMachineComponent = {
- states = {
- ChestClosedState = {
- enter = function(self, this)
- setAnimation(this, "closed")
- end,
- },
- ChestOpeningState = {
- enter = function(self, this)
- setAnimation(this, "opened")
- playSound("res/sounds/chest_open.wav")
- openChest(this)
- setScriptState(this, "ChestOpenedState")
- end,
- },
- ChestOpenedState = {
- enter = function(self, this)
- setAnimation(this, "opened")
- end
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement