Advertisement
Guest User

Untitled

a guest
Sep 21st, 2014
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.87 KB | None | 0 0
  1. roomstates = {}
  2.  
  3. function OnExitRoom(room, coordinate)
  4.     roomstates[coordinate] = {
  5.         Count = room.objects.count
  6.         Objects = {}
  7.     }
  8.  
  9.     local myroom = roomstates[coordinate]
  10.  
  11.     for i = 1, myroom.Count do
  12.         myroom.objects[i].Type = room.objects[i].Type
  13.         myroom.objects[i].Position = room.objects[i].Position
  14.         myroom.objects[i].HP = room.objects[i].HP
  15.     end
  16. end
  17.  
  18. function OnEnterRoom(room, coordinate)
  19.     if roomstates[coordinate] == nil then
  20.         return
  21.     end
  22.  
  23.     room.objects:Clear()
  24.  
  25.     local myroom = roomstates[coordinate]
  26.  
  27.     for i = 1, myroom.Count do
  28.         local Object = nil
  29.  
  30.         if myroom.objects[i] == "box" then
  31.             Object = box()
  32.         elseif myroom.objects[i] == "enemy" then
  33.             Object = new enemy()
  34.         end
  35.  
  36.         if Object ~= nil then
  37.             Object.Position = myroom.objects[i].Position
  38.             Object.HP = myroom.objects[i].HP
  39.  
  40.             room.objects:Add(Object)
  41.         end
  42.     end
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement