mover fuel cost fix: when moving with filter from chest or inventory

This commit is contained in:
rnd1 2015-11-01 18:45:09 +01:00
parent c6074585c9
commit c7f8279e04
3 changed files with 16 additions and 9 deletions

View File

@ -210,11 +210,15 @@ minetest.register_node("basic_machines:mover", {
end
local node1 = minetest.get_node(pos1);local node2 = minetest.get_node(pos2);
local prefer = meta:get_string("prefer");
--minetest.chat_send_all(" pos1 " .. pos1.x .. " " .. pos1.y .. " " .. pos1.z .. " pos2 " .. pos2.x .. " " .. pos2.y .. " " .. pos2.z );
-- FUEL COST: calculate
local dist = math.abs(pos2.x-pos1.x)+math.abs(pos2.y-pos1.y)+math.abs(pos2.z-pos1.z);
local fuel_cost = basic_machines.hardness[node1.name] or 1;
if node1.name == "default:chest_locked" or mode == "inventory" then fuel_cost = basic_machines.hardness[prefer] or 1 end;
fuel_cost=fuel_cost*dist;
if mode == "object"
then fuel_cost=fuel_cost*0.1;
@ -274,9 +278,6 @@ minetest.register_node("basic_machines:mover", {
if fuel < fuel_cost then meta:set_string("infotext", "Mover block. Fuel ".. fuel ..", needed fuel " .. fuel_cost .. ". Put fuel chest near mover or place outlet below it."); return end
local prefer = meta:get_string("prefer");
if mode == "object" then -- teleport objects and return

View File

@ -11,8 +11,6 @@ local recycler_process = function(pos)
-- FUEL CHECK
local fuel = meta:get_float("fuel");
if fuel<=0 then -- we need new fuel, check chest below
local fuellist = inv:get_list("fuel")
if not fuellist then return end -- safety check, prevents crash when using previous version recylcler without inventory
@ -36,8 +34,8 @@ local recycler_process = function(pos)
fuel=fuel + fueladd.time*0.1
meta:set_float("fuel",fuel);
meta:set_string("infotext", "added fuel furnace burn time " .. fueladd.time .. ", fuel status " .. fuel);
if fuel<=0 then return end
end
if fuel<=0 then return end
end
@ -132,7 +130,7 @@ minetest.register_node("basic_machines:recycler", {
sounds = default.node_sound_wood_defaults(),
after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos);
meta:set_string("infotext", "Recycler: put one item in it (src) and obtain 75% of raw materials (dst). To operate it must sit on top of chest with fuel.")
meta:set_string("infotext", "Recycler: put one item in it (src) and obtain 75% of raw materials (dst). To operate it insert fuel, then insert item to recycle or use keypad to activate it.")
meta:set_string("owner", placer:get_player_name());
meta:set_int("recipe",1);
meta:set_float("fuel",0);

View File

@ -1,2 +1,10 @@
display source 2 block too ( maybe different mark T for target)
to do: use timer to run the keypad (then turn the timer off when done)
transform distributor into logic element:
several inputs,
several outputs
operations: not, or, and or maybe even lua syntax??
like
(1 or 2) and 3 where 1,2,3 are inputs
not 1