MT-CTF / capturetheflag

Capture the Flag game using the Minetest Voxel Engine
https://ctf.rubenwardy.com
83 stars 88 forks source link

hpregen mod crashes server #323

Closed 9joshua closed 5 years ago

9joshua commented 5 years ago

Minetest version 5.0.0-dev The server starts when the hpregen mod is removed, otherwise:

2019-01-10 06:03:46: ERROR[Main]: ModError: Failed to load and run script from minetest/bin/../games/minetest_game/mods/hpregen/init.lua:
2019-01-10 06:03:46: ERROR[Main]: ...est/bin/../games/minetest_game/mods/hpregen/init.lua:2: attempt to compare nil with number
2019-01-10 06:03:46: ERROR[Main]: stack traceback:
2019-01-10 06:03:46: ERROR[Main]:   ...est/bin/../games/minetest_game/mods/hpregen/init.lua:2: in main chunk

contents of hpregen/init.lua:

local regen_interval = tonumber(minetest.settings:get("regen_interval"))
if regen_interval <= 0 then
    regen_interval = 6
end
local regen_amount = tonumber(minetest.settings:get("regen_amount"))
if regen_amount <= 0 then
    regen_amount = 1
end

local function regen_all()
    for _, player in pairs(minetest.get_connected_players()) do
        local oldhp = player:get_hp()
        if oldhp > 0 then
            local newhp = oldhp + regen_amount
            if newhp > 20 then
                newhp = 20
            end
            player:set_hp(newhp)
        end
    end
    minetest.after(regen_interval, regen_all)
end
minetest.after(regen_interval, regen_all)

Looks like it can't define minetest.settings:get("regen_interval") and probably minetest.settings:get("regen_amount")

rubenwardy commented 5 years ago

This is weird, as those settings are defined here:

https://github.com/MT-CTF/capturetheflag/blob/master/minetest.conf#L6-L7

How are you running the server? Are you using the whole game, or have you modified things?

9joshua commented 5 years ago

Sorry, I didn't add this to my .conf file. Works now.