Initial Commit

master
Aurailus 2018-01-01 15:50:41 -08:00
commit 1fc2cf53f0
9 changed files with 242 additions and 0 deletions

47
formspec.lua Normal file
View File

@ -0,0 +1,47 @@
spawn_pillar.formname = "pillar_gui"
function spawn_pillar.make_formspec(player, pos)
local active_pillar = minetest.deserialize(player:get_attribute("spawn_pillar"))
local fs = "size[10.3,11.3]" ..
"label[0.5,-0.25;Select a spawn pillar to tune to.]" ..
"label[0.5,0.05;\\[X\\] Is the currently tuned pillar.]" ..
"button[8.2,-0.25;2.3,0.8;pbeacon;Go to Party Beacon]" ..
"button[5.8,-0.25;2.3,0.8;respawn;Respawn]"
for i = 1, 16 do
for j = 1, 16 do
if i == 1 then
fs = fs .. "\nlabel[" .. (j/1.6 - 0.05) .. ",0.4;" .. j .. "]"
end
if j == 1 then
fs = fs .. "\nlabel[-0.04," .. (i/1.5 + 0.4) .. ";" .. i .. "]"
end
local string = " "
if active_pillar.x == j and active_pillar.y == i then
string = "\\[X\\]"
end
fs = fs .. "\nbutton[" .. (j/1.6 - 0.3) .. "," .. (i/1.5 + 0.4) .. ";0.8,0.5;x = " .. j .. ", y = " .. i .. ";" .. string .. "]"
end
end
return fs
end
minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname == spawn_pillar.formname then
for field,_ in pairs(fields) do
if field == "pbeacon" then
teleport_to_beacon(player)
return
end
if field == "respawn" then
player:set_hp(0)
return
end
if field:sub(1, 1) == "x" then
player:set_attribute("spawn_pillar", "return {" .. field .. "}")
minetest.show_formspec(player:get_player_name(), spawn_pillar.formname, spawn_pillar.make_formspec(player, pos))
return
end
end
end
end)

73
gen.lua Normal file
View File

