rolling-8

This commit is contained in:
Lars Mueller 2020-03-13 18:13:45 +01:00
parent 94e38087e6
commit a2cca67e48
4 changed files with 20 additions and 0 deletions

@ -5,6 +5,7 @@ if _VERSION then
end
if _VERSION > "Lua 5.1" then -- TODO automatically use _ENV instead of s/getfenv if _VERSION > 5.1
-- not throwing error("Too new Lua version! modlib requires Lua 5.1 or smaller.") anymore
unpack = unpack or table.unpack -- unpack was moved to table.unpack in Lua 5.2
loadstring = load
function setfenv(fn, env)
local i = 1

@ -45,6 +45,10 @@ function write_all_to_file()
write_to_file(name, channel, current_date)
end
end
function write_safe(channelname, msg)
write(channelname, msg)
write_all_to_file()
end
local timer = 0

@ -63,6 +63,15 @@ function check_player_privs(playername, privtable)
return missing_privs, to_lose_privs
end
function box_box_collision(a, b)
for i=1, 3 do
if a[i] < (b[i] + b[i+3]) or b[i] < (a[i] + a[i+3]) then
return false
end
end
return true
end
minetest.register_globalstep(function(dtime)
for k, v in pairs(delta_times) do
local v=dtime+v

@ -1,5 +1,11 @@
-- TODO probably set string metatables ?
-- String helpers - split & trim at end & begin
function upper_first(str)
return str:sub(1,1):upper()..str:sub(2)
end
function lower_first(str)
return str:sub(1,1):lower()..str:sub(2)
end
function starts_with(str, start) return str:sub(1, start:len()) == start end
function ends_with(str, suffix)
return str:sub(str:len() - suffix:len() + 1) == suffix