bunch of fixes => corrected technic recipes

master^2
Pitriss 2013-12-22 06:10:18 +01:00
parent 321ed16b22
commit 28d731d5de
5 changed files with 58 additions and 43 deletions

View File

@ -3,3 +3,4 @@ moreores
pipeworks
mesecons
moretrees
unified_inventory?

View File

@ -4,7 +4,7 @@ technic.alloy_recipes = {}
-- Register recipe in a table
technic.register_alloy_recipe = function(metal1, count1, metal2, count2, result, count3)
technic.alloy_recipes[metal1..metal2] = { src1_count = count1, src2_count = count2, dst_name = result, dst_count = count3 }
if unified_inventory then
if minetest.get_modpath("unified_inventory") ~= nil then
unified_inventory.register_craft(
{
type = "alloy",
@ -56,29 +56,29 @@ alloy_recipes = {}
registered_recipes_count = 1
function register_alloy_recipe (string1,count1, string2,count2, string3,count3)
alloy_recipes[registered_recipes_count]={}
alloy_recipes[registered_recipes_count].src1_name=string1
alloy_recipes[registered_recipes_count].src1_count=count1
alloy_recipes[registered_recipes_count].src2_name=string2
alloy_recipes[registered_recipes_count].src2_count=count2
alloy_recipes[registered_recipes_count].dst_name=string3
alloy_recipes[registered_recipes_count].dst_count=count3
registered_recipes_count=registered_recipes_count+1
alloy_recipes[registered_recipes_count]={}
alloy_recipes[registered_recipes_count].src1_name=string2
alloy_recipes[registered_recipes_count].src1_count=count2
alloy_recipes[registered_recipes_count].src2_name=string1
alloy_recipes[registered_recipes_count].src2_count=count1
alloy_recipes[registered_recipes_count].dst_name=string3
alloy_recipes[registered_recipes_count].dst_count=count3
registered_recipes_count=registered_recipes_count+1
if unified_inventory then
unified_inventory.register_craft({
type = "alloy",
output = string3.." "..count3,
items = {string1.." "..count1,string2.." "..count2},
width = 2,
})
alloy_recipes[registered_recipes_count]={}
alloy_recipes[registered_recipes_count].src1_name=string1
alloy_recipes[registered_recipes_count].src1_count=count1
alloy_recipes[registered_recipes_count].src2_name=string2
alloy_recipes[registered_recipes_count].src2_count=count2
alloy_recipes[registered_recipes_count].dst_name=string3
alloy_recipes[registered_recipes_count].dst_count=count3
registered_recipes_count=registered_recipes_count+1
alloy_recipes[registered_recipes_count]={}
alloy_recipes[registered_recipes_count].src1_name=string2
alloy_recipes[registered_recipes_count].src1_count=count2
alloy_recipes[registered_recipes_count].src2_name=string1
alloy_recipes[registered_recipes_count].src2_count=count1
alloy_recipes[registered_recipes_count].dst_name=string3
alloy_recipes[registered_recipes_count].dst_count=count3
registered_recipes_count=registered_recipes_count+1
if minetest.get_modpath("unified_inventory") ~= nil then
unified_inventory.register_craft({
type = "alloy",
output = string3.." "..count3,
items = {string2.." "..count2,string1.." "..count1},
width = 2,
})
end
end

View File

@ -105,10 +105,10 @@ minetest.register_abm(
meta:set_int("tube_time", 0)
return
end
-- Power off automatically if no longer connected to a switching station
technic.switching_station_timeout_count(pos, "LV")
-- State machine
if eu_input == 0 then
-- Unpowered - go idle
@ -117,7 +117,7 @@ minetest.register_abm(
next_state = 1
elseif eu_input == machine_state_demand[state] then
-- Powered - do the state specific actions
-- Execute always if powered logic
local inv = meta:get_inventory()
local empty = 1
@ -134,7 +134,7 @@ minetest.register_abm(
src_item2 = src2stack:to_table()
empty = 0
end
if src_item1 and src_item2 then
recipe = technic.get_alloy_recipe(src_item1,src_item2)
end
@ -142,14 +142,14 @@ minetest.register_abm(
result = { name=recipe.dst_name, count=recipe.dst_count}
end
if recipe then
print("recipe "..recipe.dst_name.." : result "..result.name.." : empty "..empty.." : src_item1 "..src_item1.name.." : src_item2 "..src_item2.name)
end
-- if recipe then
-- print("recipe "..recipe.dst_name.." : result "..result.name.." : empty "..empty.." : src_item1 "..src_item1.name.." : src_item2 "..src_item2.name)
-- end
if state == 1 then
hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Idle")
if empty == 0 and recipe and inv:room_for_item("dst", result) then
meta:set_string("infotext", machine_name.." Active")
meta:set_string("src_time", 0)
@ -272,10 +272,10 @@ minetest.register_abm({
-- Get what to cook if anything
local srcstack = inv:get_stack("src", 1)
if srcstack then src_item1=srcstack:to_table() end
local src2stack = inv:get_stack("src2", 1)
if src2stack then src_item2=src2stack:to_table() end
if src_item1 and src_item2 then
recipe = technic.get_alloy_recipe(src_item1,src_item2)
end
@ -297,13 +297,13 @@ minetest.register_abm({
inv:set_stack("src2", 1, src2stack)
-- Put result in "dst" list
inv:add_item("dst",dst_stack)
else
print("Furnace inventory full!") -- Silly code...
--[[ else
print("Furnace inventory full!")]] -- Silly code...
end
meta:set_string("src_time", 0)
end
end
if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
local percent = math.floor(meta:get_float("fuel_time") /
meta:get_float("fuel_totaltime") * 100)

View File

@ -20,7 +20,7 @@ minetest.after(0.01, function()
end
table.sort(unified_inventory.items_list)
unified_inventory.items_list_size = #unified_inventory.items_list
print("Unified Inventory. inventory size: "..#unified_inventory.items_list)
-- print("Unified Inventory. inventory size: "..#unified_inventory.items_list)
end)

View File

@ -217,11 +217,25 @@ unified_inventory.register_page("craftguide", {
.."ui_group.png;;"
..minetest.formspec_escape(group).."]"
else
formspec = formspec.."item_image_button["
..(1.0 + x)..","..(0.0 + y)..";1.1,1.1;"
..minetest.formspec_escape(item)..";"
.."item_button_"
..minetest.formspec_escape(item)..";]"
local useditemcount = 0
local useditemraw = nil
if string.match(item, '%s%d+$') ~= nil then
useditemcount = tonumber(tonumber(string.match(item, '%s(%d+)$')))
useditemraw = string.match(item, '(%g+)%s%d+$')
end
if useditemcount > 0 then
formspec = formspec.."item_image_button["
..(1.0 + x)..","..(0.0 + y)..";1.1,1.1;"
..minetest.formspec_escape(useditemraw)..";"
.."item_button_"
..minetest.formspec_escape(useditemraw)..";"..tostring(useditemcount).."]"
else
formspec = formspec.."item_image_button["
..(1.0 + x)..","..(0.0 + y)..";1.1,1.1;"
..minetest.formspec_escape(item)..";"
.."item_button_"
..minetest.formspec_escape(item)..";]"
end
end
end
i = i + 1