Compare commits

...

2 Commits

Author SHA1 Message Date
989d33ff5e fix merge conflicts 2024-03-18 15:36:27 -05:00
684ebb61a8 added real-time map render! 2024-03-18 15:31:53 -05:00
7 changed files with 59 additions and 3 deletions

15
app.lua
View File

@ -14,7 +14,11 @@ app.layout = require "views.layout"
app:post("/clickme", function(self) app:post("/clickme", function(self)
self.plane = "P-38L" self.plane = "P-38L"
<<<<<<< HEAD
mapFunc:populate(map)
=======
mapFunc.populate(self, map) mapFunc.populate(self, map)
>>>>>>> refs/remotes/origin/master
return {self.plane, layout = false} return {self.plane, layout = false}
end) end)
@ -25,6 +29,17 @@ app:get("/", function(self)
} }
end) 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 return app

Binary file not shown.

View File

@ -1,3 +1,27 @@
<<<<<<< HEAD
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],
=======
local map = { local map = {
populate = function(self, map) populate = function(self, map)
for h=1,100 do for h=1,100 do
@ -6,6 +30,7 @@ local map = {
x = h, x = h,
y = i, y = i,
occupied_by_type = "", occupied_by_type = "",
>>>>>>> refs/remotes/origin/master
occupied_by_id = "" occupied_by_id = ""
}) })
end end

View File

@ -12,6 +12,8 @@ http {
init_by_lua_block { init_by_lua_block {
require "lpeg" require "lpeg"
require "lsqlite3"
lapis = require "lapis"
} }
server { server {

View File

@ -13,6 +13,8 @@ http {
init_by_lua_block { init_by_lua_block {
require "lpeg" require "lpeg"
require "lsqlite3"
lapis = require "lapis"
} }
server { server {

View File

@ -1,11 +1,15 @@
<!-- views/index.etlua --> <!-- views/index.etlua -->
<script src="/static/htmx.min.js"></script> <script src="/static/htmx.min.js"></script>
<div id="clickable">
<button hx-post="/clickme" hx-target="#clickable">Start</button>
</div>
<button hx-post="/clickme" hx-target="#clickable">Start</button> <div id="map" hx-get="/map/render" hx-trigger="every 5s">
<p id="clickable"></p>
</div>
<ol>
<!-- <!--
<ol>
<p><% for i, thing in pairs(text) do %> <p><% for i, thing in pairs(text) do %>
<li><%= thing %></li> <li><%= thing %></li>
<% end %> <% end %>

8
views/map.etlua Normal file
View File

@ -0,0 +1,8 @@
<p style="text-align: center;">
<% for h=1,10 do %>
<% for i=1,10 do %>
<%= tiles[h][i].occupied_by_type %>
<% end %>
<br>
<% end %>
</p>