Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- roomstates = {}
- function OnExitRoom(room, coordinate)
- roomstates[coordinate] = {
- Count = room.objects.count
- Objects = {}
- }
- local myroom = roomstates[coordinate]
- for i = 1, myroom.Count do
- myroom.objects[i].Type = room.objects[i].Type
- myroom.objects[i].Position = room.objects[i].Position
- myroom.objects[i].HP = room.objects[i].HP
- end
- end
- function OnEnterRoom(room, coordinate)
- if roomstates[coordinate] == nil then
- return
- end
- room.objects:Clear()
- local myroom = roomstates[coordinate]
- for i = 1, myroom.Count do
- local Object = nil
- if myroom.objects[i] == "box" then
- Object = box()
- elseif myroom.objects[i] == "enemy" then
- Object = new enemy()
- end
- if Object ~= nil then
- Object.Position = myroom.objects[i].Position
- Object.HP = myroom.objects[i].HP
- room.objects:Add(Object)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement