summaryrefslogtreecommitdiff
path: root/client/data/locations.lua
diff options
context:
space:
mode:
authorU-DESKTOP-FOJ6TK1\Alex <alex@cogarr.net>2025-02-12 17:25:25 -0600
committerU-DESKTOP-FOJ6TK1\Alex <alex@cogarr.net>2025-02-12 17:25:25 -0600
commitb1c3386ca4032ac5925969d759ae2e5bc015d1f8 (patch)
tree74e7d8797afea9df12222e149e865134ddec9479 /client/data/locations.lua
parent0aae46ecc38005236210f7e243f02cac39ab1dc3 (diff)
downloadhome_text_adventure-b1c3386ca4032ac5925969d759ae2e5bc015d1f8.tar.gz
home_text_adventure-b1c3386ca4032ac5925969d759ae2e5bc015d1f8.tar.bz2
home_text_adventure-b1c3386ca4032ac5925969d759ae2e5bc015d1f8.zip
Final commitHEADmaster
Diffstat (limited to 'client/data/locations.lua')
-rw-r--r--client/data/locations.lua88
1 files changed, 44 insertions, 44 deletions
diff --git a/client/data/locations.lua b/client/data/locations.lua
index 183425e..f499619 100644
--- a/client/data/locations.lua
+++ b/client/data/locations.lua
@@ -1,44 +1,44 @@
-local world = require("world")
-local net = require("net")
-world.locations = world.locations or {}
-local loc = {}
-
-local required_fields = {
- name = "string",
- desc = "string",
- goto_txt = "string",
- go = "table",
- settle_txt = "string"
-}
-
-local location_base = {
- get_desc = function(self)
- local houses = net.ask_for_homes(self.name,1)
- self.last_houses = houses
- local sb = {self.desc}
- for k,v in pairs(houses) do
- print("Adding ", v)
- sb[#sb + 1] = string.format("%s is here",v)
- end
- return table.concat(sb,"\n")
- end,
- houses = {},
- is_location = true
-}
-
-local location_m = {__index = location_base}
-
-function loc.add_location(tbl)
- print("Added location:",tbl.name)
- assert(type(tbl) == "table","Tried to register a location that was not a table")
- for k,v in pairs(required_fields) do
- assertf(tbl[k],"Tried to register a location without a %s field",k)
- assertf(type(tbl[k]) == v,"Tried to register a location with a %s field that should have been a %s, but was a %s",k,v,type(tbl[k]))
- end
- assert(world.locations[tbl.name] == nil)
- setmetatable(tbl,location_m)
- world.locations[tbl.name] = tbl
-end
-
-
-return loc
+local world = require("world")
+local net = require("net")
+world.locations = world.locations or {}
+local loc = {}
+
+local required_fields = {
+ name = "string",
+ desc = "string",
+ goto_txt = "string",
+ go = "table",
+ settle_txt = "string"
+}
+
+local location_base = {
+ get_desc = function(self)
+ local houses = net.ask_for_homes(self.name,1)
+ self.last_houses = houses
+ local sb = {self.desc}
+ for k,v in pairs(houses) do
+ print("Adding ", v)
+ sb[#sb + 1] = string.format("%s is here",v)
+ end
+ return table.concat(sb,"\n")
+ end,
+ houses = {},
+ is_location = true
+}
+
+local location_m = {__index = location_base}
+
+function loc.add_location(tbl)
+ print("Added location:",tbl.name)
+ assert(type(tbl) == "table","Tried to register a location that was not a table")
+ for k,v in pairs(required_fields) do
+ assertf(tbl[k],"Tried to register a location without a %s field",k)
+ assertf(type(tbl[k]) == v,"Tried to register a location with a %s field that should have been a %s, but was a %s",k,v,type(tbl[k]))
+ end
+ assert(world.locations[tbl.name] == nil)
+ setmetatable(tbl,location_m)
+ world.locations[tbl.name] = tbl
+end
+
+
+return loc