@ -0,0 +1,73 @@
--Place spawn pillars
local spawn_positions = {}
local xseg = 1
local zseg = 1
for i = -8, 8 do
for j = -8, 8 do
if not spawn_pillar.get_spawnpoint(xseg, zseg) then
table.insert(spawn_positions, {x = j*2000, z = i*2000, xseg = xseg, zseg = zseg})
end
xseg = xseg + 1
end
zseg = zseg + 1
end
print("[Spawn Pillar] There are " .. #spawn_positions .. "spawn positions.")
-- print(dump(spawn_positions))
local function create_pillar(pos)
for i = -2, 2 do
for j = -2, 2 do
for k = -1, 3 do
local pos = vector.new(pos.x + i, pos.y + k, pos.z + j)
if k == -1 then
minetest.set_node(pos, {name = "spawn_pillar:spawn_tile"})
else
minetest.set_node(pos, {name = "air"})
end
end
end
end
minetest.set_node(pos, {name = "spawn_pillar:pillar_bottom"})
minetest.set_node(vector.add(pos, vector.new(1, 0, 0)), {name = "default:torch", param2 = 1})
minetest.set_node(vector.add(pos, vector.new(-1, 0, 0)), {name = "default:torch", param2 = 1})
minetest.set_node(vector.add(pos, vector.new(0, 0, 1)), {name = "default:torch", param2 = 1})
minetest.set_node(vector.add(pos, vector.new(0, 0, -1)), {name = "default:torch", param2 = 1})
end
minetest.register_on_generated(function(minp, maxp)
for ind,spos in pairs(spawn_positions) do
if minp.x < spos.x and spos.x < maxp.x and
minp.z < spos.z and spos.z < maxp.z and
minp.y < 79 and 79 < maxp.y then
if not spawn_pillar.get_spawnpoint(spos.xseg, spos.zseg) then
for j = 79, 2, -1 do
local node = vector.new(spos.x, j, spos.z)
local below = vector.new(spos.x, j-1, spos.z)
if (minetest.get_node(node).name == "air" and
minetest.get_node(below).name ~= "air" and minetest.get_node(below).name ~= "ignore") then
create_pillar(vector.new(spos.x, j, spos.z))
spawn_pillar.set_spawnpoint(spos.xseg, spos.zseg, vector.new(spos.x, j, spos.z))
table.remove(spawn_positions, ind)
return
end
end
create_pillar(vector.new(spos.x, 79, spos.z))
spawn_pillar.set_spawnpoint(spos.xseg, spos.zseg, vector.new(spos.x, 79, spos.z))
table.remove(spawn_positions, ind)
return
end
return
end
end
end)

25
init.lua Normal file
View File

@ -0,0 +1,25 @@
spawn_pillar = {}
spawn_pillar.storage = minetest.get_mod_storage()
spawn_pillar.spawn_points = minetest.deserialize(spawn_pillar.storage:get_string("spawn_points")) or {}
function spawn_pillar.get_spawnpoint(xseg, zseg)
return spawn_pillar.spawn_points[xseg .. "|" .. zseg] or nil
end
function spawn_pillar.set_spawnpoint(xseg, zseg, coords)
spawn_pillar.spawn_points[xseg .. "|" .. zseg] = coords
spawn_pillar.storage:set_string("spawn_points", minetest.serialize(spawn_pillar.spawn_points))
-- print(dump(spawn_pillar.spawn_points))
print("adding spawnpoint")
end
local path = minetest.get_modpath("spawn_pillar")
dofile(path .. "/formspec.lua")
dofile(path .. "/nodes.lua")
dofile(path .. "/gen.lua")
dofile(path .. "/respawn.lua")
minetest.register_on_newplayer(function(player)
player:set_attribute("spawn_pillar", minetest.serialize({x = math.random(16), y = math.random(16)}))
end)

90
nodes.lua Normal file
View File

@ -0,0 +1,90 @@
minetest.register_node("spawn_pillar:spawn_tile", {
tiles = {
"spawn_pillar_tile.png"
},
groups = {immortal = 1},
description = "Spawn Tile"
})
minetest.register_node("spawn_pillar:pillar_bottom", {
tiles = {
"spawn_pillar_pillar_bottom.png",
"spawn_pillar_pillar_crystal.png",
"spawn_pillar_pillar_crystal_bottom.png",
"spawn_pillar_pillar_crystal_bottom.png",
"spawn_pillar_pillar_crystal_bottom.png",
"spawn_pillar_pillar_crystal_bottom.png"
},
drawtype = "nodebox",
paramtype = "light",
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, -0.3125, 0.5}, -- NodeBox1
{-0.125, -0.1875, -0.125, 0.125, 0.0625, 0.125}, -- NodeBox2
{-0.1875, 0.0625, -0.1875, 0.1875, 0.3125, 0.1875}, -- NodeBox3
{-0.25, 0.3125, -0.25, 0.25, 0.5, 0.25}, -- NodeBox4
}
},
selection_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 1.3, 0.5}
}
},
light_source = 14,
collisionbox = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 1, 0.5}
}
},
groups = {not_in_creative_inventory = 1, immortal = 1},
on_construct = function(pos)
minetest.set_node(vector.add(pos, vector.new(0, 1, 0)), {name = "spawn_pillar:pillar_top"})
end,
on_destruct = function(pos)
minetest.set_node(vector.add(pos, vector.new(0, 1, 0)), {name = "air"})
end,
on_rightclick = function(pos, node, player)
minetest.show_formspec(player:get_player_name(), spawn_pillar.formname, spawn_pillar.make_formspec(player, pos))
end
})
minetest.register_node("spawn_pillar:pillar_top", {
tiles = {
"spawn_pillar_pillar_crystal.png",
"spawn_pillar_pillar_crystal.png",
"spawn_pillar_pillar_crystal.png",
"spawn_pillar_pillar_crystal.png",
"spawn_pillar_pillar_crystal.png",
"spawn_pillar_pillar_crystal.png"
},
drawtype = "nodebox",
paramtype = "light",
node_box = {
type = "fixed",
fixed = {
{-0.25, -0.5, -0.25, 0.25, -0.4375, 0.25}, -- NodeBox1
{-0.3125, -0.4375, -0.3125, 0.3125, -0.1875, 0.3125}, -- NodeBox2
{-0.375, -0.1875, -0.375, 0.375, -0.0625, 0.375}, -- NodeBox3
{-0.3125, -0.0625, -0.3125, 0.3125, 0.0625, 0.3125}, -- NodeBox4
{-0.25, 0.0625, -0.25, 0.25, 0.125, 0.25}, -- NodeBox5
{-0.1875, 0.125, -0.1875, 0.1875, 0.1875, 0.1875}, -- NodeBox6
{-0.125, 0.1875, -0.125, 0.125, 0.25, 0.125}, -- NodeBox8
{-0.0625, 0.25, -0.0625, 0.0625, 0.3125, 0.0625}, -- NodeBox9
}
},
selection_box = {
type = "fixed",
fixed = {
}
},
light_source = 14,
collisionbox = {
type = "fixed",
fixed = {
}
},
groups = {not_in_creative_inventory = 1, immortal = 1}
})

7
respawn.lua Normal file
View File

@ -0,0 +1,7 @@
-- function spawn_pillar.get_spawnpoint(player)
-- end
-- minetest.register_on_respawnplayer(function(player)
-- player:set_pos(spawn_pillar.get_spawnpoint(player))
-- end)

Binary file not shown.

After

Width:  |  Height:  |  Size: 610 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 847 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 782 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 589 B