Fix control to work. Rename supplies.

This commit is contained in:
SFENCE 2021-09-07 18:00:55 +02:00
parent 5386a63767
commit 037419adca
3 changed files with 61 additions and 13 deletions

View File

@ -45,6 +45,7 @@ function appliance:have_liquid(pos, meta)
end
appliance.power_connect_sides = {"back"}; -- right, left, front, back, top, bottom
appliance.control_connect_sides = {"right", "left", "front", "back", "top", "bottom"}; -- right, left, front, back, top, bottom
appliance.power_data = {};
appliance.liquid_data = {};
@ -479,7 +480,7 @@ end
-- Inactive/Active
function appliance:cb_play_sound(pos, meta, old_state, new_state)
--print("Sound from "..old_state.." to "..new_state)
--print(self.node_name_inactive.." sound from "..old_state.." to "..new_state)
local sound_key = old_state.."_"..new_state;
local sound = self.sounds[sound_key] or self.sounds[new_state]
if sound then
@ -522,11 +523,12 @@ function appliance:activate(pos, meta)
timer:start(1)
self:power_need(pos, meta)
meta:set_string(self.meta_infotext, self.node_description.." - active")
self:call_activate(pos, meta)
self:cb_activate(pos, meta)
self:update_state(pos, meta, "active")
end
self:call_activate(pos, meta)
self:cb_activate(pos, meta)
self:update_state(pos, meta, "active")
end
function appliance:cb_deactivate(pos, meta)
end

View File

@ -6,16 +6,66 @@ function appliances.add_control(control_name, control_def)
minetest.log("error", "Another appliances mod extension with name \""..control_name.."\" is already registered.")
return ;
end
appliances.item_supplies[control_name] = control_def;
appliances.controls[control_name] = control_def;
appliances.all_extensions[control_name] = control_def;
end
-- punch
if true then
local control =
{
control_wait = function (self, control, pos, meta)
local state = meta:get_int("punch_control");
if (state~=0) then
return false;
end
return true;
end,
after_place_node = function (self, control, pos, meta)
minetest.get_meta(pos):set_int("punch_control", 0);
end,
on_punch = function (self, control, pos, node, puncher, pointed_thing)
local meta = minetest.get_meta(pos);
local state = meta:get_int("punch_control");
if (state~=0) then
meta:set_int("punch_control", 0);
else
meta:set_int("punch_control", 1);
self:activate(pos, meta);
end
end,
};
appliances.add_control("punch_control", control);
end
-- mesecons
if appliances.have_mesecons then
local control =
{
control_wait = function (self, control, pos, meta)
local state = meta:get_int("mesecons_control");
if (state~=0) then
return false;
end
return true;
end,
update_node_def = function (self, control, node_def)
node_def.effector = {
action_on = function (pos, node)
minetest.get_meta(pos):set_int("mesecons_control", 1);
self:activate(pos, meta);
end,
action_off = function (pos, node)
minetest.get_meta(pos):set_int("mesecons_control", 0);
end,
}
end,
after_place_node = function (self, control, pos, meta)
minetest.get_meta(pos):set_int("mesecons_control", 0);
end,
};
appliances.add_control("mesecons_control", control);
end
-- digilines?

View File

@ -18,7 +18,7 @@ if true then
return power_supply.run_speed;
end,
};
appliances.add_power_supply("time", power_supply)
appliances.add_power_supply("time_power", power_supply)
end
-- punch
@ -45,7 +45,7 @@ if true then
end,
};
appliances.add_power_supply("punch", power_supply)
appliances.add_power_supply("punch_power", power_supply)
end
-- mesecons
@ -69,15 +69,11 @@ if appliances.have_mesecons then
end,
}
end,
update_node_inactive_def = function (self, power_supply, node_def)
end,
update_node_active_def = function (self, power_supply, node_def)
end,
after_place_node = function (self, power_supply, pos, meta)
minetest.get_meta(pos):set_int("is_powered", 0);
end,
};
appliances.add_power_supply("mesecons", power_supply)
appliances.add_power_supply("mesecons_power", power_supply)
end
-- technic