Skip to content
This repository was archived by the owner on Apr 7, 2019. It is now read-only.

Commit

Permalink
mod
Browse files Browse the repository at this point in the history
  • Loading branch information
naturefreshmilk committed Jun 14, 2018
1 parent b66be97 commit 1b7ac0d
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 0 deletions.
1 change: 1 addition & 0 deletions integration/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ services:
- "postgres"
volumes:
- "./minetest:/data"
- "../tileserver_mod:/data/world/worldmods/tileserver_mod"
command: minetestserver --config /data/minetest.conf --world /data/world/
ports:
- "30000:30000/udp"
Expand Down
Empty file added tileserver_mod/modpack.txt
Empty file.
1 change: 1 addition & 0 deletions tileserver_mod/tileserver/depends.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
default
9 changes: 9 additions & 0 deletions tileserver_mod/tileserver/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

tileserver = {
}

local MP = minetest.get_modpath("tileserver")

dofile(MP.."/poi.lua")

print("[OK] Tileserver")
95 changes: 95 additions & 0 deletions tileserver_mod/tileserver/poi.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@

local update_formspec = function(meta)
local inv = meta:get_inventory()

local active = meta:get_int("active") == 1
local state = "Inactive"

if active then
state = "Active"
end

local name = meta:get_string("name")
local category = meta:get_string("category")
meta:set_string("infotext", "POI: " .. name .. ", " .. category .. " (" .. state .. ")")

meta:set_string("formspec", "size[8,3;]" ..
-- col 1
"field[0,1;4,1;name;Name;" .. name .. "]" ..
"button_exit[4,1;4,1;save;Save]" ..

-- col 2
"field[0,2.5;4,1;category;Category;" .. category .. "]" ..
"button_exit[4,2;4,1;toggle;Toggle]" ..
"")

end


minetest.register_node("tileserver:poi", {
description = "Tileserver POI",
tiles = {
"tileserver_poi.png",
"tileserver_poi.png",
"tileserver_poi.png",
"tileserver_poi.png",
"tileserver_poi.png",
"tileserver_poi.png"
},
groups = {cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),

can_dig = function(pos, player)
local meta = minetest.env:get_meta(pos)
local owner = meta:get_string("owner")

return player and player:get_player_name() == owner
end,

after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name() or "")
end,

on_construct = function(pos)
local meta = minetest.get_meta(pos)

meta:set_string("name", "<unconfigured>")
meta:set_string("category", "main")
meta:set_int("active", 0)

update_formspec(meta)
end,

on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.get_meta(pos)
local playername = sender:get_player_name()

if playername == meta:get_string("owner") then
-- owner
if fields.save then

local name = fields.name
meta:set_string("name", fields.name)


end

if fields.toggle then
if meta:get_int("active") == 1 then
meta:set_int("active", 0)
else
meta:set_int("active", 1)
end
end

else
-- non-owner
end


update_formspec(meta)
end


})
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1b7ac0d

Please sign in to comment.