This commit is contained in:
Evert Prants 2018-08-04 22:45:04 +03:00
parent 93ed7eeeaa
commit cc909b2f51
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
4 changed files with 39 additions and 30 deletions

View File

@ -47,6 +47,7 @@ function ele.register_fluid_generator(nodename, nodedef)
},
tube = false,
on_timer = function (pos, elapsed)
local refresh = false
local meta = minetest.get_meta(pos)
local nodename = nodename
@ -59,12 +60,14 @@ function ele.register_fluid_generator(nodename, nodedef)
-- Fluid buffer
local flbuffer = fluid_lib.get_buffer_data(pos, buffer_name)
local pow_percent
if not flbuffer or flbuffer.fluid == "" then return false end
while true do
-- If more to burn and the energy produced was used: produce some more
if burn_time > 0 then
if storage + generation > capacity then
return false
break
end
meta:set_int("storage", storage + generation)
@ -73,7 +76,7 @@ function ele.register_fluid_generator(nodename, nodedef)
meta:set_int("burn_time", burn_time)
end
local pow_percent = math.floor((storage / capacity) * 100)
pow_percent = math.floor((storage / capacity) * 100)
-- Burn another bucket of lava
if burn_time == 0 then
@ -87,16 +90,19 @@ function ele.register_fluid_generator(nodename, nodedef)
local active_node = nodename.."_active"
ele.helpers.swap_node(pos, active_node)
refresh = true
else
meta:set_string("formspec", get_formspec(pow_percent, 0, flbuffer))
meta:set_string("infotext", ("%s Idle\n%s\n%s"):format(nodedef.description,
ele.capacity_text(capacity, storage), fluid_lib.buffer_to_string(flbuffer)))
ele.helpers.swap_node(pos, nodename)
return false
end
end
if burn_totaltime == 0 then burn_totaltime = 1 end
break
end
local percent = math.floor((burn_time / burn_totaltime) * 100)
meta:set_string("formspec", get_formspec(pow_percent, percent, flbuffer))
@ -105,7 +111,7 @@ function ele.register_fluid_generator(nodename, nodedef)
meta:set_int(buffer_name .. "_fluid_storage", flbuffer.amount)
return true
return refresh
end,
on_construct = function (pos)
local meta = minetest.get_meta(pos)

View File

@ -470,6 +470,7 @@ ele.register_base_device("elepower_nuclear:fission_core", {
meta:set_string("formspec", get_core_formspec(0,0,false))
end,
can_dig = can_dig,
allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_move = allow_metadata_inventory_move,
allow_metadata_inventory_take = ele.default.allow_metadata_inventory_take,

View File

@ -1,6 +1,8 @@
ele.tools = {}
local creative = minetest.settings:get_bool("creative_mode")
-- Get a tool property
function ele.tools.get_tool_property(itemstack, param)
local meta = itemstack:get_meta()
@ -23,7 +25,7 @@ function ele.tools.groupcaps(itemstack)
local meta = itemstack:get_meta()
local itemdef = minetest.registered_items[itemstack:get_name()]
if wear == 65535 and meta:get_int("disable") ~= 1 then
if wear == 65535 and meta:get_int("disable") ~= 1 and not creative then
local prvcaps = itemstack:get_tool_capabilities()
meta:set_string("toolcaps", minetest.serialize(prvcaps))
meta:set_tool_capabilities({})
@ -121,7 +123,7 @@ function ele.register_tool(toolname, tooldef)
local usage = ele.tools.get_tool_property(itemstack, "usage")
local pos = pointed_thing.under
if not pos or storage < usage then
if not pos or (storage < usage and not creative) then
return nil
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 946 KiB

After

Width:  |  Height:  |  Size: 889 KiB