Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local makeCutscene = function(args)
- local door = args.door
- local cutscene = args.cutscene
- -- position to which player goes before fade in to black
- local enterDestinationPos = door:getCenter()
- enterDestinationPos.y = enterDestinationPos.y - 40.0
- local teleportDestination = getEntityByTag(door:getDestinationTag())
- -- position from which player starts after fade in
- local insideCenterPos = teleportDestination:getCenter()
- insideCenterPos.y = insideCenterPos.y + 28.0
- local actions = {
- {
- f = function()
- if(door:getScriptStateName() == "DoorLockedState") then -- check if the door is locked
- if(playerEntity:hasItem(args.key)) then -- check if player has the key
- cutscene:goTo("OPEN")
- else
- cutscene:goTo("CANT_OPEN")
- end
- else
- cutscene:goTo("ENTER") -- just open the door
- end
- end
- },
- -- has the key, open the door and enter
- {
- tag = "OPEN",
- type = ActionType.UsedItem,
- itemName = args.key,
- nextTag = "ENTER"
- },
- -- can't open, say that the door is locked
- {
- tag = "CANT_OPEN",
- type = ActionType.Dialogue,
- dialogue = {
- {
- text = { "DOOR_LOCKED" }
- }
- },
- nextTag = "EXIT_REQUEST_TAG"
- },
- -- enter the house
- {
- tag = "ENTER",
- f = function()
- door:setScriptState("DoorOpeningState")
- playerEntity:setComponentDisabled("CollisionComponent", true)
- cameraUnfollow()
- end
- },
- {
- type = ActionType.GoTo,
- entity = playerEntity,
- destination = enterDestinationPos
- },
- -- don't forget to close the door, it's cold outside
- {
- f = function()
- door:setScriptState("DoorClosingState")
- end
- },
- {
- type = ActionType.Effect,
- name = "FadeOutToBlack",
- popAfterFinish = false
- },
- {
- f = function()
- centerCameraAround(teleportDestination) -- this sets camera to be in the room which player teleports into
- end
- },
- {
- type = ActionType.Effect,
- name = "FadeInFromBlack",
- popPrevious = true,
- waitForFinish = false
- },
- {
- f = function()
- playerEntity:setCenter(insideCenterPos)
- playerEntity:setDisabled(false)
- playerEntity:setComponentDisabled("CollisionComponent", false)
- cameraFollow(playerEntity)
- end
- },
- {
- type = ActionType.GoTo,
- entity = playerEntity,
- destinationEntity = teleportDestination
- }
- }
- return actions
- end
- return makeCutscene
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement