| | |
| | | minetest.register_craft({ |
| | | output = "technic:forcefield_emitter_off", |
| | | recipe = { |
| | | {"default:mese", "technic:motor", "default:mese" }, |
| | | {"default:mese", "basic_materials:motor", "default:mese" }, |
| | | {"technic:deployer_off", "technic:machine_casing", "technic:deployer_off"}, |
| | | {"default:mese", "technic:hv_cable", "default:mese" }, |
| | | } |
| | |
| | | -- | | |
| | | -- \___/\___/ |
| | | |
| | | local function update_forcefield(pos, meta, active, first) |
| | | local function update_forcefield(pos, meta, active) |
| | | local shape = meta:get_int("shape") |
| | | local range = meta:get_int("range") |
| | | local vm = VoxelManip() |
| | |
| | | vm:set_data(data) |
| | | vm:update_liquids() |
| | | vm:write_to_map() |
| | | -- update_map is very slow, but if we don't call it we'll |
| | | -- get phantom blocks on the client. |
| | | if not active or first then |
| | | vm:update_map() |
| | | end |
| | | end |
| | | |
| | | local function set_forcefield_formspec(meta) |
| | |
| | | else |
| | | formspec = formspec.."button[0,1;5,1;mesecon_mode_0;"..S("Controlled by Mesecon Signal").."]" |
| | | end |
| | | -- TODO: String replacement with %s will stop working with client-side translations |
| | | if meta:get_int("enabled") == 0 then |
| | | formspec = formspec.."button[0,1.75;5,1;enable;"..S("%s Disabled"):format(S("%s Forcefield Emitter"):format("HV")).."]" |
| | | formspec = formspec.."button[0,1.75;5,1;enable;".. |
| | | S("%s Disabled"):format(S("%s Forcefield Emitter"):format("HV")).."]" |
| | | else |
| | | formspec = formspec.."button[0,1.75;5,1;disable;"..S("%s Enabled"):format(S("%s Forcefield Emitter"):format("HV")).."]" |
| | | formspec = formspec.."button[0,1.75;5,1;disable;".. |
| | | S("%s Enabled"):format(S("%s Forcefield Emitter"):format("HV")).."]" |
| | | end |
| | | meta:set_string("formspec", formspec) |
| | | end |
| | | |
| | | local forcefield_receive_fields = function(pos, formname, fields, sender) |
| | | local player_name = sender:get_player_name() |
| | | if minetest.is_protected(pos, player_name) then |
| | | minetest.chat_send_player(player_name, "You are not allowed to edit this!") |
| | | minetest.record_protection_violation(pos, player_name) |
| | | return |
| | | end |
| | | local meta = minetest.get_meta(pos) |
| | | local range = nil |
| | | if fields.range then |
| | |
| | | technic.swap_node(pos, "technic:forcefield_emitter_off") |
| | | end |
| | | elseif eu_input >= power_requirement then |
| | | local first = false |
| | | if node.name == "technic:forcefield_emitter_off" then |
| | | first = true |
| | | technic.swap_node(pos, "technic:forcefield_emitter_on") |
| | | meta:set_string("infotext", S("%s Active"):format(machine_name)) |
| | | end |
| | | update_forcefield(pos, meta, true, first) |
| | | update_forcefield(pos, meta, true) |
| | | end |
| | | end |
| | | |