2012-10-30 16:04:35 +06:00
|
|
|
table.contains = function(t, v)
|
|
|
|
for _, i in ipairs(t) do
|
|
|
|
if i == v then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
2012-10-31 18:36:51 +06:00
|
|
|
function table:get_index(value)
|
|
|
|
for i, v in ipairs(self) do
|
|
|
|
if v == value then
|
|
|
|
return i
|
2012-10-30 16:04:35 +06:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function hacky_swap_node(pos,name)
|
|
|
|
local node = minetest.env:get_node(pos)
|
|
|
|
local meta = minetest.env:get_meta(pos)
|
|
|
|
local meta0 = meta:to_table()
|
|
|
|
if node.name == name then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
node.name = name
|
|
|
|
local meta0 = meta:to_table()
|
|
|
|
minetest.env:set_node(pos,node)
|
|
|
|
meta = minetest.env:get_meta(pos)
|
|
|
|
meta:from_table(meta0)
|
|
|
|
end
|
2012-10-31 13:29:10 +06:00
|
|
|
|
|
|
|
function string:capitalize()
|
|
|
|
return self:sub(1,1):upper()..self:sub(2):lower()
|
|
|
|
end
|
2012-10-31 18:36:51 +06:00
|
|
|
|
|
|
|
function minetest.get_item_group(name, group)
|
|
|
|
if not minetest.registered_items[name] or not minetest.registered_items[name].groups[group] then
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
return minetest.registered_items[name].groups[group]
|
|
|
|
end
|