summaryrefslogtreecommitdiff
path: root/client/data/room.lua
diff options
context:
space:
mode:
Diffstat (limited to 'client/data/room.lua')
-rw-r--r--client/data/room.lua136
1 files changed, 68 insertions, 68 deletions
diff --git a/client/data/room.lua b/client/data/room.lua
index 410b08e..d5d9b47 100644
--- a/client/data/room.lua
+++ b/client/data/room.lua
@@ -1,68 +1,68 @@
-local room = {}
-local item = require("item")
-
-local room_base = {
- add_item = function(self,itemname,itemdesc,itemlocation)
- local newitem = item.create_new(itemname,itemdesc,itemlocation)
- self.items[#self.items + 1] = newitem
- end,
- remove_item = function(self,itemname,itemdesc,itemlocation)
- local to_remove = {}
- for k,v in pairs(self.items) do
- if v.name == itemname and v.desc == itemdesc and v.itemlocation == itemlocation then
- to_remove[#to_remove + 1] = k
- end
- end
- for k,v in pairs(to_remove) do
- table.remove(self.items,v)
- end
- end,
- get_items_names = function(self)
- local ret = {}
- for k,v in pairs(self.items) do
- ret[#ret + 1] = v.name
- end
- return ret
- end,
- get_room_desc = function(self)
- local sb = {}
- sb[#sb + 1] = string.format("You are in a %s",self.name)
- sb[#sb + 1] = string.format(self.desc)
- for itemnum,item in pairs(self.items) do
- sb[#sb + 1] = string.format("There is a %s %s",item.name,item.location)
- end
- for direction,room in pairs(self.go) do
- if room == "exit" then
- sb[#sb + 1] = string.format("There is an exit to the %s",direction)
- else
- local name = room.name
- local sdir = string.lower(direction)
- if sdir == "up" then
- sb[#sb + 1] = string.format("There is a %s above you",name)
- elseif sdir == "down" then
- sb[#sb + 1] = string.format("There is a %s below you",name)
- else
- sb[#sb + 1] = string.format("There is a %s to the %s",name,direction)
- end
- end
- end
- return table.concat(sb,"\n")
- end
-}
-
-local room_m = {__index = room_base}
-
-function room.create_new(n,loc)
- local ret = {
- name=n,
- items={},
- desc="",
- go={},
- location=loc
- }
- print("Created room:",ret)
- setmetatable(ret,room_m)
- return ret
-end
-room.meta = room_m
-return room
+local room = {}
+local item = require("item")
+
+local room_base = {
+ add_item = function(self,itemname,itemdesc,itemlocation)
+ local newitem = item.create_new(itemname,itemdesc,itemlocation)
+ self.items[#self.items + 1] = newitem
+ end,
+ remove_item = function(self,itemname,itemdesc,itemlocation)
+ local to_remove = {}
+ for k,v in pairs(self.items) do
+ if v.name == itemname and v.desc == itemdesc and v.itemlocation == itemlocation then
+ to_remove[#to_remove + 1] = k
+ end
+ end
+ for k,v in pairs(to_remove) do
+ table.remove(self.items,v)
+ end
+ end,
+ get_items_names = function(self)
+ local ret = {}
+ for k,v in pairs(self.items) do
+ ret[#ret + 1] = v.name
+ end
+ return ret
+ end,
+ get_room_desc = function(self)
+ local sb = {}
+ sb[#sb + 1] = string.format("You are in a %s",self.name)
+ sb[#sb + 1] = string.format(self.desc)
+ for itemnum,item in pairs(self.items) do
+ sb[#sb + 1] = string.format("There is a %s %s",item.name,item.location)
+ end
+ for direction,room in pairs(self.go) do
+ if room == "exit" then
+ sb[#sb + 1] = string.format("There is an exit to the %s",direction)
+ else
+ local name = room.name
+ local sdir = string.lower(direction)
+ if sdir == "up" then
+ sb[#sb + 1] = string.format("There is a %s above you",name)
+ elseif sdir == "down" then
+ sb[#sb + 1] = string.format("There is a %s below you",name)
+ else
+ sb[#sb + 1] = string.format("There is a %s to the %s",name,direction)
+ end
+ end
+ end
+ return table.concat(sb,"\n")
+ end
+}
+
+local room_m = {__index = room_base}
+
+function room.create_new(n,loc)
+ local ret = {
+ name=n,
+ items={},
+ desc="",
+ go={},
+ location=loc
+ }
+ print("Created room:",ret)
+ setmetatable(ret,room_m)
+ return ret
+end
+room.meta = room_m
+return room