From 684ebb61a803c9ee45f08b972a273793084a5356 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 18 Mar 2024 15:31:53 -0500 Subject: [PATCH] added real-time map render! --- app.lua | 15 ++++++++++++++- config.lua | 2 +- database.sqlite3 | Bin 20480 -> 20480 bytes lua_scripts/map.lua | 44 ++++++++++++++++++++++++++++++++++++++++++++ nginx.conf | 2 ++ nginx.conf.compiled | 2 ++ setup_db | 2 +- views/index.etlua | 10 +++++++--- views/map.etlua | 8 ++++++++ 9 files changed, 79 insertions(+), 6 deletions(-) create mode 100644 lua_scripts/map.lua create mode 100644 views/map.etlua 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 d5c7d8885092a70b7dfb65935ced5151f85890cb..a3ee4113060656c99d9b0b8142f82a38a6093cc2 100644 GIT binary patch literal 20480 zcmeI2OHdni9LKYShr9VdN>NjME^Sc|mJ;%AeUz58VtF^!QmQc|0hxgi(qPPJ4{*?4 zt6r-ft23Ue<9M-NJXlZ8SZ|K@sPee)w{4HdGmoDp{L~LGps{{}-^MonH=OtMWeka{jq)px&g%VY z7QhD=-~wEL3vdB0zy-Jf7vKV1fD8QB0&883Eq=!_*1e_l>|(C4n6BiCsfGNTxqNB4 zSlNBvbaE;&m`vEo!4o41d-qkl%QDS{tUWxIOq@FR7Rtt{g8ICUwv zvYN|ha=T8wJLbLXVpl%Bl8 zr!VMnJ*4BhPao8NEwrKjQh%!7)NOT3-BdT!b#+a>uijJds1-G*X4HflQgPL%4ygl5 zss_0s@5(#!w!9^8$}i-n@+0|yydp2lqMVa6azZBLQF%ljmhDnWuh^L&N0VI*E#A~uh%)^SgAUP9qY9^ zhaBtGItRK?BR2cdh65V}VRp?ic7x^_aW?f_w^Z2AeYx`zp&dx#Kw_aG3u0aw>n z8yj1-Jkg-~wEL T3vdB0zy-Jf7vKV1fC~H#Rkm%d delta 34 ocmZozz}T>Wae_1>^F$eER%Ql0?}-~z7VvLoG590D$Uy*z0JXLXo&W#< 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 @@ +
+ +
- -

+
+ +
-