summary refs log tree commit diff stats
path: root/scripts/checkpoint.lua
blob: 04cf357947d610870a585e200a6bd6a0dfd640e9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
checkpoint = {}

function checkpoint.OnTouch(id, player)
  curMap = entity.new(realizing().activeMap)

  if not player:playable().checkpointMapObject or
      not curMap:mappable().mapId == player:playable().checkpointMapId or
      not id:prototypable().mapObjectIndex ==
        player:playable().checkpointMapObjectIndex then

    player:playable().checkpointMapObject = true
    player:playable().checkpointMapId = curMap:mappable().mapId
    player:playable().checkpointMapObjectIndex =
      id:prototypable().mapObjectIndex
    player:playable().checkpointPos = player:transformable().pos

    playSound("res/Pickup_Coin23.wav", 0.25)
  end
end