mirror of
https://github.com/minetest-mods/mesecons.git
synced 2024-12-26 10:20:19 +01:00
Fix #196, removes soft-depend on commonlib
This commit is contained in:
parent
b3aa8f5d13
commit
011543a782
@ -6,18 +6,6 @@ function mesecon.move_node(pos, newpos)
|
|||||||
minetest.get_meta(pos):from_table(meta)
|
minetest.get_meta(pos):from_table(meta)
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[ new functions:
|
|
||||||
mesecon.flattenrules(allrules)
|
|
||||||
mesecon.rule2bit(findrule, allrules)
|
|
||||||
mesecon.rule2meta(findrule, allrules)
|
|
||||||
dec2bin(n)
|
|
||||||
mesecon.getstate(nodename, states)
|
|
||||||
mesecon.getbinstate(nodename, states)
|
|
||||||
mesecon.get_bit(binary, bit)
|
|
||||||
mesecon.set_bit(binary, bit, value)
|
|
||||||
mesecon.invertRule(r)
|
|
||||||
--]]
|
|
||||||
|
|
||||||
function mesecon.flattenrules(allrules)
|
function mesecon.flattenrules(allrules)
|
||||||
--[[
|
--[[
|
||||||
{
|
{
|
||||||
@ -101,23 +89,14 @@ function mesecon.rule2meta(findrule, allrules)
|
|||||||
return allrules[index]
|
return allrules[index]
|
||||||
end
|
end
|
||||||
|
|
||||||
if convert_base then
|
function mesecon.dec2bin(n)
|
||||||
print(
|
|
||||||
"base2dec is tonumber(num,base1)\n"..
|
|
||||||
"commonlib needs dec2base(num,base2)\n"..
|
|
||||||
"and it needs base2base(num,base1,base2),\n"..
|
|
||||||
"which is dec2base(tonumber(num,base1),base2)"
|
|
||||||
)
|
|
||||||
else
|
|
||||||
function dec2bin(n)
|
|
||||||
local x, y = math.floor(n / 2), n % 2
|
local x, y = math.floor(n / 2), n % 2
|
||||||
if (n > 1) then
|
if (n > 1) then
|
||||||
return dec2bin(x)..y
|
return mesecon.dec2bin(x)..y
|
||||||
else
|
else
|
||||||
return ""..y
|
return ""..y
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
function mesecon.getstate(nodename, states)
|
function mesecon.getstate(nodename, states)
|
||||||
for state, name in ipairs(states) do
|
for state, name in ipairs(states) do
|
||||||
@ -129,7 +108,7 @@ function mesecon.getstate(nodename, states)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function mesecon.getbinstate(nodename, states)
|
function mesecon.getbinstate(nodename, states)
|
||||||
return dec2bin(mesecon.getstate(nodename, states)-1)
|
return mesecon.dec2bin(mesecon.getstate(nodename, states)-1)
|
||||||
end
|
end
|
||||||
|
|
||||||
function mesecon.get_bit(binary,bit)
|
function mesecon.get_bit(binary,bit)
|
||||||
@ -141,11 +120,11 @@ end
|
|||||||
function mesecon.set_bit(binary,bit,value)
|
function mesecon.set_bit(binary,bit,value)
|
||||||
if value == "1" then
|
if value == "1" then
|
||||||
if not mesecon.get_bit(binary,bit) then
|
if not mesecon.get_bit(binary,bit) then
|
||||||
return dec2bin(tonumber(binary,2)+math.pow(2,bit-1))
|
return mesecon.dec2bin(tonumber(binary,2)+math.pow(2,bit-1))
|
||||||
end
|
end
|
||||||
elseif value == "0" then
|
elseif value == "0" then
|
||||||
if mesecon.get_bit(binary,bit) then
|
if mesecon.get_bit(binary,bit) then
|
||||||
return dec2bin(tonumber(binary,2)-math.pow(2,bit-1))
|
return mesecon.dec2bin(tonumber(binary,2)-math.pow(2,bit-1))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return binary
|
return binary
|
||||||
|
@ -559,7 +559,6 @@ for d = 0, 1 do
|
|||||||
node_box = node_box,
|
node_box = node_box,
|
||||||
on_construct = reset_meta,
|
on_construct = reset_meta,
|
||||||
on_receive_fields = on_receive_fields,
|
on_receive_fields = on_receive_fields,
|
||||||
on_timer = handle_timer,
|
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
mesecons = mesecons,
|
mesecons = mesecons,
|
||||||
digiline = digiline,
|
digiline = digiline,
|
||||||
@ -600,7 +599,7 @@ minetest.register_node(BASENAME .. "_burnt", {
|
|||||||
groups = {dig_immediate=2, not_in_creative_inventory=1},
|
groups = {dig_immediate=2, not_in_creative_inventory=1},
|
||||||
drop = BASENAME.."0000",
|
drop = BASENAME.."0000",
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
selection_box = selectionbox,
|
selection_box = selection_box,
|
||||||
node_box = node_box,
|
node_box = node_box,
|
||||||
on_construct = reset_meta,
|
on_construct = reset_meta,
|
||||||
on_receive_fields = on_receive_fields,
|
on_receive_fields = on_receive_fields,
|
||||||
|
Loading…
Reference in New Issue
Block a user