summary refs log tree commit diff stats
path: root/scripts/checkpoint.lua
blob: a5c8c54c5200427b012eb748687322e61ee759a5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
  end
end