mirror of
https://github.com/HybridDog/nether-pack.git
synced 2025-06-29 14:41:05 +02:00
Compare commits
4 Commits
v1.0.0
...
html_forms
Author | SHA1 | Date | |
---|---|---|---|
dbcd72aa25 | |||
817efcdd29 | |||
6507e43dc5 | |||
27bf94c4d0 |
@ -315,6 +315,58 @@ local guide_forms = {
|
||||
}
|
||||
|
||||
-- change the infos to formspecs
|
||||
for n,data in ipairs(guide_infos) do
|
||||
local html_text = ""
|
||||
local form = ""
|
||||
local y = 0
|
||||
local x = guide_size.cx
|
||||
for _,i in ipairs(data) do
|
||||
local typ, content = unpack(i)
|
||||
if typ == "y" then
|
||||
y = y+content
|
||||
elseif typ == "x" then
|
||||
x = math.max(x, content)
|
||||
elseif typ == "text" then
|
||||
html_text = html_text .. content .. "\n"
|
||||
local tab = minetest.wrap_text(content, guide_size.fx, true)
|
||||
local l = guide_size.cx
|
||||
for _,str in ipairs(tab) do
|
||||
--~ form = form.."label["..guide_size.cx ..","..guide_size.cy+y..";"..str.."]"
|
||||
y = y+guide_size.fy
|
||||
l = math.max(l, #str)
|
||||
end
|
||||
x = math.max(x, l/font_size)
|
||||
elseif typ == "image" then
|
||||
local w, h, texture_name, px, py = unpack(content)
|
||||
if not px then
|
||||
--~ form = form.."image["..guide_size.cx..","..guide_size.cy+y+h*0.3 ..";"..w..","..h..";"..texture_name.."]"
|
||||
html_text = html_text ..
|
||||
("<img name=%s width=%g height=%g>\n"):format(
|
||||
texture_name, w, h)
|
||||
y = y+h
|
||||
else
|
||||
px = guide_size.cx+px
|
||||
py = py or 0
|
||||
html_text = html_text ..
|
||||
("<img name=%s width=%g height=%g>\n"):format(
|
||||
texture_name, w, h)
|
||||
--~ form = form.."image["..px..","..
|
||||
--~ guide_size.cy+y+h*0.3+py ..";"..w..","..h..";"..texture_name.."]"
|
||||
x = math.max(x, px+w)
|
||||
end
|
||||
end
|
||||
end
|
||||
form = ("formspec_version[4]size[%g,%g;]hypertext[0,0;%g,%g;html;%s]button[%g,%g;1,2;quit;Back]"
|
||||
):format(
|
||||
x * 1.8, y + 1,
|
||||
x * 1.8, y,
|
||||
minetest.formspec_escape(html_text),
|
||||
0.5 * x - 0.5, y)
|
||||
|
||||
guide_forms[n] = {data.description, form}
|
||||
end
|
||||
print(dump(guide_forms))
|
||||
--[[
|
||||
for n,data in ipairs(guide_infos) do
|
||||
local form = ""
|
||||
local y = 0
|
||||
@ -351,6 +403,7 @@ for n,data in ipairs(guide_infos) do
|
||||
form = "size["..x*1.8 ..","..y+1 ..";]"..form.."button["..x/2-0.5 ..","..y ..";1,2;quit;Back]"
|
||||
guide_forms[n] = {data.description, form}
|
||||
end
|
||||
--]]
|
||||
|
||||
local desc_tab = {}
|
||||
for n,i in ipairs(guide_forms) do
|
||||
|
@ -19,15 +19,6 @@ end
|
||||
|
||||
--== EDITABLE OPTIONS ==--
|
||||
|
||||
--says some information.
|
||||
nether.info = true
|
||||
|
||||
-- tell everyone about the generation
|
||||
nether.inform_all = minetest.is_singleplayer()
|
||||
|
||||
--1:<a bit of information> 2:<acceptable amount of information> 3:<lots of text>
|
||||
nether.max_spam = 2
|
||||
|
||||
-- Depth of the nether
|
||||
local nether_middle = -20000
|
||||
|
||||
@ -94,9 +85,17 @@ local NETHER_SHROOM_FREQ = 100
|
||||
|
||||
--== END OF EDITABLE OPTIONS ==--
|
||||
|
||||
if nether.info then
|
||||
local path = minetest.get_modpath"nether"
|
||||
dofile(path .. "/settings.lua")
|
||||
local nether_weird_noise = dofile(path .. "/weird_mapgen_noise.lua")
|
||||
dofile(path .. "/items.lua")
|
||||
--dofile(path .. "/furnace.lua")
|
||||
dofile(path .. "/pearl.lua")
|
||||
|
||||
|
||||
if nether.log_level >= 1 then
|
||||
function nether:inform(msg, spam, t)
|
||||
if spam <= self.max_spam then
|
||||
if spam <= self.log_level then
|
||||
local info
|
||||
if t then
|
||||
info = "[nether] " .. msg .. (" after ca. %.3g s"):format(
|
||||
@ -105,7 +104,7 @@ if nether.info then
|
||||
info = "[nether] " .. msg
|
||||
end
|
||||
print(info)
|
||||
if self.inform_all then
|
||||
if self.log_to_chat then
|
||||
minetest.chat_send_all(info)
|
||||
end
|
||||
end
|
||||
@ -116,12 +115,6 @@ else
|
||||
end
|
||||
|
||||
|
||||
local path = minetest.get_modpath"nether"
|
||||
local nether_weird_noise = dofile(path.."/weird_mapgen_noise.lua")
|
||||
dofile(path.."/items.lua")
|
||||
--dofile(path.."/furnace.lua")
|
||||
dofile(path.."/pearl.lua")
|
||||
|
||||
-- Weierstrass function stuff from https://github.com/slemonide/gen
|
||||
local SIZE = 1000
|
||||
local ssize = math.ceil(math.abs(SIZE))
|
||||
|
@ -2,8 +2,7 @@
|
||||
|
||||
-- kills the player if he uses PilzAdam portal
|
||||
local portal_target = nether.buildings+1
|
||||
local nether_prisons = minetest.settings:get_bool("enable_damage")
|
||||
local obsidian_portal_kills = nether_prisons and true
|
||||
local damage_enabled = minetest.settings:get_bool"enable_damage"
|
||||
local mclike_portal = false
|
||||
|
||||
local abm_allowed
|
||||
@ -13,20 +12,20 @@ end)
|
||||
|
||||
local save_path = minetest.get_worldpath() .. "/nether_players"
|
||||
local players_in_nether = {}
|
||||
-- only get info from file if nether prisons
|
||||
if nether_prisons then
|
||||
|
||||
-- Load the list of players which are trapped in the nether
|
||||
-- (or would be trapped if nether.trap_players was true)
|
||||
do
|
||||
local file = io.open(save_path, "r")
|
||||
if not file then
|
||||
return
|
||||
end
|
||||
local contents = file:read"*all"
|
||||
io.close(file)
|
||||
if not contents then
|
||||
return
|
||||
end
|
||||
local playernames = string.split(contents, " ")
|
||||
for i = 1,#playernames do
|
||||
players_in_nether[playernames[i]] = true
|
||||
if file then
|
||||
local contents = file:read"*all"
|
||||
io.close(file)
|
||||
if contents then
|
||||
local playernames = string.split(contents, " ")
|
||||
for i = 1,#playernames do
|
||||
players_in_nether[playernames[i]] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -43,7 +42,7 @@ local function save_nether_players()
|
||||
end
|
||||
|
||||
local update_background
|
||||
if nether_prisons then
|
||||
if nether.trap_players then
|
||||
function update_background(player, down)
|
||||
if down then
|
||||
player:set_sky({r=15, g=0, b=0}, "plain")
|
||||
@ -95,9 +94,6 @@ end
|
||||
-- teleports players to nether or helps it
|
||||
local function player_to_nether(player, pos)
|
||||
local pname = player:get_player_name()
|
||||
if players_in_nether[pname] then
|
||||
return
|
||||
end
|
||||
players_in_nether[pname] = true
|
||||
save_nether_players()
|
||||
update_background(player, true)
|
||||
@ -107,8 +103,10 @@ local function player_to_nether(player, pos)
|
||||
end
|
||||
minetest.chat_send_player(pname, "For any reason you arrived here. " ..
|
||||
"Type /nether_help to find out things like craft recipes.")
|
||||
player:set_hp(0)
|
||||
if not nether_prisons then
|
||||
if nether.trap_players then
|
||||
player:set_hp(0)
|
||||
end
|
||||
if not damage_enabled or not nether.trap_players then
|
||||
player:set_pos(get_player_died_target(player))
|
||||
end
|
||||
end
|
||||
@ -119,7 +117,7 @@ local function player_from_nether(player, pos)
|
||||
players_in_nether[pname] = nil
|
||||
save_nether_players()
|
||||
end
|
||||
update_background(player)
|
||||
update_background(player, false)
|
||||
player:set_pos(pos)
|
||||
end
|
||||
|
||||
@ -179,7 +177,8 @@ minetest.register_chatcommand("from_hell", {
|
||||
})
|
||||
|
||||
|
||||
if nether_prisons then
|
||||
-- Disallow teleportation and change spawn positions if the nether traps players
|
||||
if nether.trap_players then
|
||||
-- randomly set player position when he/she dies in nether
|
||||
minetest.register_on_respawnplayer(function(player)
|
||||
local pname = player:get_player_name()
|
||||
@ -229,7 +228,7 @@ if nether_prisons then
|
||||
else
|
||||
minetest.log("action", "Player \"" .. pname ..
|
||||
"\" must not be in the nether, teleporting it!")
|
||||
update_background(player)
|
||||
update_background(player, false)
|
||||
current_pos.y = 20
|
||||
player:set_pos(current_pos)
|
||||
end
|
||||
@ -266,12 +265,6 @@ if nether_prisons then
|
||||
end
|
||||
end
|
||||
end)
|
||||
else
|
||||
-- test if player is in nether when he/she joins
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
players_in_nether[player:get_player_name()] =
|
||||
player:get_pos().y < nether.start or nil
|
||||
end)
|
||||
end
|
||||
|
||||
-- removes the violet stuff from the obsidian portal
|
||||
@ -317,7 +310,7 @@ local function obsi_teleport_player(player, pos, target)
|
||||
end
|
||||
|
||||
local has_teleported
|
||||
if obsidian_portal_kills then
|
||||
if damage_enabled then
|
||||
obsidian_teleport(player, pname)
|
||||
has_teleported = true
|
||||
elseif not mclike_portal then
|
||||
@ -649,13 +642,19 @@ local function set_portal(t, z,x, y)
|
||||
t[z][x] = y
|
||||
end
|
||||
|
||||
local function get_player_nodepos(player)
|
||||
local pos = player:get_pos()
|
||||
pos.y = pos.y + player:get_properties().collisionbox[2] + 0.5
|
||||
return vector.round(pos)
|
||||
end
|
||||
|
||||
-- used when a player eats that fruit in a portal
|
||||
function nether.teleport_player(player)
|
||||
if not player then
|
||||
minetest.log("error", "[nether] Missing player.")
|
||||
return
|
||||
end
|
||||
local pos = vector.round(player:get_pos())
|
||||
local pos = get_player_nodepos(player)
|
||||
if not is_netherportal(pos) then
|
||||
return
|
||||
end
|
||||
|
23
nether/settings.lua
Normal file
23
nether/settings.lua
Normal file
@ -0,0 +1,23 @@
|
||||
local default_settings = {
|
||||
trap_players = true,
|
||||
log_to_chat = false,
|
||||
log_level = 2,
|
||||
}
|
||||
|
||||
nether.settings = {}
|
||||
|
||||
for name,dv in pairs(default_settings) do
|
||||
local setting
|
||||
local setting_name = "nether." .. name
|
||||
if type(dv) == "boolean" then
|
||||
setting = minetest.settings:get_bool(setting_name)
|
||||
elseif type(dv) == "number" then
|
||||
setting = tonumber(minetest.settings:get(setting_name))
|
||||
else
|
||||
error"[nether] Only boolean and number settings are available"
|
||||
end
|
||||
if setting == nil then
|
||||
setting = dv
|
||||
end
|
||||
nether[name] = setting
|
||||
end
|
19
nether/settingtypes.txt
Normal file
19
nether/settingtypes.txt
Normal file
@ -0,0 +1,19 @@
|
||||
# If enabled, regular players which are in the nether can leave it only with
|
||||
# a nether portal and other ways of teleportation, e.g. the /spawn
|
||||
# chatcommand, are blocked. Similarly, the nether can only be entered with a
|
||||
# portal.
|
||||
# This forces the players to investigate the nether and build a portal with
|
||||
# hellish effort to go back to their home in the overworld.
|
||||
# It is recommended to disable this setting in creative mode or if damage is
|
||||
# disabled.
|
||||
nether.trap_players (Trap players) bool true
|
||||
|
||||
# If enabled, show log messages in the chat and not only in debug.txt
|
||||
nether.log_to_chat (Log messages to chat) bool false
|
||||
|
||||
# Specify how much text is printed for debugging purposes
|
||||
# 0: Disabled
|
||||
# 1: A bit of information
|
||||
# 2: Acceptable amount of information
|
||||
# 3: Lots of text
|
||||
nether.log_level (Log level) int 2 0 3
|
Reference in New Issue
Block a user