numerous bug fixes, new machine: Wireless Control Station
This commit is contained in:
parent
688f7e39e1
commit
875cbd7701
@ -2,6 +2,7 @@
|
|||||||
elepm.upgrading = {
|
elepm.upgrading = {
|
||||||
dict = {
|
dict = {
|
||||||
machine_chip = "Machine Chip",
|
machine_chip = "Machine Chip",
|
||||||
|
wireless_chip = "Wireless Chip",
|
||||||
capacitor = "Capacitor",
|
capacitor = "Capacitor",
|
||||||
pump_filter = "Pump Filter",
|
pump_filter = "Pump Filter",
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ local function get_formspec(timer, power, buffer, state)
|
|||||||
default.gui_bg_img..
|
default.gui_bg_img..
|
||||||
default.gui_slots..
|
default.gui_slots..
|
||||||
ele.formspec.power_meter(power)..
|
ele.formspec.power_meter(power)..
|
||||||
ele.formspec.state_switcher(0, 0, state)..
|
ele.formspec.state_switcher(0, 2.5, state)..
|
||||||
ele.formspec.fluid_bar(7, 0, buffer)..
|
ele.formspec.fluid_bar(7, 0, buffer)..
|
||||||
ele.formspec.create_bar(1, 0, 100 - timer, "#00ff11", true)..
|
ele.formspec.create_bar(1, 0, 100 - timer, "#00ff11", true)..
|
||||||
"list[context;dst;1.5,0;5,3;]"..
|
"list[context;dst;1.5,0;5,3;]"..
|
||||||
@ -174,7 +174,8 @@ local function on_timer(pos, elapsed)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if added == 0 then
|
-- If the inventory is full and the miner mined something, stop the clock
|
||||||
|
if added == 0 and #itms > 0 then
|
||||||
active = "Inventory full!"
|
active = "Inventory full!"
|
||||||
refresh = false
|
refresh = false
|
||||||
break
|
break
|
||||||
|
@ -152,8 +152,8 @@ local function get_core_formspec(heat, power)
|
|||||||
"list[current_player;main;0,5.5;8,3;8]"..
|
"list[current_player;main;0,5.5;8,3;8]"..
|
||||||
ele.formspec.create_bar(0, 0, power, "#ff0000", true)..
|
ele.formspec.create_bar(0, 0, power, "#ff0000", true)..
|
||||||
ele.formspec.create_bar(0.5, 0, heat, "#ffdd11", true)..
|
ele.formspec.create_bar(0.5, 0, heat, "#ffdd11", true)..
|
||||||
"label[0,3;Power: \t"..power.."%]"..
|
"tooltip[0,0;0.25,2.5;Power: "..power.."%]"..
|
||||||
"label[0,3.25;Heat: \t"..heat.."%]"..
|
"tooltip[0.5,0;0.25,2.5;Heat: "..heat.."%]"..
|
||||||
"label[0,3.75;".. status .."]"..
|
"label[0,3.75;".. status .."]"..
|
||||||
"listring[current_player;main]"..
|
"listring[current_player;main]"..
|
||||||
"listring[context;fuel]"..
|
"listring[context;fuel]"..
|
||||||
|
@ -79,6 +79,10 @@ function ele.helpers.get_node_property(meta, pos, prop)
|
|||||||
return value
|
return value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ele.helpers.get_first_line(str)
|
||||||
|
return str:split('\n', false, 1, true)[1]
|
||||||
|
end
|
||||||
|
|
||||||
-- Look for item name regardless of mod
|
-- Look for item name regardless of mod
|
||||||
function ele.helpers.scan_item_list(item_name)
|
function ele.helpers.scan_item_list(item_name)
|
||||||
local found = nil
|
local found = nil
|
||||||
|
@ -88,6 +88,8 @@ local function validate_structure(pos, player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if player then minetest.chat_send_player(player, "Structure complete.") end
|
if player then minetest.chat_send_player(player, "Structure complete.") end
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("Thermal Evaporation Plant")
|
||||||
|
|
||||||
elethermal.cache[minetest.pos_to_string(pos)] = {
|
elethermal.cache[minetest.pos_to_string(pos)] = {
|
||||||
height = height,
|
height = height,
|
||||||
@ -266,6 +268,10 @@ minetest.register_node("elepower_thermal:evaporator_controller", {
|
|||||||
drainable = true,
|
drainable = true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
on_construct = function (pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("Thermal Evaporation Plant\nPunch to form structure")
|
||||||
|
end,
|
||||||
on_timer = controller_timer,
|
on_timer = controller_timer,
|
||||||
on_punch = function (pos, node, puncher, pointed_thing)
|
on_punch = function (pos, node, puncher, pointed_thing)
|
||||||
if validate_structure(pos, puncher:get_player_name()) then
|
if validate_structure(pos, puncher:get_player_name()) then
|
||||||
|
@ -45,6 +45,26 @@ minetest.register_craft({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Control Station
|
||||||
|
minetest.register_craft({
|
||||||
|
output = "elepower_wireless:station",
|
||||||
|
recipe = {
|
||||||
|
{"elepower_dynamics:wound_copper_coil", "elepower_dynamics:soc", "elepower_dynamics:wound_copper_coil"},
|
||||||
|
{"elepower_dynamics:viridisium_plate", "elepower_machines:machine_block", "elepower_dynamics:viridisium_plate"},
|
||||||
|
{"elepower_dynamics:wound_copper_coil", "elepower_dynamics:lcd_panel", "elepower_dynamics:wound_copper_coil"},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Control Station Chip
|
||||||
|
minetest.register_craft({
|
||||||
|
output = "elepower_wireless:card",
|
||||||
|
recipe = {
|
||||||
|
{"elepower_dynamics:wound_copper_coil", "elepower_dynamics:chip", "elepower_dynamics:wound_copper_coil"},
|
||||||
|
{"elepower_dynamics:wound_copper_coil", "basic_materials:plastic_sheet", "elepower_dynamics:wound_copper_coil"},
|
||||||
|
{"basic_materials:plastic_sheet", "group:color_red", "basic_materials:plastic_sheet"},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
-- Tesseract Frame
|
-- Tesseract Frame
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
|
|
||||||
ele.register_tool("elepower_wireless:wireless_porter", {
|
local function porter_teleport(itemstack, player, pointed_thing)
|
||||||
description = "Wireless Porter",
|
|
||||||
inventory_image = "elewireless_wireless_porter.png",
|
|
||||||
on_use = function (itemstack, player, pointed_thing)
|
|
||||||
local meta = itemstack:get_meta()
|
local meta = itemstack:get_meta()
|
||||||
local storage = ele.tools.get_tool_property(itemstack, "storage")
|
local storage = ele.tools.get_tool_property(itemstack, "storage")
|
||||||
local pos = minetest.string_to_pos(meta:get_string("receiver"))
|
local pos = minetest.string_to_pos(meta:get_string("receiver"))
|
||||||
@ -28,22 +25,36 @@ ele.register_tool("elepower_wireless:wireless_porter", {
|
|||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
if not (nstorage >= nusage and storage >= nusage) then
|
if nstorage < nusage then
|
||||||
minetest.chat_send_player(plname, "Not enough power to commit teleport!")
|
minetest.chat_send_player(plname, "Receiver is out of power!")
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
|
if storage < nusage then
|
||||||
|
minetest.chat_send_player(plname, "Your Wireless Porter is out of power!")
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Teleport player
|
-- Teleport player
|
||||||
player:set_pos(top)
|
player:set_pos(top)
|
||||||
|
|
||||||
-- TODO: Sound
|
-- TODO: Sound
|
||||||
|
|
||||||
nmeta:set_int("storage", nstorage - nusage)
|
nmeta:set_int("storage", nstorage - nusage)
|
||||||
|
ele.helpers.start_timer(pos)
|
||||||
|
|
||||||
-- Add wear
|
-- Add wear
|
||||||
meta:set_int("storage", storage - nusage)
|
meta:set_int("storage", storage - nusage)
|
||||||
itemstack = ele.tools.update_tool_wear(itemstack)
|
itemstack = ele.tools.update_tool_wear(itemstack)
|
||||||
|
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end
|
||||||
|
|
||||||
|
ele.register_tool("elepower_wireless:wireless_porter", {
|
||||||
|
description = "Wireless Porter",
|
||||||
|
inventory_image = "elewireless_wireless_porter.png",
|
||||||
|
on_use = porter_teleport,
|
||||||
|
on_secondary_use = porter_teleport,
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
if not placer or placer:get_player_name() == "" then return itemstack end
|
if not placer or placer:get_player_name() == "" then return itemstack end
|
||||||
local player = placer:get_player_name()
|
local player = placer:get_player_name()
|
||||||
@ -74,3 +85,14 @@ ele.register_tool("elepower_wireless:wireless_porter", {
|
|||||||
end,
|
end,
|
||||||
ele_capacity = 1000,
|
ele_capacity = 1000,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_craftitem("elepower_wireless:upgrade_item_transfer", {
|
||||||
|
description = "Wireless Upgrade\nAllows for transmission of matter",
|
||||||
|
groups = {wireless_chip = 2, ele_upgrade_component = 1},
|
||||||
|
inventory_image = "elewireless_upgrade_item_transfer.png",
|
||||||
|
ele_upgrade = {
|
||||||
|
usage = {
|
||||||
|
multiplier = 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
@ -12,3 +12,4 @@ dofile(mp .. "matter_receiver.lua")
|
|||||||
dofile(mp .. "matter_transmitter.lua")
|
dofile(mp .. "matter_transmitter.lua")
|
||||||
dofile(mp .. "dialler.lua")
|
dofile(mp .. "dialler.lua")
|
||||||
dofile(mp .. "tesseract.lua")
|
dofile(mp .. "tesseract.lua")
|
||||||
|
dofile(mp .. "station.lua")
|
||||||
|
216
elepower_wireless/machines/station.lua
Normal file
216
elepower_wireless/machines/station.lua
Normal file
@ -0,0 +1,216 @@
|
|||||||
|
--[[
|
||||||
|
Wireless Station:
|
||||||
|
|
||||||
|
Wireless Card -> Bind to node -> Add to station
|
||||||
|
Name the station to keep track
|
||||||
|
|
||||||
|
]]
|
||||||
|
|
||||||
|
elewi.node_handlers = {}
|
||||||
|
local desc_cache = {}
|
||||||
|
|
||||||
|
local function default_on_receive_fields(name)
|
||||||
|
local rcv = minetest.registered_nodes[name].on_receive_fields
|
||||||
|
if not rcv then return function ( ... ) end end
|
||||||
|
return function (pos, fields, sender)
|
||||||
|
return rcv(pos, name, fields, sender)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function elewi.register_handler(name, def)
|
||||||
|
assert(minetest.registered_nodes[name])
|
||||||
|
assert(def.get_formspec)
|
||||||
|
|
||||||
|
if not def.on_receive_fields then
|
||||||
|
def.on_receive_fields = default_on_receive_fields(name)
|
||||||
|
end
|
||||||
|
|
||||||
|
elewi.node_handlers[name] = def
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_desc(node)
|
||||||
|
if desc_cache[node] then return desc_cache[node] end
|
||||||
|
local n = minetest.registered_nodes[node]
|
||||||
|
if not n then return "" end
|
||||||
|
desc_cache[node] = ele.helpers.get_first_line(n.description)
|
||||||
|
return desc_cache[node]
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_formspec(power)
|
||||||
|
return "size[8,8.5]"..
|
||||||
|
default.gui_bg..
|
||||||
|
default.gui_bg_img..
|
||||||
|
default.gui_slots..
|
||||||
|
ele.formspec.power_meter(power)..
|
||||||
|
"list[context;card;3.5,1;1,1;]"..
|
||||||
|
"list[current_player;main;0,4.25;8,1;]"..
|
||||||
|
"list[current_player;main;0,5.5;8,3;8]"..
|
||||||
|
"listring[current_player;main]"..
|
||||||
|
"listring[context;card]"..
|
||||||
|
"listring[current_player;main]"..
|
||||||
|
default.get_hotbar_bg(0, 4.25)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function data_from_card(card)
|
||||||
|
if card:is_empty() then return nil end
|
||||||
|
|
||||||
|
local meta = card:get_meta()
|
||||||
|
local pstr = meta:get_string("pos")
|
||||||
|
local rpos = minetest.string_to_pos(pstr)
|
||||||
|
local node = meta:get_string("node")
|
||||||
|
if not rpos or node == "" then return nil end
|
||||||
|
|
||||||
|
-- Check validity
|
||||||
|
local nodeat = minetest.get_node_or_nil(rpos)
|
||||||
|
if not nodeat or nodeat.name ~= node then return nil end
|
||||||
|
|
||||||
|
return elewi.node_handlers[node], { pos = rpos, pos_str = pstr, node = node }
|
||||||
|
end
|
||||||
|
|
||||||
|
local function station_timer(pos, elapsed)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
local card = inv:get_stack("card", 1)
|
||||||
|
local fns, info = data_from_card(card)
|
||||||
|
|
||||||
|
local capacity = ele.helpers.get_node_property(meta, pos, "capacity")
|
||||||
|
local storage = ele.helpers.get_node_property(meta, pos, "storage")
|
||||||
|
local usage = ele.helpers.get_node_property(meta, pos, "usage")
|
||||||
|
|
||||||
|
local pow_buffer = {capacity = capacity, storage = storage, usage = usage}
|
||||||
|
local status = "Idle"
|
||||||
|
|
||||||
|
if not fns then
|
||||||
|
pow_buffer.usage = 0
|
||||||
|
meta:set_string("formspec", get_formspec(pow_buffer))
|
||||||
|
meta:set_string("infotext", "Wireless Control Station Idle")
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
status = ("Monitoring %s at %s"):format(get_desc(info.node), info.pos_str)
|
||||||
|
|
||||||
|
if storage < usage then
|
||||||
|
pow_buffer.usage = 0
|
||||||
|
status = status .. "\nOut of Power!"
|
||||||
|
meta:set_string("formspec", get_formspec(pow_buffer))
|
||||||
|
else
|
||||||
|
storage = storage - usage
|
||||||
|
meta:set_int("storage", storage)
|
||||||
|
meta:set_string("formspec", fns.get_formspec(info.pos, pow_buffer, pos, meta))
|
||||||
|
end
|
||||||
|
|
||||||
|
meta:set_string("infotext", "Wireless Control Station\n"..status)
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
|
||||||
|
if minetest.is_protected(pos, player:get_player_name()) then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
if listname == "card" and stack:get_name() ~= "elepower_wireless:card" then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
return stack:get_count()
|
||||||
|
end
|
||||||
|
|
||||||
|
local function allow_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
local stack = inv:get_stack(from_list, from_index)
|
||||||
|
return allow_metadata_inventory_put(pos, to_list, to_index, stack, player)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function set_card(itemstack, placer, pointed_thing)
|
||||||
|
local meta = itemstack:get_meta()
|
||||||
|
if not placer or placer:get_player_name() == "" then return itemstack end
|
||||||
|
local player = placer:get_player_name()
|
||||||
|
if placer:get_player_control().sneak and pointed_thing.type == "nothing" then
|
||||||
|
meta:set_string("node", "")
|
||||||
|
meta:set_string("pos", "")
|
||||||
|
meta:set_string("description",
|
||||||
|
"Wireless Control Station Card\nSneak-Right-Click on a node to bind it")
|
||||||
|
minetest.chat_send_player(player, "Cleared card.")
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
|
if pointed_thing.type == "nothing" then return itemstack end
|
||||||
|
if minetest.is_protected(pointed_thing.under, player) then
|
||||||
|
minetest.chat_send_player(player, "You do not have permission to remotely control this node!")
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
|
local node = minetest.get_node_or_nil(pointed_thing.under)
|
||||||
|
if not node or elewi.node_handlers[node.name] == nil then return end
|
||||||
|
|
||||||
|
local pstr = minetest.pos_to_string(pointed_thing.under)
|
||||||
|
local ndesc = minetest.registered_nodes[node.name]
|
||||||
|
local str = ("Bound to %s at %s"):format(ele.helpers.get_first_line(ndesc.description), pstr)
|
||||||
|
|
||||||
|
meta:set_string("node", node.name)
|
||||||
|
meta:set_string("pos", pstr)
|
||||||
|
meta:set_string("description", "Wireless Control Station Card\n"..str)
|
||||||
|
minetest.chat_send_player(player, str)
|
||||||
|
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_craftitem("elepower_wireless:card", {
|
||||||
|
description = "Wireless Control Station Card\nSneak-Right-Click on a node to bind it",
|
||||||
|
inventory_image = "elewireless_station_card.png",
|
||||||
|
wield_image = "elewireless_station_card.png",
|
||||||
|
on_place = set_card,
|
||||||
|
on_secondary_use = set_card,
|
||||||
|
stack_max = 1,
|
||||||
|
})
|
||||||
|
|
||||||
|
ele.register_machine("elepower_wireless:station", {
|
||||||
|
description = "Wireless Control Station",
|
||||||
|
groups = {cracky = 1, ele_user = 1},
|
||||||
|
tiles = {
|
||||||
|
"elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png",
|
||||||
|
"elepower_machine_side.png", "elepower_machine_side.png", "elepower_machine_side.png^elewireless_station.png",
|
||||||
|
},
|
||||||
|
ele_capacity = 8000,
|
||||||
|
ele_usage = 8,
|
||||||
|
ele_no_automatic_ports = true,
|
||||||
|
on_timer = station_timer,
|
||||||
|
on_construct = function (pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
inv:set_size("card", 1)
|
||||||
|
meta:set_string("formspec", get_formspec())
|
||||||
|
end,
|
||||||
|
on_receive_fields = function (pos, formname, fields, sender)
|
||||||
|
if sender and sender ~= "" and minetest.is_protected(pos, sender:get_player_name()) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local storage = ele.helpers.get_node_property(meta, pos, "storage")
|
||||||
|
local usage = ele.helpers.get_node_property(meta, pos, "usage")
|
||||||
|
if storage < usage then return end
|
||||||
|
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
local card = inv:get_stack("card", 1)
|
||||||
|
local fns, info = data_from_card(card)
|
||||||
|
|
||||||
|
if not fns then return end
|
||||||
|
|
||||||
|
return fns.on_receive_fields(info.pos, fields, sender, pos, meta)
|
||||||
|
end,
|
||||||
|
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||||
|
allow_metadata_inventory_move = allow_metadata_inventory_move,
|
||||||
|
ele_upgrades = {
|
||||||
|
wireless_chip = {"usage"},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Include individual node support
|
||||||
|
|
||||||
|
local mp = minetest.get_modpath("elepower_wireless") .. "/machines/station/"
|
||||||
|
if minetest.get_modpath("elepower_nuclear") ~= nil then
|
||||||
|
dofile(mp .. "fission_reactor.lua")
|
||||||
|
end
|
142
elepower_wireless/machines/station/fission_reactor.lua
Normal file
142
elepower_wireless/machines/station/fission_reactor.lua
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
|
||||||
|
local myname = "elepower_nuclear:fission_controller"
|
||||||
|
|
||||||
|
local function check(pos)
|
||||||
|
local reactpos = vector.add(pos, {x = 0, y = -1, z = 0})
|
||||||
|
local reactnode = minetest.get_node_or_nil(reactpos)
|
||||||
|
|
||||||
|
local coolpos = vector.add(pos, {x = 0, y = -2, z = 0})
|
||||||
|
local coolnode = minetest.get_node_or_nil(coolpos)
|
||||||
|
|
||||||
|
if not reactnode or reactnode.name ~= "elepower_nuclear:fission_core" then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
if not coolnode or coolnode.name ~= "elepower_nuclear:reactor_fluid_port" then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
control_meta = minetest.get_meta(pos),
|
||||||
|
core = reactpos,
|
||||||
|
core_meta = minetest.get_meta(reactpos),
|
||||||
|
coolant = coolpos,
|
||||||
|
coolant_meta = minetest.get_meta(coolpos)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_controller_formspec(meta)
|
||||||
|
local ctrls = {}
|
||||||
|
local rods = 4
|
||||||
|
local selected = meta:get_int("selected")
|
||||||
|
|
||||||
|
for i = 1, rods do
|
||||||
|
local setting = meta:get_int("c" .. i)
|
||||||
|
local xoffset = ((i / rods) * 4) + 3.75
|
||||||
|
local sel = ""
|
||||||
|
|
||||||
|
if i == selected then
|
||||||
|
sel = " <- "
|
||||||
|
end
|
||||||
|
|
||||||
|
local fspc = ("label[%f,0;%s]"):format(xoffset - 1.25, setting .. " %" .. sel)
|
||||||
|
|
||||||
|
fspc = fspc .. ele.formspec.create_bar(xoffset - 1, 0.5, 100 - setting, "#252625", true)
|
||||||
|
|
||||||
|
table.insert(ctrls, fspc)
|
||||||
|
end
|
||||||
|
|
||||||
|
return table.concat( ctrls, "" )..
|
||||||
|
"button[1,3.2;1.5,0.5;next;Next]"..
|
||||||
|
"button[2.5,3.2;1.5,0.5;prev;Previous]"..
|
||||||
|
"button[4.25,3.2;1.5,0.5;stop;SCRAM]"..
|
||||||
|
"button[6,3.2;1.5,0.5;up;Raise]"..
|
||||||
|
"button[7.5,3.2;1.5,0.5;down;Lower]"..
|
||||||
|
"tooltip[next;Select the next control rod]"..
|
||||||
|
"tooltip[prev;Select the previous control rod]"..
|
||||||
|
"tooltip[stop;Drops all the rods into the reactor core, instantly stopping it]"..
|
||||||
|
"tooltip[up;Raise selected control rod]"..
|
||||||
|
"tooltip[down;Lower selected control rod]"
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_formspec(pos, power, station, station_meta)
|
||||||
|
local width = 8
|
||||||
|
local fspec = "list[context;card;1,0;1,1;]"
|
||||||
|
local metas = check(pos)
|
||||||
|
|
||||||
|
--local comps = station_meta:get_string("components")
|
||||||
|
--local seeitems = comps:match("elepower_wireless:upgrade_item_transfer") ~= nil
|
||||||
|
|
||||||
|
if metas then
|
||||||
|
fspec = "list[context;card;2,0;1,1;]"
|
||||||
|
width = 10
|
||||||
|
|
||||||
|
-- Reactor Core
|
||||||
|
|
||||||
|
local power = metas.core_meta:get_int("setting")
|
||||||
|
local heat = metas.core_meta:get_int("heat")
|
||||||
|
|
||||||
|
local status = "Activate by extracting the control rods"
|
||||||
|
|
||||||
|
if heat > 80 then
|
||||||
|
status = "!!! TEMPERATURE CRITICAL !!!"
|
||||||
|
elseif heat > 90 then
|
||||||
|
status = "!!! REACTOR CRITICAL !!!"
|
||||||
|
elseif heat > 95 then
|
||||||
|
status = "!!! REACTOR MELTDOWN IMMINENT !!!"
|
||||||
|
elseif power > 0 then
|
||||||
|
status = "Active reaction chain"
|
||||||
|
end
|
||||||
|
|
||||||
|
fspec = fspec..
|
||||||
|
ele.formspec.create_bar(1, 0, power, "#ff0000", true)..
|
||||||
|
ele.formspec.create_bar(1.5, 0, heat, "#ffdd11", true)..
|
||||||
|
"tooltip[1,0;0.25,2.5;Power: "..power.."%]"..
|
||||||
|
"tooltip[1.5,0;0.25,2.5;Heat: "..heat.."%]"..
|
||||||
|
"label[1,3.75;".. status .."]"
|
||||||
|
|
||||||
|
-- Rods
|
||||||
|
fspec = fspec .. get_controller_formspec(metas.control_meta)
|
||||||
|
|
||||||
|
-- Coolant port
|
||||||
|
|
||||||
|
local cool = fluid_lib.get_buffer_data(metas.coolant, "cool")
|
||||||
|
local hot = fluid_lib.get_buffer_data(metas.coolant, "hot")
|
||||||
|
|
||||||
|
fspec = fspec ..
|
||||||
|
ele.formspec.fluid_bar(8, 0, cool)..
|
||||||
|
ele.formspec.fluid_bar(9, 0, hot)
|
||||||
|
|
||||||
|
--if seeitems then
|
||||||
|
-- fspec = fspec ..
|
||||||
|
-- "button[2,1;1,1;inv;Items]"
|
||||||
|
--end
|
||||||
|
end
|
||||||
|
|
||||||
|
local centered = (width - 8) / 2
|
||||||
|
return "size["..width..",8.5]"..
|
||||||
|
default.gui_bg..
|
||||||
|
default.gui_bg_img..
|
||||||
|
default.gui_slots..
|
||||||
|
ele.formspec.power_meter(power)..
|
||||||
|
"list[current_player;main;"..centered..",4.25;8,1;]"..
|
||||||
|
"list[current_player;main;"..centered..",5.5;8,3;8]"..
|
||||||
|
fspec..
|
||||||
|
"listring[current_player;main]"..
|
||||||
|
"listring[context;card]"..
|
||||||
|
"listring[current_player;main]"..
|
||||||
|
default.get_hotbar_bg(centered, 4.25)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function on_receive_fields(pos, fields, sender, station, station_meta)
|
||||||
|
--if fields["inv"] then
|
||||||
|
-- return
|
||||||
|
--end
|
||||||
|
|
||||||
|
return minetest.registered_nodes[myname].on_receive_fields(pos, myname, fields, sender)
|
||||||
|
end
|
||||||
|
|
||||||
|
elewi.register_handler(myname, {
|
||||||
|
get_formspec = get_formspec,
|
||||||
|
on_receive_fields = on_receive_fields
|
||||||
|
})
|
@ -1,3 +1,4 @@
|
|||||||
name = elepower_wireless
|
name = elepower_wireless
|
||||||
description = Going wireless!
|
description = Going wireless!
|
||||||
depends = elepower_dynamics,elepower_machines
|
depends = elepower_dynamics,elepower_machines
|
||||||
|
optional_depends = elepower_nuclear
|
||||||
|
BIN
elepower_wireless/textures/elewireless_station.png
Normal file
BIN
elepower_wireless/textures/elewireless_station.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
BIN
elepower_wireless/textures/elewireless_station_card.png
Normal file
BIN
elepower_wireless/textures/elewireless_station_card.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 718 B |
BIN
elepower_wireless/textures/elewireless_upgrade_item_transfer.png
Normal file
BIN
elepower_wireless/textures/elewireless_upgrade_item_transfer.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
Loading…
Reference in New Issue
Block a user