diff --git a/app.lua b/app.lua index 49da45a..6a32494 100644 --- a/app.lua +++ b/app.lua @@ -1,18 +1,20 @@ local lapis = require("lapis") local app = lapis.Application() local say = require('lua_scripts/main') +local mapFunc = require('lua_scripts/map') local player = require('player') local db = require("lapis.db") local Model = require("lapis.db.model").Model -local db = Model:extend('database') +local map = Model:extend('map') app:enable("etlua") app.layout = require "views.layout" app:post("/clickme", function(self) self.plane = "P-38L" + mapFunc:populate(map) return {self.plane, layout = false} end) @@ -23,6 +25,17 @@ app:get("/", function(self) } end) +app:match("/map/render", function(self) + self.tiles = {} + for h=1,10 do + self.tiles[h] = {} + for i=1,10 do + self.tiles[h][i] = map:find({x = h, y = i}) + end + end + return {render = "map", layout = false} +end) + return app diff --git a/config.lua b/config.lua index fd412a1..0f958a8 100644 --- a/config.lua +++ b/config.lua @@ -5,7 +5,7 @@ config("development", { code_cache = "off", num_workers = "1", sqlite = { - database = "my_database.sqlite", + database = "database.sqlite3", -- open_flags = ... } }) diff --git a/database.sqlite3 b/database.sqlite3 index d5c7d88..a3ee411 100644 Binary files a/database.sqlite3 and b/database.sqlite3 differ diff --git a/lua_scripts/map.lua b/lua_scripts/map.lua new file mode 100644 index 0000000..0e62407 --- /dev/null +++ b/lua_scripts/map.lua @@ -0,0 +1,44 @@ + + +local map = { + map_tiles = { + {"-", "-", "w", "w", "-", "-", "-", "-", "-", "-"}, + {"-", "-", "w", "w", "-", "-", "-", "-", "-", "-"}, + {"-", "-", "w", "w", "-", "w", "-", "-", "-", "-"}, + {"w", "-", "-", "-", "w", "w", "-", "-", "-", "-"}, + {"w", "-", "w", "-", "-", "w", "w", "w", "-", "-"}, + {"w", "-", "w", "-", "-", "w", "-", "-", "-", "-"}, + {"-", "-", "w", "-", "-", "w", "-", "w", "-", "-"}, + {"-", "-", "-", "-", "-", "-", "-", "w", "-", "-"}, + {"-", "-", "w", "-", "-", "-", "-", "w", "w", "-"}, + {"-", "-", "w", "-", "-", "-", "-", "-", "w", "-"} + }, + populate = function(self, map) + for h=1,10 do + for i=1,10 do + local tile = map:create({ + x = h, + y = i, + occupied_by_type = self.map_tiles[h][i], + occupied_by_id = "" + }) + end + end + end +} +local tiles = {} + +return map + + + + + + + + + + + + + diff --git a/nginx.conf b/nginx.conf index e9bcd06..7db519f 100644 --- a/nginx.conf +++ b/nginx.conf @@ -12,6 +12,8 @@ http { init_by_lua_block { require "lpeg" + require "lsqlite3" + lapis = require "lapis" } server { diff --git a/nginx.conf.compiled b/nginx.conf.compiled index eae3968..0b9976d 100644 --- a/nginx.conf.compiled +++ b/nginx.conf.compiled @@ -13,6 +13,8 @@ http { init_by_lua_block { require "lpeg" + require "lsqlite3" + lapis = require "lapis" } server { diff --git a/setup_db b/setup_db index 6e67040..3e91186 100755 --- a/setup_db +++ b/setup_db @@ -15,7 +15,7 @@ sqlite3 database.sqlite3 " hp INTEGER, inventory_ref INTEGER ); - CREATE TABLE IF NOT EXISTS player_inventory ( + CREATE TABLE IF NOT EXISTS player_inventory ( id INTEGER PRIMARY KEY AUTOINCREMENT, type TEXT, quantity INTEGER, diff --git a/views/index.etlua b/views/index.etlua index ed17d69..7755f22 100644 --- a/views/index.etlua +++ b/views/index.etlua @@ -1,11 +1,15 @@ +