Merge pull request #1 from RealBadAngel/indev

Indev
This commit is contained in:
kpoppel 2013-05-06 11:55:11 -07:00
commit 2239a4447b
35 changed files with 919 additions and 306 deletions

4
.gitignore vendored

@ -161,3 +161,7 @@ pip-log.txt
# Mac crap # Mac crap
.DS_Store .DS_Store
#gedit backup files
*~

@ -1 +0,0 @@

@ -1,29 +0,0 @@
crafts_table ={}
crafts_table_count=0
UI_recipes_hook=true
-- override minetest.register_craft
local minetest_register_craft = minetest.register_craft
minetest.register_craft = function (options)
register_craft(options)
if options.type=="alloy" or options.type=="grinding" then return end
minetest_register_craft(options)
end
-- register_craft
register_craft = function(options)
if options.output == nil then
return
end
local itemstack = ItemStack(options.output)
if itemstack:is_empty() then
return
end
if crafts_table[itemstack:get_name()]==nil then
crafts_table[itemstack:get_name()] = {}
end
table.insert(crafts_table[itemstack:get_name()],options)
crafts_table_count=crafts_table_count+1
end

1
framedglass/depends.txt Normal file

@ -0,0 +1 @@
default

77
framedglass/init.lua Normal file

@ -0,0 +1,77 @@
-- Minetest 0.4.5 mod: framedglass
minetest.register_craft({
output = 'framedglass:wooden_framed_glass 4',
recipe = {
{'default:glass', 'default:glass', 'default:stick'},
{'default:glass', 'default:glass', 'default:stick'},
{'default:stick', 'default:stick', ''},
}
})
minetest.register_craft({
output = 'framedglass:steel_framed_glass 4',
recipe = {
{'default:glass', 'default:glass', 'default:steel_ingot'},
{'default:glass', 'default:glass', 'default:steel_ingot'},
{'default:steel_ingot', 'default:steel_ingot', ''},
}
})
minetest.register_craft({
output = 'framedglass:wooden_framed_obsidian_glass 4',
recipe = {
{'default:obsidian_glass', 'default:obsidian_glass', 'default:stick'},
{'default:obsidian_glass', 'default:obsidian_glass', 'default:stick'},
{'default:stick', 'default:stick', ''},
}
})
minetest.register_craft({
output = 'framedglass:steel_framed_obsidian_glass 4',
recipe = {
{'default:obsidian_glass', 'default:obsidian_glass', 'default:steel_ingot'},
{'default:obsidian_glass', 'default:obsidian_glass', 'default:steel_ingot'},
{'default:steel_ingot', 'default:steel_ingot', ''},
}
})
minetest.register_node("framedglass:wooden_framed_glass", {
description = "Wooden-framed Glass",
drawtype = "glasslike_framed",
tiles = {"framedglass_wooden_frame.png","framedglass_glass_face_streaks.png"},
paramtype = "light",
sunlight_propagates = true,
groups = {cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
})
minetest.register_node("framedglass:steel_framed_glass", {
description = "Steel-framed Glass",
drawtype = "glasslike_framed",
tiles = {"framedglass_steel_frame.png","framedglass_glass_face_streaks.png"},
paramtype = "light",
sunlight_propagates = true,
groups = {cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
})
minetest.register_node("framedglass:wooden_framed_obsidian_glass", {
description = "Wooden-framed Obsidian Glass",
drawtype = "glasslike_framed",
tiles = {"framedglass_wooden_frame.png","framedglass_glass_face_clean.png"},
paramtype = "light",
sunlight_propagates = true,
groups = {cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
})
minetest.register_node("framedglass:steel_framed_obsidian_glass", {
description = "Steel-framed Obsidian Glass",
drawtype = "glasslike_framed",
tiles = {"framedglass_steel_frame.png","framedglass_glass_face_clean.png"},
paramtype = "light",
sunlight_propagates = true,
groups = {cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 926 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 951 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 740 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 387 B

1
item_drop/depends.txt Normal file

@ -0,0 +1 @@
technic

@ -1,76 +1,37 @@
dofile(minetest.get_modpath("item_drop").."/item_entity.lua") dofile(minetest.get_modpath("item_drop").."/item_entity.lua")
time_pick = 3 time_pick = 3
minetest.register_globalstep(function(dtime)
if technic.config:getBool("enable_item_pickup") then
minetest.register_globalstep(function(dtime)
for _,player in ipairs(minetest.get_connected_players()) do for _,player in ipairs(minetest.get_connected_players()) do
local pos = player:getpos() local pos = player:getpos()
pos.y = pos.y+0.5 pos.y = pos.y+0.5
local inv = player:get_inventory() local inv = player:get_inventory()
for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 1)) do for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 2)) do
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then if not object:is_player() and object:get_luaentity() then
if inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then local obj=object:get_luaentity()
if object:get_luaentity().timer > time_pick then if obj.name == "__builtin:item" then
inv:add_item("main", ItemStack(object:get_luaentity().itemstring)) if inv:room_for_item("main", ItemStack(obj.itemstring)) then
if object:get_luaentity().itemstring ~= "" then if obj.timer > time_pick then
minetest.sound_play("item_drop_pickup", { inv:add_item("main", ItemStack(obj.itemstring))
to_player = player:get_player_name(), if obj.itemstring ~= "" then
}) minetest.sound_play("item_drop_pickup",{pos = pos, gain = 1.0, max_hear_distance = 10})
end end
if object:get_luaentity() then
object:get_luaentity().itemstring = "" object:get_luaentity().itemstring = ""
object:remove() object:remove()
end end
end end
end end
end end
end
end
end
end)
end
for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 3)) do if technic.config:getBool("enable_item_drop") then
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then function minetest.handle_node_drops(pos, drops, digger)
--print(dump(object:getpos().y-player:getpos().y))
if object:getpos().y-player:getpos().y > 0 then
if object:get_luaentity().collect then
if inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
if object:get_luaentity().timer > time_pick then
local pos1 = pos
pos1.y = pos1.y+0.2
local pos2 = object:getpos()
local vec = {x=pos1.x-pos2.x, y=pos1.y-pos2.y, z=pos1.z-pos2.z}
vec.x = vec.x*3
vec.y = vec.y*3
vec.z = vec.z*3
object:setvelocity(vec)
minetest.after(1, function(args)
local lua = object:get_luaentity()
if object == nil or lua == nil or lua.itemstring == nil then
return
end
if inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
inv:add_item("main", ItemStack(object:get_luaentity().itemstring))
if object:get_luaentity().itemstring ~= "" then
minetest.sound_play("item_drop_pickup", {
to_player = player:get_player_name(),
})
end
object:get_luaentity().itemstring = ""
object:remove()
else
object:setvelocity({x=0,y=0,z=0})
end
end, {player, object})
end
end
else
minetest.after(0.5, function(entity)
entity.collect = true
end, object:get_luaentity())
end
end
end
end
end
end)
function minetest.handle_node_drops(pos, drops, digger)
for _,item in ipairs(drops) do for _,item in ipairs(drops) do
local count, name local count, name
if type(item) == "string" then if type(item) == "string" then
@ -103,7 +64,9 @@ function minetest.handle_node_drops(pos, drops, digger)
end end
end end
end end
end
end end
--[[ --[[
minetest.register_on_dieplayer(function(name, pos) minetest.register_on_dieplayer(function(name, pos)
local inv = name:get_inventory() local inv = name:get_inventory()

@ -62,15 +62,21 @@ minetest.register_entity(":__builtin:item", {
return minetest.serialize({ return minetest.serialize({
itemstring = self.itemstring, itemstring = self.itemstring,
always_collect = self.always_collect, always_collect = self.always_collect,
timer = self.timer,
}) })
end, end,
on_activate = function(self, staticdata) on_activate = function(self, staticdata, dtime_s)
if string.sub(staticdata, 1, string.len("return")) == "return" then if string.sub(staticdata, 1, string.len("return")) == "return" then
local data = minetest.deserialize(staticdata) local data = minetest.deserialize(staticdata)
if data and type(data) == "table" then if data and type(data) == "table" then
self.itemstring = data.itemstring self.itemstring = data.itemstring
self.always_collect = data.always_collect self.always_collect = data.always_collect
self.timer = data.timer
if not self.timer then
self.timer = 0
end
self.timer = self.timer+dtime_s
end end
else else
self.itemstring = staticdata self.itemstring = staticdata
@ -82,16 +88,77 @@ minetest.register_entity(":__builtin:item", {
end, end,
on_step = function(self, dtime) on_step = function(self, dtime)
local time = minetest.setting_get("remove_items")
if not time then
time = 300
end
if not self.timer then
self.timer = 0
end
self.timer = self.timer + dtime self.timer = self.timer + dtime
if (self.timer > 300) then if time ~= 0 and (self.timer > time) then
self.object:remove() self.object:remove()
end end
local p = self.object:getpos() local p = self.object:getpos()
local name = minetest.env:get_node(p).name
if name == "default:lava_flowing" or name == "default:lava_source" then
minetest.sound_play("builtin_item_lava", {pos=self.object:getpos(),gain = 1.0, max_hear_distance = 10})
self.object:remove()
return
end
if minetest.registered_nodes[name].liquidtype == "flowing" then
get_flowing_dir = function(self)
local pos = self.object:getpos()
local param2 = minetest.env:get_node(pos).param2
for i,d in ipairs({-1, 1, -1, 1}) do
if i<3 then
pos.x = pos.x+d
else
pos.z = pos.z+d
end
local name = minetest.env:get_node(pos).name
local par2 = minetest.env:get_node(pos).param2
if name == "default:water_flowing" and par2 < param2 then
return pos
end
if i<3 then
pos.x = pos.x-d
else
pos.z = pos.z-d
end
end
end
local vec = get_flowing_dir(self)
if vec then
local v = self.object:getvelocity()
if vec and vec.x-p.x > 0 then
self.object:setvelocity({x=0.5,y=v.y,z=0})
elseif vec and vec.x-p.x < 0 then
self.object:setvelocity({x=-0.5,y=v.y,z=0})
elseif vec and vec.z-p.z > 0 then
self.object:setvelocity({x=0,y=v.y,z=0.5})
elseif vec and vec.z-p.z < 0 then
self.object:setvelocity({x=0,y=v.y,z=-0.5})
end
self.object:setacceleration({x=0, y=-10, z=0})
self.physical_state = true
self.object:set_properties({
physical = true
})
return
end
end
p.y = p.y - 0.3 p.y = p.y - 0.3
local nn = minetest.env:get_node(p).name local nn = minetest.env:get_node(p).name
-- If node is not registered or node is walkably solid and resting on nodebox -- If node is not registered or node is walkably solid
local v = self.object:getvelocity() if not minetest.registered_nodes[nn] or minetest.registered_nodes[nn].walkable then
if not minetest.registered_nodes[nn] or minetest.registered_nodes[nn].walkable and v.y == 0 then
if self.physical_state then if self.physical_state then
self.object:setvelocity({x=0,y=0,z=0}) self.object:setvelocity({x=0,y=0,z=0})
self.object:setacceleration({x=0, y=0, z=0}) self.object:setacceleration({x=0, y=0, z=0})
@ -114,13 +181,12 @@ minetest.register_entity(":__builtin:item", {
on_punch = function(self, hitter) on_punch = function(self, hitter)
if self.itemstring ~= '' then if self.itemstring ~= '' then
local left = hitter:get_inventory():add_item("main", self.itemstring) hitter:get_inventory():add_item("main", self.itemstring)
if not left:is_empty() then
self.itemstring = left:to_string()
return
end
end end
self.object:remove() self.object:remove()
end, end,
}) })
print("ITEM ENTITY LOADED")
if minetest.setting_get("log_mods") then
minetest.log("action", "builtin_item loaded")
end

@ -0,0 +1,126 @@
-- Minetest: builtin/item_entity.lua
function minetest.spawn_item(pos, item)
-- Take item in any format
local stack = ItemStack(item)
local obj = minetest.env:add_entity(pos, "__builtin:item")
obj:get_luaentity():set_item(stack:to_string())
return obj
end
minetest.register_entity(":__builtin:item", {
initial_properties = {
hp_max = 1,
physical = true,
collisionbox = {-0.17,-0.17,-0.17, 0.17,0.17,0.17},
visual = "sprite",
visual_size = {x=0.5, y=0.5},
textures = {""},
spritediv = {x=1, y=1},
initial_sprite_basepos = {x=0, y=0},
is_visible = false,
},
itemstring = '',
physical_state = true,
timer = 0,
set_item = function(self, itemstring)
self.itemstring = itemstring
local stack = ItemStack(itemstring)
local itemtable = stack:to_table()
local itemname = nil
if itemtable then
itemname = stack:to_table().name
end
local item_texture = nil
local item_type = ""
if minetest.registered_items[itemname] then
item_texture = minetest.registered_items[itemname].inventory_image
item_type = minetest.registered_items[itemname].type
end
prop = {
is_visible = true,
visual = "sprite",
textures = {"unknown_item.png"}
}
if item_texture and item_texture ~= "" then
prop.visual = "sprite"
prop.textures = {item_texture}
prop.visual_size = {x=0.50, y=0.50}
else
prop.visual = "wielditem"
prop.textures = {itemname}
prop.visual_size = {x=0.20, y=0.20}
prop.automatic_rotate = math.pi * 0.25
end
self.object:set_properties(prop)
end,
get_staticdata = function(self)
--return self.itemstring
return minetest.serialize({
itemstring = self.itemstring,
always_collect = self.always_collect,
})
end,
on_activate = function(self, staticdata)
if string.sub(staticdata, 1, string.len("return")) == "return" then
local data = minetest.deserialize(staticdata)
if data and type(data) == "table" then
self.itemstring = data.itemstring
self.always_collect = data.always_collect
end
else
self.itemstring = staticdata
end
self.object:set_armor_groups({immortal=1})
self.object:setvelocity({x=0, y=2, z=0})
self.object:setacceleration({x=0, y=-10, z=0})
self:set_item(self.itemstring)
end,
on_step = function(self, dtime)
self.timer = self.timer + dtime
if (self.timer > 300) then
self.object:remove()
end
local p = self.object:getpos()
p.y = p.y - 0.3
local nn = minetest.env:get_node(p).name
-- If node is not registered or node is walkably solid and resting on nodebox
local v = self.object:getvelocity()
if not minetest.registered_nodes[nn] or minetest.registered_nodes[nn].walkable and v.y == 0 then
if self.physical_state then
self.object:setvelocity({x=0,y=0,z=0})
self.object:setacceleration({x=0, y=0, z=0})
self.physical_state = false
self.object:set_properties({
physical = false
})
end
else
if not self.physical_state then
self.object:setvelocity({x=0,y=0,z=0})
self.object:setacceleration({x=0, y=-10, z=0})
self.physical_state = true
self.object:set_properties({
physical = true
})
end
end
end,
on_punch = function(self, hitter)
if self.itemstring ~= '' then
local left = hitter:get_inventory():add_item("main", self.itemstring)
if not left:is_empty() then
self.itemstring = left:to_string()
return
end
end
self.object:remove()
end,
})
print("ITEM ENTITY LOADED")

@ -19,14 +19,12 @@ alloy_recipes[registered_recipes_count].src2_count=count1
alloy_recipes[registered_recipes_count].dst_name=string3 alloy_recipes[registered_recipes_count].dst_name=string3
alloy_recipes[registered_recipes_count].dst_count=count3 alloy_recipes[registered_recipes_count].dst_count=count3
registered_recipes_count=registered_recipes_count+1 registered_recipes_count=registered_recipes_count+1
if UI_recipes_hook then if unified_inventory then
minetest.register_craft({ unified_inventory.register_craft({
type = "alloy", type = "alloy",
output = string3.." "..count3, output = string3.." "..count3,
recipe = { items = {string1.." "..count1,string2.." "..count2},
{string1.." "..count1}, width = 2,
{string2.." "..count2},
}
}) })
end end
end end

@ -1,7 +1,42 @@
enable_technic_inventory=true technic.config = {}
enable_mining_drill=true
enable_mining_laser=true technic.config.loaded = {}
enable_flashlight=true
enable_rubber_tree_generation=true technic.config.default = {
enable_marble_generation=true enable_mining_drill = "true",
enable_granite_generation=true enable_mining_laser = "true",
enable_flashlight = "true",
enable_item_drop = "true",
enable_item_pickup = "true",
enable_rubber_tree_generation = "true",
enable_marble_generation = "true",
enable_granite_generation = "true"
}
function technic.config:load(filename)
file, error = io.open(filename, "r")
if error then return end
local line = file:read("*l")
while line do
local found, _, setting, value = line:find("^([^#%s=]+)%s?=%s?([^%s#]+)")
if found then
self.loaded[setting] = value
end
line = file:read("*l")
end
file:close()
end
technic.config:load(minetest.get_worldpath().."/technic.conf")
function technic.config:get(setting)
if self.loaded[setting] then
return self.loaded[setting]
else
return self.default[setting]
end
end
function technic.config:getBool(setting)
return string.lower(self:get(setting)) == "true"
end

@ -2,5 +2,3 @@ default
moreores moreores
pipeworks pipeworks
mesecons mesecons
technic_worldgen

@ -4,8 +4,8 @@ minetest.register_craft({
output = 'technic:geothermal', output = 'technic:geothermal',
recipe = { recipe = {
{'default:stone', 'default:stone', 'default:stone'}, {'default:stone', 'default:stone', 'default:stone'},
{'moreores:copper_ingot', 'technic:diamond', 'moreores:copper_ingot'}, {'default:copper_ingot', 'default:diamond', 'default:copper_ingot'},
{'default:stone', 'moreores:copper_ingot', 'default:stone'}, {'default:stone', 'default:copper_ingot', 'default:stone'},
} }
}) })

@ -7,11 +7,12 @@ grinder_recipes[registered_grinder_recipes_count]={}
grinder_recipes[registered_grinder_recipes_count].src_name=string1 grinder_recipes[registered_grinder_recipes_count].src_name=string1
grinder_recipes[registered_grinder_recipes_count].dst_name=string2 grinder_recipes[registered_grinder_recipes_count].dst_name=string2
registered_grinder_recipes_count=registered_grinder_recipes_count+1 registered_grinder_recipes_count=registered_grinder_recipes_count+1
if UI_recipes_hook then if unified_inventory then
minetest.register_craft({ unified_inventory.register_craft({
type = "grinding", type = "grinding",
output = string2, output = string2,
recipe = string1, items = {string1},
width = 0,
}) })
end end
end end
@ -22,11 +23,9 @@ register_grinder_recipe("default:gravel","default:dirt")
register_grinder_recipe("default:desert_stone","default:desert_sand") register_grinder_recipe("default:desert_stone","default:desert_sand")
register_grinder_recipe("default:iron_lump","technic:iron_dust 2") register_grinder_recipe("default:iron_lump","technic:iron_dust 2")
register_grinder_recipe("default:coal_lump","technic:coal_dust 2") register_grinder_recipe("default:coal_lump","technic:coal_dust 2")
register_grinder_recipe("moreores:copper_lump","technic:copper_dust 2")
register_grinder_recipe("default:copper_lump","technic:copper_dust 2") register_grinder_recipe("default:copper_lump","technic:copper_dust 2")
register_grinder_recipe("moreores:tin_lump","technic:tin_dust 2") register_grinder_recipe("moreores:tin_lump","technic:tin_dust 2")
register_grinder_recipe("moreores:silver_lump","technic:silver_dust 2") register_grinder_recipe("moreores:silver_lump","technic:silver_dust 2")
register_grinder_recipe("moreores:gold_lump","technic:gold_dust 2")
register_grinder_recipe("default:gold_lump","technic:gold_dust 2") register_grinder_recipe("default:gold_lump","technic:gold_dust 2")
register_grinder_recipe("moreores:mithril_lump","technic:mithril_dust 2") register_grinder_recipe("moreores:mithril_lump","technic:mithril_dust 2")
register_grinder_recipe("technic:chromium_lump","technic:chromium_dust 2") register_grinder_recipe("technic:chromium_lump","technic:chromium_dust 2")

@ -2,6 +2,8 @@
-- namespace: technic -- namespace: technic
-- (c) 2012-2013 by RealBadAngel <mk@realbadangel.pl> -- (c) 2012-2013 by RealBadAngel <mk@realbadangel.pl>
technic = {}
modpath=minetest.get_modpath("technic") modpath=minetest.get_modpath("technic")
--Read technic config file --Read technic config file
@ -34,10 +36,13 @@ dofile(modpath.."/electric_furnace_mv.lua")
dofile(modpath.."/alloy_furnace_mv.lua") dofile(modpath.."/alloy_furnace_mv.lua")
dofile(modpath.."/forcefield.lua") dofile(modpath.."/forcefield.lua")
--HV machines
dofile(modpath.."/wires_hv.lua")
--Tools --Tools
if enable_mining_drill==true then dofile(modpath.."/mining_drill.lua") end if technic.config:getBool("enable_mining_drill") then dofile(modpath.."/mining_drill.lua") end
if enable_mining_laser==true then dofile(modpath.."/mining_laser_mk1.lua") end if technic.config:getBool("enable_mining_laser") then dofile(modpath.."/mining_laser_mk1.lua") end
if enable_flashlight==true then dofile(modpath.."/flashlight.lua") end if technic.config:getBool("enable_flashlight") then dofile(modpath.."/flashlight.lua") end
dofile(modpath.."/cans.lua") dofile(modpath.."/cans.lua")
dofile(modpath.."/chainsaw.lua") dofile(modpath.."/chainsaw.lua")
dofile(modpath.."/tree_tap.lua") dofile(modpath.."/tree_tap.lua")

@ -217,11 +217,11 @@ minetest.register_tool("technic:mining_drill", {
stack_max = 1, stack_max = 1,
on_use = function(itemstack, user, pointed_thing) on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type=="node" then if pointed_thing.type=="node" then
item=itemstack:to_table() local item=itemstack:to_table()
local meta=get_item_meta(item["metadata"]) local meta=get_item_meta(item["metadata"])
if meta==nil then return end --tool not charghed if meta==nil then return end --tool not charghed
if meta["charge"]==nil then return end if meta["charge"]==nil then return end
charge=meta["charge"] local charge=meta["charge"]
if charge-mining_drill_power_usage>0 then if charge-mining_drill_power_usage>0 then
charge_to_take=drill_dig_it(minetest.get_pointed_thing_position(pointed_thing, above),user,1,1) charge_to_take=drill_dig_it(minetest.get_pointed_thing_position(pointed_thing, above),user,1,1)
charge =charge-mining_drill_power_usage; charge =charge-mining_drill_power_usage;
@ -287,7 +287,7 @@ function mining_drill_mk2_handler (itemstack,user,pointed_thing)
local keys=user:get_player_control() local keys=user:get_player_control()
local player_name=user:get_player_name() local player_name=user:get_player_name()
local item=itemstack:to_table() local item=itemstack:to_table()
meta=get_item_meta(item["metadata"]) local meta=get_item_meta(item["metadata"])
if meta==nil or keys["sneak"]==true then return mining_drill_mk2_setmode(user,itemstack) end if meta==nil or keys["sneak"]==true then return mining_drill_mk2_setmode(user,itemstack) end
if meta["mode"]==nil then return mining_drill_mk2_setmode(user,itemstack) end if meta["mode"]==nil then return mining_drill_mk2_setmode(user,itemstack) end
if pointed_thing.type~="node" then return end if pointed_thing.type~="node" then return end
@ -309,14 +309,13 @@ function mining_drill_mk3_handler (itemstack,user,pointed_thing)
local keys=user:get_player_control() local keys=user:get_player_control()
local player_name=user:get_player_name() local player_name=user:get_player_name()
local item=itemstack:to_table() local item=itemstack:to_table()
meta=get_item_meta(item["metadata"]) local meta=get_item_meta(item["metadata"])
if meta==nil or keys["sneak"]==true then return mining_drill_mk3_setmode(user,itemstack) end if meta==nil or keys["sneak"]==true then return mining_drill_mk3_setmode(user,itemstack) end
if meta["mode"]==nil then return mining_drill_mk3_setmode(user,itemstack) end if meta["mode"]==nil then return mining_drill_mk3_setmode(user,itemstack) end
if pointed_thing.type~="node" then return end if pointed_thing.type~="node" then return end
if meta["charge"]==nil then return end if meta["charge"]==nil then return end
charge=meta["charge"] local charge=meta["charge"]
if charge-mining_drill_power_usage>0 then if charge-mining_drill_power_usage>0 then
print(dump(meta))
local charge_to_take=drill_dig_it(minetest.get_pointed_thing_position(pointed_thing, above),user,3,meta["mode"]) local charge_to_take=drill_dig_it(minetest.get_pointed_thing_position(pointed_thing, above),user,3,meta["mode"])
charge=charge-charge_to_take; charge=charge-charge_to_take;
if charge<0 then charge=0 end if charge<0 then charge=0 end

@ -88,14 +88,12 @@ minetest.register_abm({
end end
}) })
minetest.register_on_generated(function(minp, maxp, blockseed) if technic.config:getBool("enable_rubber_tree_generation") then
minetest.register_on_generated(function(minp, maxp, blockseed)
if math.random(1, 100) > 5 then if math.random(1, 100) > 5 then
return return
end end
local tmp = {x=(maxp.x-minp.x)/2+minp.x, y=(maxp.y-minp.y)/2+minp.y, z=(maxp.z-minp.z)/2+minp.z} local rubber_tree={
local pos = minetest.env:find_node_near(tmp, maxp.x-minp.x, {"default:dirt_with_grass"})
if pos ~= nil then
rubber_tree={
axiom="FFFFA", axiom="FFFFA",
rules_a="[&FFBFA]////[&BFFFA]////[&FBFFA]", rules_a="[&FFBFA]////[&BFFFA]////[&FBFFA]",
rules_b="[&FFA]////[&FFA]////[&FFA]", rules_b="[&FFA]////[&FFA]////[&FFA]",
@ -108,9 +106,13 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
fruit_tree=false, fruit_tree=false,
fruit="" fruit=""
} }
minetest.env:spawn_tree({x=pos.x, y=pos.y+1, z=pos.z},rubber_tree) local tmp = {x=(maxp.x-minp.x)/2+minp.x, y=(maxp.y-minp.y)/2+minp.y, z=(maxp.z-minp.z)/2+minp.z}
local pos = minetest.env:find_node_near(tmp, maxp.x-minp.x, {"default:dirt_with_grass"})
if pos ~= nil then
minetest.env:spawn_tree({x=pos.x, y=pos.y+1, z=pos.z}, rubber_tree)
end end
end) end)
end
-- ========= FUEL ========= -- ========= FUEL =========

@ -52,7 +52,7 @@ minetest.register_tool("technic:sonic_screwdriver", {
minetest.register_craft({ minetest.register_craft({
output = "technic:sonic_screwdriver", output = "technic:sonic_screwdriver",
recipe = { recipe = {
{"technic:diamond"}, {"default:diamond"},
{"technic:battery"}, {"technic:battery"},
{"technic:stainless_steel_ingot"} {"technic:stainless_steel_ingot"}
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 601 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 531 B

398
technic/wires_hv.lua Normal file

@ -0,0 +1,398 @@
--HV cable node boxes
minetest.register_craft({
output = 'technic:hv_cable 3',
recipe ={
{'technic:rubber','technic:rubber','technic:rubber'},
{'technic:mv_cable','technic:mv_cable','technic:mv_cable'},
{'technic:rubber','technic:rubber','technic:rubber'},
}
})
minetest.register_craftitem("technic:hv_cable", {
description = "Gigh Voltage Copper Cable",
stack_max = 99,
})
minetest.register_node("technic:hv_cable", {
description = "High Voltage Copper Cable",
tiles = {"technic_hv_cable.png"},
inventory_image = "technic_hv_cable_wield.png",
wield_image = "technic_hv_cable_wield.png",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
drop = "technic:hv_cable",
hv_cablelike=1,
rules_x1=0,
rules_x2=0,
rules_y1=0,
rules_y2=0,
rules_z1=0,
rules_z2=0,
paramtype = "light",
drawtype = "nodebox",
selection_box = {
type = "fixed",
fixed = {
{ -0.1 , -0.1 , -0.1 , 0.1 , 0.1 , 0.1 },
}},
node_box = {
type = "fixed",
fixed = {
{ -0.125 , -0.125 , -0.125 , 0.125 , 0.125 , 0.125 },
}},
on_construct = function(pos)
meta=minetest.env:get_meta(pos)
meta:set_float("hv_cablelike",1)
meta:set_float("x1",0)
meta:set_float("x2",0)
meta:set_float("y1",0)
meta:set_float("y2",0)
meta:set_float("z1",0)
meta:set_float("z2",0)
HV_check_connections (pos)
end,
after_dig_node = function (pos, oldnode, oldmetadata, digger)
HV_check_connections_on_destroy (pos)
end,
})
str_y1= { -0.125 , -0.125 , -0.125 , 0.125 , 0.5, 0.125 } --0 y+
str_x1= { -0.125 , -0.125 , -0.125 , 0.5, 0.125 , 0.125 } --0 x+
str_z1= { -0.125 , -0.125 , 0.125 , 0.125 , 0.125 , 0.5 } --0 z+
str_z2= { -0.125 , -0.125, -0.5 , 0.125 , 0.125 , 0.125 } --0 z-
str_y2= { -0.125 , -0.5, -0.125 , 0.125 , 0.125 , 0.125 } --0 y-
str_x2= { -0.5 , -0.125, -0.125 , 0.125 , 0.125 , 0.125 } --0 x-
local x1,x2,y1,y2,z1,z2
local count=0
for x1 = 0, 1, 1 do --x-
for x2 = 0, 1, 1 do --x+
for y1 = 0, 1, 1 do --y-
for y2 = 0, 1, 1 do --y-
for z1 = 0, 1, 1 do --z-
for z2 = 0, 1, 1 do --z+
temp_x1={} temp_x2={} temp_y1={} temp_y2={} temp_z1={} temp_z2={}
if x1==1 then temp_x1=str_x1 end
if x2==1 then temp_x2=str_x2 end
if y1==1 then temp_y1=str_y1 end
if y2==1 then temp_y2=str_y2 end
if z1==1 then temp_z1=str_z1 end
if z2==1 then temp_z2=str_z2 end
minetest.register_node("technic:hv_cable"..count, {
description = "Gigh Voltage Copper Cable",
tiles = {"technic_hv_cable.png"},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
sounds = default.node_sound_wood_defaults(),
drop = "technic:hv_cable",
rules_x1=0,
rules_x2=0,
rules_y1=0,
rules_y2=0,
rules_z1=0,
rules_z2=0,
cablelike=1,
paramtype = "light",
drawtype = "nodebox",
selection_box = {
type = "fixed",
fixed = {
temp_x1,temp_x2,temp_y1,temp_y2,temp_z1,temp_z2,
}},
node_box = {
type = "fixed",
fixed = {
temp_x1,temp_x2,temp_y1,temp_y2,temp_z1,temp_z2,
}},
after_dig_node = function (pos, oldnode, oldmetadata, digger)
HV_check_connections_on_destroy (pos)
end,
})
count=count+1 end end end end end end
HV_check_connections = function(pos)
local pos1={}
pos1.x=pos.x
pos1.y=pos.y
pos1.z=pos.z
pos1.x=pos1.x+1
if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
x2=1
x1=minetest.env:get_meta(pos1):get_float("x1")
y1=minetest.env:get_meta(pos1):get_float("y1")
y2=minetest.env:get_meta(pos1):get_float("y2")
z1=minetest.env:get_meta(pos1):get_float("z1")
z2=minetest.env:get_meta(pos1):get_float("z2")
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
hacky_swap_node(pos1,"technic:hv_cable"..rule)
meta=minetest.env:get_meta(pos1)
meta:set_float("x2",x2)
meta=minetest.env:get_meta(pos)
x1=1
x2=minetest.env:get_meta(pos):get_float("x2")
y1=minetest.env:get_meta(pos):get_float("y1")
y2=minetest.env:get_meta(pos):get_float("y2")
z1=minetest.env:get_meta(pos):get_float("z1")
z2=minetest.env:get_meta(pos):get_float("z2")
meta:set_float("x1",x1)
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
hacky_swap_node(pos,"technic:hv_cable"..rule)
end
pos1.x=pos1.x-2
if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
x1=1
x2=minetest.env:get_meta(pos1):get_float("x2")
y1=minetest.env:get_meta(pos1):get_float("y1")
y2=minetest.env:get_meta(pos1):get_float("y2")
z1=minetest.env:get_meta(pos1):get_float("z1")
z2=minetest.env:get_meta(pos1):get_float("z2")
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
hacky_swap_node(pos1,"technic:hv_cable"..rule)
meta=minetest.env:get_meta(pos1)
meta:set_float("x1",x1)
meta=minetest.env:get_meta(pos)
x2=1
x1=minetest.env:get_meta(pos):get_float("x1")
y1=minetest.env:get_meta(pos):get_float("y1")
y2=minetest.env:get_meta(pos):get_float("y2")
z1=minetest.env:get_meta(pos):get_float("z1")
z2=minetest.env:get_meta(pos):get_float("z2")
meta:set_float("x2",x2)
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
hacky_swap_node(pos,"technic:hv_cable"..rule)
end
pos1.x=pos1.x+1
pos1.y=pos1.y+1
if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
y2=1
x1=minetest.env:get_meta(pos1):get_float("x1")
x2=minetest.env:get_meta(pos1):get_float("x2")
y1=minetest.env:get_meta(pos1):get_float("y1")
z1=minetest.env:get_meta(pos1):get_float("z1")
z2=minetest.env:get_meta(pos1):get_float("z2")
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
hacky_swap_node(pos1,"technic:hv_cable"..rule)
meta=minetest.env:get_meta(pos1)
meta:set_float("y2",y2)
meta=minetest.env:get_meta(pos)
y1=1
x1=minetest.env:get_meta(pos):get_float("x1")
x2=minetest.env:get_meta(pos):get_float("x2")
y2=minetest.env:get_meta(pos):get_float("y2")
z1=minetest.env:get_meta(pos):get_float("z1")
z2=minetest.env:get_meta(pos):get_float("z2")
meta:set_float("y1",y1)
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
hacky_swap_node(pos,"technic:hv_cable"..rule)
end
if minetest.env:get_meta(pos1):get_float("technic_hv_power_machine")==1 then
y1=1
x1=minetest.env:get_meta(pos):get_float("x1")
x2=minetest.env:get_meta(pos):get_float("x2")
y2=minetest.env:get_meta(pos):get_float("y2")
z1=minetest.env:get_meta(pos):get_float("z1")
z2=minetest.env:get_meta(pos):get_float("z2")
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
hacky_swap_node(pos,"technic:hv_cable"..rule)
meta=minetest.env:get_meta(pos)
meta:set_float("y1",y1)
end
pos1.y=pos1.y-2
if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
y1=1
x1=minetest.env:get_meta(pos1):get_float("x1")
x2=minetest.env:get_meta(pos1):get_float("x2")
y2=minetest.env:get_meta(pos1):get_float("y2")
z1=minetest.env:get_meta(pos1):get_float("z1")
z2=minetest.env:get_meta(pos1):get_float("z2")
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
hacky_swap_node(pos1,"technic:hv_cable"..rule)
meta=minetest.env:get_meta(pos1)
meta:set_float("y1",y1)
meta=minetest.env:get_meta(pos)
y2=1
x1=minetest.env:get_meta(pos):get_float("x1")
x2=minetest.env:get_meta(pos):get_float("x2")
y1=minetest.env:get_meta(pos):get_float("y1")
z1=minetest.env:get_meta(pos):get_float("z1")
z2=minetest.env:get_meta(pos):get_float("z2")
meta:set_float("y2",y2)
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
hacky_swap_node(pos,"technic:hv_cable"..rule)
end
pos1.y=pos1.y+1
pos1.z=pos1.z+1
if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
z2=1
x1=minetest.env:get_meta(pos1):get_float("x1")
x2=minetest.env:get_meta(pos1):get_float("x2")
y1=minetest.env:get_meta(pos1):get_float("y1")
y2=minetest.env:get_meta(pos1):get_float("y2")
z1=minetest.env:get_meta(pos1):get_float("z1")
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
hacky_swap_node(pos1,"technic:hv_cable"..rule)
meta=minetest.env:get_meta(pos1)
meta:set_float("z2",z2)
meta=minetest.env:get_meta(pos)
z1=1
x1=minetest.env:get_meta(pos):get_float("x1")
x2=minetest.env:get_meta(pos):get_float("x2")
y1=minetest.env:get_meta(pos):get_float("y1")
y2=minetest.env:get_meta(pos):get_float("y2")
z2=minetest.env:get_meta(pos):get_float("z2")
meta:set_float("z1",z1)
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
hacky_swap_node(pos,"technic:hv_cable"..rule)
end
pos1.z=pos1.z-2
if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
z1=1
x1=minetest.env:get_meta(pos1):get_float("x1")
x2=minetest.env:get_meta(pos1):get_float("x2")
y1=minetest.env:get_meta(pos1):get_float("y1")
y2=minetest.env:get_meta(pos1):get_float("y2")
z2=minetest.env:get_meta(pos1):get_float("z2")
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
hacky_swap_node(pos1,"technic:hv_cable"..rule)
meta=minetest.env:get_meta(pos1)
meta:set_float("z1",z1)
meta=minetest.env:get_meta(pos)
z2=1
x1=minetest.env:get_meta(pos):get_float("x1")
x2=minetest.env:get_meta(pos):get_float("x2")
y1=minetest.env:get_meta(pos):get_float("y1")
y2=minetest.env:get_meta(pos):get_float("y2")
z1=minetest.env:get_meta(pos):get_float("z1")
meta:set_float("z2",z2)
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
hacky_swap_node(pos,"technic:hv_cable"..rule)
end
pos1.z=pos1.z+1
end
HV_check_connections_on_destroy = function(pos)
local pos1={}
pos1.x=pos.x
pos1.y=pos.y
pos1.z=pos.z
pos1.x=pos1.x+1
if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
x2=0
x1=minetest.env:get_meta(pos1):get_float("x1")
y1=minetest.env:get_meta(pos1):get_float("y1")
y2=minetest.env:get_meta(pos1):get_float("y2")
z1=minetest.env:get_meta(pos1):get_float("z1")
z2=minetest.env:get_meta(pos1):get_float("z2")
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
if rule==0 then hacky_swap_node(pos1,"technic:hv_cable") end
if rule>0 then hacky_swap_node(pos1,"technic:hv_cable"..rule) end
meta=minetest.env:get_meta(pos1)
meta:set_float("x2",x2)
end
pos1.x=pos1.x-2
if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
x1=0
x2=minetest.env:get_meta(pos1):get_float("x2")
y1=minetest.env:get_meta(pos1):get_float("y1")
y2=minetest.env:get_meta(pos1):get_float("y2")
z1=minetest.env:get_meta(pos1):get_float("z1")
z2=minetest.env:get_meta(pos1):get_float("z2")
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
if rule==0 then hacky_swap_node(pos1,"technic:hv_cable") end
if rule>0 then hacky_swap_node(pos1,"technic:hv_cable"..rule) end
meta=minetest.env:get_meta(pos1)
meta:set_float("x1",x1)
end
pos1.x=pos1.x+1
pos1.y=pos1.y+1
if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
y2=0
x1=minetest.env:get_meta(pos1):get_float("x1")
x2=minetest.env:get_meta(pos1):get_float("x2")
y1=minetest.env:get_meta(pos1):get_float("y1")
z1=minetest.env:get_meta(pos1):get_float("z1")
z2=minetest.env:get_meta(pos1):get_float("z2")
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
if rule==0 then hacky_swap_node(pos1,"technic:hv_cable") end
if rule>0 then hacky_swap_node(pos1,"technic:hv_cable"..rule) end
meta=minetest.env:get_meta(pos1)
meta:set_float("y2",y2)
end
pos1.y=pos1.y-2
if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
y1=0
x1=minetest.env:get_meta(pos1):get_float("x1")
x2=minetest.env:get_meta(pos1):get_float("x2")
y2=minetest.env:get_meta(pos1):get_float("y2")
z1=minetest.env:get_meta(pos1):get_float("z1")
z2=minetest.env:get_meta(pos1):get_float("z2")
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
if rule==0 then hacky_swap_node(pos1,"technic:hv_cable") end
if rule>0 then hacky_swap_node(pos1,"technic:hv_cable"..rule) end
meta=minetest.env:get_meta(pos1)
meta:set_float("y1",y1)
end
pos1.y=pos1.y+1
pos1.z=pos1.z+1
if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
z2=0
x1=minetest.env:get_meta(pos1):get_float("x1")
x2=minetest.env:get_meta(pos1):get_float("x2")
y1=minetest.env:get_meta(pos1):get_float("y1")
y2=minetest.env:get_meta(pos1):get_float("y2")
z1=minetest.env:get_meta(pos1):get_float("z1")
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
if rule==0 then hacky_swap_node(pos1,"technic:hv_cable") end
if rule>0 then hacky_swap_node(pos1,"technic:hv_cable"..rule) end
meta=minetest.env:get_meta(pos1)
meta:set_float("z2",z2)
end
pos1.z=pos1.z-2
if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
z1=0
x1=minetest.env:get_meta(pos1):get_float("x1")
x2=minetest.env:get_meta(pos1):get_float("x2")
y1=minetest.env:get_meta(pos1):get_float("y1")
y2=minetest.env:get_meta(pos1):get_float("y2")
z2=minetest.env:get_meta(pos1):get_float("z2")
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
if rule==0 then hacky_swap_node(pos1,"technic:hv_cable") end
if rule>0 then hacky_swap_node(pos1,"technic:hv_cable"..rule) end
meta=minetest.env:get_meta(pos1)
meta:set_float("z1",z1)
end
pos1.y=pos1.y+1
end

@ -1 +1,2 @@
default default
technic

@ -56,3 +56,5 @@ minetest.register_craft({
{'technic:marble','technic:marble'} {'technic:marble','technic:marble'}
} }
}) })
minetest.register_alias("technic:diamond_block", "default:diamondblock")

@ -28,6 +28,7 @@ minetest.register_ore({
height_min = -31000, height_min = -31000,
height_max = 2, height_max = 2,
}) })
if technic.config:getBool("enable_marble_generation") then
minetest.register_ore({ minetest.register_ore({
ore_type = "sheet", ore_type = "sheet",
ore = "technic:marble", ore = "technic:marble",
@ -40,6 +41,8 @@ minetest.register_ore({
noise_threshhold = 0.4, noise_threshhold = 0.4,
noise_params = {offset=0, scale=15, spread={x=150, y=150, z=150}, seed=23, octaves=3, persist=0.70} noise_params = {offset=0, scale=15, spread={x=150, y=150, z=150}, seed=23, octaves=3, persist=0.70}
}) })
end
if technic.config:getBool("enable_granite_generation") then
minetest.register_ore({ minetest.register_ore({
ore_type = "sheet", ore_type = "sheet",
ore = "technic:granite", ore = "technic:granite",
@ -52,4 +55,5 @@ minetest.register_ore({
noise_threshhold = 0.4, noise_threshhold = 0.4,
noise_params = {offset=0, scale=15, spread={x=130, y=130, z=130}, seed=24, octaves=3, persist=0.70} noise_params = {offset=0, scale=15, spread={x=130, y=130, z=130}, seed=24, octaves=3, persist=0.70}
}) })
end

@ -10,6 +10,8 @@ unified_inventory.filtered_items_list = {}
unified_inventory.activefilter = {} unified_inventory.activefilter = {}
unified_inventory.alternate = {} unified_inventory.alternate = {}
unified_inventory.current_item = {} unified_inventory.current_item = {}
unified_inventory.crafts_table ={}
unified_inventory.crafts_table_count=0
-- default inventory page -- default inventory page
unified_inventory.default = "craft" unified_inventory.default = "craft"
@ -26,8 +28,18 @@ minetest.after(0.01, function()
if (not def.groups.not_in_creative_inventory or def.groups.not_in_creative_inventory == 0) if (not def.groups.not_in_creative_inventory or def.groups.not_in_creative_inventory == 0)
and def.description and def.description ~= "" then and def.description and def.description ~= "" then
table.insert(unified_inventory.items_list, name) table.insert(unified_inventory.items_list, name)
local recipes=minetest.get_all_craft_recipes(name)
if unified_inventory.crafts_table[name]==nil then
unified_inventory.crafts_table[name] = {}
end
if recipes then
for i=1,#recipes,1 do
table.insert(unified_inventory.crafts_table[name],recipes[i])
end end
end end
end
end
--print(dump(unified_inventory.crafts_table))
table.sort(unified_inventory.items_list) table.sort(unified_inventory.items_list)
unified_inventory.items_list_size = #unified_inventory.items_list unified_inventory.items_list_size = #unified_inventory.items_list
print ("Unified Inventory. inventory size: "..unified_inventory.items_list_size) print ("Unified Inventory. inventory size: "..unified_inventory.items_list_size)
@ -37,7 +49,6 @@ end)
minetest.register_on_joinplayer(function(player) minetest.register_on_joinplayer(function(player)
local player_name = player:get_player_name() local player_name = player:get_player_name()
unified_inventory.players[player_name]={} unified_inventory.players[player_name]={}
unified_inventory.players[player_name]["sound_volume"]=minetest.setting_get("sound_volume")*10
unified_inventory.current_index[player_name] = 1 unified_inventory.current_index[player_name] = 1
unified_inventory.filtered_items_list[player_name] = {} unified_inventory.filtered_items_list[player_name] = {}
unified_inventory.filtered_items_list[player_name] = unified_inventory.items_list unified_inventory.filtered_items_list[player_name] = unified_inventory.items_list
@ -206,9 +217,9 @@ unified_inventory.get_formspec = function(player,page)
formspec = formspec.."label[2,0;"..item_name.."]" formspec = formspec.."label[2,0;"..item_name.."]"
local alternates = 0 local alternates = 0
local alternate = unified_inventory.alternate[player_name] local alternate = unified_inventory.alternate[player_name]
local crafts = crafts_table[item_name] local crafts = unified_inventory.crafts_table[item_name]
if crafts ~= nil then if crafts ~= nil and #crafts>0 then
alternates = #crafts alternates = #crafts
local craft = crafts[alternate] local craft = crafts[alternate]
local method = "Crafting" local method = "Crafting"
@ -440,7 +451,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
if item_name then if item_name then
local alternates = 0 local alternates = 0
local alternate=unified_inventory.alternate[player_name] local alternate=unified_inventory.alternate[player_name]
local crafts = crafts_table[item_name] local crafts = unified_inventory.crafts_table[item_name]
if crafts ~= nil then if crafts ~= nil then
alternates = #crafts alternates = #crafts
end end
@ -537,135 +548,64 @@ end
-- update_recipe -- update_recipe
unified_inventory.update_recipe = function(player, stack_name, alternate) unified_inventory.update_recipe = function(player, stack_name, alternate)
--print("Lookup:"..stack_name)
local inv = minetest.get_inventory({type="detached", name=player:get_player_name().."craftrecipe"}) local inv = minetest.get_inventory({type="detached", name=player:get_player_name().."craftrecipe"})
for i=0,inv:get_size("build"),1 do for i=0,inv:get_size("build"),1 do
inv:set_stack("build", i, nil) inv:set_stack("build", i, nil)
end end
inv:set_stack("cook", 1, nil) inv:set_stack("output", 1, nil)
inv:set_stack("fuel", 1, nil)
inv:set_stack("output", 1, stack_name)
local def
alternate = tonumber(alternate) or 1 alternate = tonumber(alternate) or 1
local crafts = crafts_table[stack_name] local crafts = unified_inventory.crafts_table[stack_name]
if crafts == nil then print(dump(crafts))
--minetest.chat_send_player(player:get_player_name(), "no recipe available for "..stack_name) local next=next
return if next(crafts) == nil then return end -- no craft recipes
end
if alternate < 1 or alternate > #crafts then if alternate < 1 or alternate > #crafts then
alternate = 1 alternate = 1
end end
local craft = crafts[alternate] local craft = crafts[alternate]
--print (dump(craft)) inv:set_stack("output", 1, craft.output)
--minetest.chat_send_player(player:get_player_name(), "recipe for "..stack_name..": "..dump(craft)) local items=craft.items
local itemstack = ItemStack(craft.output)
inv:set_stack("output", 1, itemstack)
-- cook, fuel, grinding recipes -- cook, fuel, grinding recipes
if craft.type == "cooking" or craft.type == "fuel" or craft.type == "grinding" then if craft.type == "cooking" or craft.type == "fuel" or craft.type == "grinding" then
def=unified_inventory.find_item_def(craft.recipe) def=unified_inventory.find_item_def(craft["items"][1])
if def then if def then
inv:set_stack("build", 1, def) inv:set_stack("build", 1, def)
end end
return return
end end
if craft.width==0 then
-- build (shaped or shapeless) local build_table={1,2,3}
if craft.recipe[1] then for i=1,3,1 do
def=unified_inventory.find_item_def(craft.recipe[1]) if craft.items[i] then
if def then def=unified_inventory.find_item_def(craft.items[i])
inv:set_stack("build", 1, def) if def then inv:set_stack("build", build_table[i], def) end
else
def=unified_inventory.find_item_def(craft.recipe[1][1])
if def then
inv:set_stack("build", 1, def)
end
def=unified_inventory.find_item_def(craft.recipe[1][2])
if def then
inv:set_stack("build", 2, def)
end
def=unified_inventory.find_item_def(craft.recipe[1][3])
if def then
inv:set_stack("build", 3, def)
end end
end end
end end
if craft.recipe[2] then if craft.width==1 then
def=unified_inventory.find_item_def(craft.recipe[2]) local build_table={1,4,7}
if def then for i=1,3,1 do
inv:set_stack("build", 2, def) if craft.items[i] then
else def=unified_inventory.find_item_def(craft.items[i])
def=unified_inventory.find_item_def(craft.recipe[2][1]) if def then inv:set_stack("build", build_table[i], def) end
if def then
inv:set_stack("build", 4, def)
end
def=unified_inventory.find_item_def(craft.recipe[2][2])
if def then
inv:set_stack("build", 5, def)
end
def=unified_inventory.find_item_def(craft.recipe[2][3])
if def then
inv:set_stack("build", 6, def)
end end
end end
end end
if craft.width==2 then
if craft.recipe[3] then local build_table={1,2,4,5,7,8}
def=unified_inventory.find_item_def(craft.recipe[3]) for i=1,6,1 do
if def then if craft.items[i] then
inv:set_stack("build", 3, def) def=unified_inventory.find_item_def(craft.items[i])
else if def then inv:set_stack("build", build_table[i], def) end
def=unified_inventory.find_item_def(craft.recipe[3][1])
if def then
inv:set_stack("build", 7, def)
end
def=unified_inventory.find_item_def(craft.recipe[3][2])
if def then
inv:set_stack("build", 8, def)
end
def=unified_inventory.find_item_def(craft.recipe[3][3])
if def then
inv:set_stack("build", 9, def)
end end
end end
end end
if craft.recipe[4] then if craft.width==3 then
def=unified_inventory.find_item_def(craft.recipe[4]) for i=1,9,1 do
if def then if craft.items[i] then
inv:set_stack("build", 4, def) def=unified_inventory.find_item_def(craft.items[i])
if def then inv:set_stack("build", i, def) end
end end
end end
if craft.recipe[5] then
def=unified_inventory.find_item_def(craft.recipe[5])
if def then
inv:set_stack("build", 5, def)
end
end
if craft.recipe[6] then
def=unified_inventory.find_item_def(craft.recipe[6])
if def then
inv:set_stack("build", 6, def)
end
end
if craft.recipe[7] then
def=unified_inventory.find_item_def(craft.recipe[7])
if def then
inv:set_stack("build", 7, def)
end
end
if craft.recipe[8] then
def=unified_inventory.find_item_def(craft.recipe[8])
if def then
inv:set_stack("build", 8, def)
end
end
if craft.recipe[9] then
def=unified_inventory.find_item_def(craft.recipe[9])
if def then
inv:set_stack("build", 9, def)
end
end end
end end
@ -674,14 +614,39 @@ if type(def1)=="string" then
if string.find(def1, "group:") then if string.find(def1, "group:") then
def1=string.gsub(def1, "group:", "") def1=string.gsub(def1, "group:", "")
def1=string.gsub(def1, '\"', "") def1=string.gsub(def1, '\"', "")
for name,def in pairs(minetest.registered_items) do local items=unified_inventory.items_in_group(def1)
if def.groups[def1] == 1 and def.groups.not_in_creative_inventory ~= 1 then return items[1]
return def
end
end
else else
return def1 return def1
end end
end end
return nil return nil
end end
unified_inventory.items_in_group = function(group)
local items = {}
for name, item in pairs(minetest.registered_items) do
for _, g in ipairs(group:split(',')) do
if item.groups[g] then
table.insert(items,name)
end
end
end
return items
end
-- register_craft
unified_inventory.register_craft = function(options)
if options.output == nil then
return
end
local itemstack = ItemStack(options.output)
if itemstack:is_empty() then
return
end
if unified_inventory.crafts_table[itemstack:get_name()]==nil then
unified_inventory.crafts_table[itemstack:get_name()] = {}
end
table.insert(unified_inventory.crafts_table[itemstack:get_name()],options)
--crafts_table_count=crafts_table_count+1
end

@ -1,2 +1 @@
aaa_recipeshook
creative creative