Initial commit
commit
331782a0d1
|
@ -0,0 +1,49 @@
|
|||
local NAME = minetest.get_current_modname()
|
||||
local PATH = minetest.get_modpath(NAME) .."/rules/"
|
||||
local MODFILES = minetest.get_dir_list(PATH, false)
|
||||
|
||||
serverrules = {}
|
||||
|
||||
spacenum = 20 - string.len(NAME)
|
||||
minetest.debug("│ " .. NAME .. string.rep(" ",spacenum) .. "init")
|
||||
|
||||
-- This assumes that the lua/ subdir contains lua code only.
|
||||
|
||||
for i=1,table.getn(MODFILES),1
|
||||
do
|
||||
minetest.debug("│ "..NAME .. string.rep(" ",spacenum) .."load " .. MODFILES[i])
|
||||
dofile(PATH .. MODFILES[i])
|
||||
end
|
||||
|
||||
minetest.debug("| "..NAME .. string.rep(" ", spacenum) .."rules loaded!")
|
||||
|
||||
|
||||
local rand = PseudoRandom(tonumber(SecureRandom():next_bytes():byte(1)))
|
||||
|
||||
local function getruleset()
|
||||
index = math.floor(rand:next() / 32767 * #serverrules + 1)
|
||||
return serverrules[index] or {"A bomb is a bad choice for close range combat."}
|
||||
end
|
||||
|
||||
local function show_rules(playername)
|
||||
local ruleset = getruleset()
|
||||
local formspec = "size[10,12]real_coordinates[true]textarea[0,0;10,11;;rules;"
|
||||
for i=1, #ruleset do
|
||||
formspec = formspec .. i .. ". " .. minetest.formspec_escape(ruleset[i]) .. "\n"
|
||||
end
|
||||
formspec = formspec .. "]button_exit[0,11;10,1;;I agree to be bound by these terms and conditions]"
|
||||
print(formspec)
|
||||
minetest.show_formspec(playername, "idontcare", formspec)
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("rules",{
|
||||
params = "",
|
||||
description = "Shows server rules YOU MUST AGREE BEFORE PLAYING",
|
||||
func = function(name, param)
|
||||
show_rules(name)
|
||||
return true
|
||||
end
|
||||
})
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
show_rules(player:get_player_name())
|
||||
end)
|
|
@ -0,0 +1,4 @@
|
|||
table.insert(serverrules, {
|
||||
"don't be a hero",
|
||||
"Shoot anything that can't shoot back (e.g little goats; circus people)"
|
||||
})
|
Loading…
Reference in New Issue