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

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

View File

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

View File

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

View File

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