diff --git a/concrete/init.lua b/concrete/init.lua index bf25c32..1f1e0f5 100644 --- a/concrete/init.lua +++ b/concrete/init.lua @@ -1,4 +1,4 @@ ---Minetest 0.4.7 mod: concrete +--Minetest 0.4.7 mod: concrete --(c) 2013 by RealBadAngel minetest.register_craft({ @@ -126,7 +126,7 @@ minetest.register_node(":technic:concrete_post_platform", { paramtype = "light", light_source = 0, sunlight_propagates = true, - drawtype = "nodebox", + drawtype = "nodebox", selection_box = { type = "fixed", fixed = {platform_box} @@ -137,14 +137,14 @@ minetest.register_node(":technic:concrete_post_platform", { }, on_place=function (itemstack, placer, pointed_thing) local node=minetest.env:get_node(pointed_thing.under) - if minetest.get_item_group(node.name, "concrete_post")==0 then - return minetest.item_place_node(itemstack, placer, pointed_thing) + if minetest.get_item_group(node.name, "concrete_post")==0 then + return minetest.item_place_node(itemstack, placer, pointed_thing) end local meta=minetest.env:get_meta(pointed_thing.under) y1=meta:get_float("y1") platform=meta:get_float("platform") - if y1==1 or platform==1 then - return minetest.item_place_node(itemstack, placer, pointed_thing) + if y1==1 or platform==1 then + return minetest.item_place_node(itemstack, placer, pointed_thing) end y2=meta:get_float("y2") x1=meta:get_float("x1") @@ -169,7 +169,7 @@ minetest.register_node(":technic:concrete_post", { paramtype = "light", light_source = 0, sunlight_propagates = true, - drawtype = "nodebox", + drawtype = "nodebox", selection_box = { type = "fixed", fixed = { -0.15 , -0.5 , -0.15 , 0.15 , 0.5 , 0.15 }}, @@ -202,13 +202,13 @@ for x1 = 0, 1, 1 do --x- for x2 = 0, 1, 1 do --x+ for z1 = 0, 1, 1 do --z- for z2 = 0, 1, 1 do --z+ - + temp_x1={} temp_x2={} temp_z1={} temp_z2={} - if x1==1 then temp_x1=post_str_x1 end - if x2==1 then temp_x2=post_str_x2 end - if z1==1 then temp_z1=post_str_z1 end - if z2==1 then temp_z2=post_str_z2 end + if x1==1 then temp_x1=post_str_x1 end + if x2==1 then temp_x2=post_str_x2 end + if z1==1 then temp_z1=post_str_z1 end + if z2==1 then temp_z2=post_str_z2 end minetest.register_node(":technic:concrete_post"..count, { @@ -220,7 +220,7 @@ minetest.register_node(":technic:concrete_post"..count, { paramtype = "light", light_source = 0, sunlight_propagates = true, - drawtype = "nodebox", + drawtype = "nodebox", selection_box = { type = "fixed", fixed = { @@ -248,7 +248,7 @@ minetest.register_node(":technic:concrete_post"..count+16, { paramtype = "light", light_source = 0, sunlight_propagates = true, - drawtype = "nodebox", + drawtype = "nodebox", selection_box = { type = "fixed", fixed = { @@ -277,7 +277,7 @@ minetest.register_node(":technic:concrete_post32", { paramtype = "light", light_source = 0, sunlight_propagates = true, - drawtype = "nodebox", + drawtype = "nodebox", selection_box = { type = "fixed", fixed = {-0.5,-0.3,-0.1,0.5,0.3,0.1}, @@ -301,7 +301,7 @@ minetest.register_node(":technic:concrete_post33", { paramtype = "light", light_source = 0, sunlight_propagates = true, - drawtype = "nodebox", + drawtype = "nodebox", selection_box = { type = "fixed", fixed = { @@ -327,7 +327,7 @@ minetest.register_node(":technic:concrete_post34", { paramtype = "light", light_source = 0, sunlight_propagates = true, - drawtype = "nodebox", + drawtype = "nodebox", selection_box = { type = "fixed", fixed = { @@ -352,7 +352,7 @@ minetest.register_node(":technic:concrete_post35", { paramtype = "light", light_source = 0, sunlight_propagates = true, - drawtype = "nodebox", + drawtype = "nodebox", selection_box = { type = "fixed", fixed = { @@ -375,7 +375,7 @@ dig_post_with_platform = function (pos,oldnode,oldmetadata) y2=tonumber(oldmetadata.fields["y2"]) z1=tonumber(oldmetadata.fields["z1"]) z2=tonumber(oldmetadata.fields["z2"]) - print(dump(x1)) + --print(dump(x1)) oldmetadata.fields["platform"]="0" local rule=make_post_rule_number(x1,x2,y1,y2,z1,z2,0) --print(dump(rule)) @@ -383,7 +383,7 @@ dig_post_with_platform = function (pos,oldnode,oldmetadata) minetest.env:set_node(pos,oldnode) meta = minetest.env:get_meta(pos) meta:from_table(oldmetadata) -end +end check_post_connections = function(pos,mode) local pos1={} @@ -396,7 +396,7 @@ check_post_connections = function(pos,mode) tempy2=0 tempz1=0 tempz2=0 - + pos1.x=pos1.x+1 if minetest.env:get_meta(pos1):get_int("postlike")==1 then x2=mode @@ -430,7 +430,7 @@ check_post_connections = function(pos,mode) end pos1.x=pos1.x+1 - + pos1.y=pos1.y+1 if minetest.env:get_meta(pos1):get_int("postlike")==1 then y2=mode @@ -480,7 +480,7 @@ check_post_connections = function(pos,mode) tempz1=mode end pos1.z=pos1.z-2 - + if minetest.env:get_meta(pos1):get_int("postlike")==1 then z1=mode x1=minetest.env:get_meta(pos1):get_int("x1") @@ -496,8 +496,8 @@ check_post_connections = function(pos,mode) tempz2=mode end pos1.z=pos1.z+1 - - if mode==1 then + + if mode==1 then meta=minetest.env:get_meta(pos) meta:set_int("x1",tempx1) meta:set_int("x2",tempx2) @@ -508,13 +508,13 @@ check_post_connections = function(pos,mode) rule=make_post_rule_number(tempx1,tempx2,tempy1,tempy2,tempz1,tempz2,0) hacky_swap_posts(pos,"technic:concrete_post"..rule) end -end +end function make_post_rule_number (x1,x2,y1,y2,z1,z2,platform) local tempy=y1+y2 local tempx=x1+x2 local tempz=z1+z2 - if platform==0 then + if platform==0 then if tempy==0 and tempx==0 and tempz==0 then return 0 end if x1==1 and x2==1 and tempz==0 and tempy==0 then return 32 end if z1==1 and z2==1 and tempx==0 and tempy==0 then return 33 end diff --git a/technic/depends.txt b/technic/depends.txt index 7d2e8c3..f80e130 100644 --- a/technic/depends.txt +++ b/technic/depends.txt @@ -3,3 +3,4 @@ moreores pipeworks mesecons moretrees +unified_inventory? \ No newline at end of file diff --git a/technic/machines/alloy_furnaces_commons.lua b/technic/machines/alloy_furnaces_commons.lua index 41ab690..4c76176 100644 --- a/technic/machines/alloy_furnaces_commons.lua +++ b/technic/machines/alloy_furnaces_commons.lua @@ -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 diff --git a/technic/machines/lv/alloy_furnace.lua b/technic/machines/lv/alloy_furnace.lua index fcdb9c0..2319708 100644 --- a/technic/machines/lv/alloy_furnace.lua +++ b/technic/machines/lv/alloy_furnace.lua @@ -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) diff --git a/unified_inventory/api.lua b/unified_inventory/api.lua index 86160b4..efebfe1 100644 --- a/unified_inventory/api.lua +++ b/unified_inventory/api.lua @@ -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) diff --git a/unified_inventory/register.lua b/unified_inventory/register.lua index 2786642..656b23e 100644 --- a/unified_inventory/register.lua +++ b/unified_inventory/register.lua @@ -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