update several mods:
worldedit unified inventory item tweaks technic moreores maptools moreblocks digilines plasticboxmaster
|
@ -42,10 +42,12 @@ function digiline:update_autoconnect(pos, secondcall)
|
|||
digiline:update_autoconnect(zmympos, true)
|
||||
end
|
||||
|
||||
local digilinespec = minetest.registered_nodes[minetest.get_node(pos).name].digiline
|
||||
if not digilinespec then return nil end
|
||||
if not digilinespec.wire then return nil end
|
||||
if not digilinespec.wire.use_autoconnect then return nil end
|
||||
local def = minetest.registered_nodes[minetest.get_node(pos).name]
|
||||
local digilinespec = def and def.digiline
|
||||
if not (digilinespec and digilinespec.wire and
|
||||
digilinespec.wire.use_autoconnect) then
|
||||
return nil
|
||||
end
|
||||
|
||||
local zmg = digiline:rules_link_anydir(pos, zmpos)
|
||||
local zmymg = digiline:rules_link_anydir(pos, zmympos)
|
||||
|
|
|
@ -189,7 +189,7 @@ if minetest.setting_get("enable_item_pickup") == "true" then
|
|||
local inv = player:get_inventory()
|
||||
|
||||
for _, object in ipairs(minetest.env:get_objects_inside_radius(playerPosition, 3)) do
|
||||
if isGood(object) and object:get_luaentity().age > 3 and
|
||||
if isGood(object) and (object:get_luaentity().dropped_by ~= player:get_player_name() or object:get_luaentity().age > 3) and
|
||||
inv and
|
||||
inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring))
|
||||
then
|
||||
|
@ -304,6 +304,7 @@ function minetest.item_drop(itemstack, dropper, pos)
|
|||
v.y = v.y*2 + 1
|
||||
v.z = v.z*2
|
||||
obj:setvelocity(v)
|
||||
obj:get_luaentity().dropped_by = dropper:get_player_name()
|
||||
end
|
||||
return r
|
||||
else
|
||||
|
|
|
@ -1,182 +0,0 @@
|
|||
-- If item_entity_ttl is not set, enity will have default life time
|
||||
-- Setting it to -1 disables the feature
|
||||
|
||||
local time_to_live = tonumber(minetest.setting_get("item_entity_ttl"))
|
||||
if not time_to_live then
|
||||
time_to_live = 900
|
||||
end
|
||||
|
||||
minetest.register_entity(":__builtin:item", {
|
||||
initial_properties = {
|
||||
hp_max = 1,
|
||||
physical = true,
|
||||
collide_with_objects = false,
|
||||
collisionbox = {-0.24, -0.24, -0.24, 0.24, 0.24, 0.24},
|
||||
visual = "wielditem",
|
||||
visual_size = {x = 0.3, y = 0.3},
|
||||
textures = {""},
|
||||
spritediv = {x = 1, y = 1},
|
||||
initial_sprite_basepos = {x = 0, y = 0},
|
||||
is_visible = false,
|
||||
},
|
||||
|
||||
itemstring = '',
|
||||
physical_state = true,
|
||||
age = 0,
|
||||
|
||||
set_item = function(self, itemstring)
|
||||
self.itemstring = itemstring
|
||||
local stack = ItemStack(itemstring)
|
||||
local count = stack:get_count()
|
||||
local max_count = stack:get_stack_max()
|
||||
if count > max_count then
|
||||
count = max_count
|
||||
self.itemstring = stack:get_name().." "..max_count
|
||||
end
|
||||
local s = 0.15 + 0.15 * (count/max_count)
|
||||
local c = 0.8 * s
|
||||
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 = "wielditem",
|
||||
textures = {itemname},
|
||||
visual_size = {x=s, y=s},
|
||||
collisionbox = {-c, -c, -c, c, c, c},
|
||||
automatic_rotate = math.pi * 0.2,
|
||||
}
|
||||
self.object:set_properties(prop)
|
||||
self.age = 0
|
||||
end,
|
||||
|
||||
get_staticdata = function(self)
|
||||
return minetest.serialize({
|
||||
itemstring = self.itemstring,
|
||||
always_collect = self.always_collect,
|
||||
age = self.age
|
||||
})
|
||||
end,
|
||||
|
||||
on_activate = function(self, staticdata, dtime_s)
|
||||
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
|
||||
if data.age then
|
||||
self.age = data.age + dtime_s
|
||||
else
|
||||
self.age = dtime_s
|
||||
end
|
||||
print(dump(self.age))
|
||||
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.age = self.age + dtime
|
||||
--print(dump(self.age))
|
||||
if time_to_live > 0 and self.age > time_to_live then
|
||||
self.itemstring = ''
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
local p = self.object:getpos()
|
||||
p.y = p.y - 0.3
|
||||
local nn = minetest.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
|
||||
local own_stack = ItemStack(self.object:get_luaentity().itemstring)
|
||||
for _,object in ipairs(minetest.get_objects_inside_radius(p, 0.8)) do
|
||||
local obj = object:get_luaentity()
|
||||
if obj and obj.name == "__builtin:item" and obj.physical_state == false then
|
||||
local stack = ItemStack(obj.itemstring)
|
||||
if own_stack:get_name() == stack:get_name() and stack:get_free_space() > 0 then
|
||||
local overflow = false
|
||||
local count = stack:get_count() + own_stack:get_count()
|
||||
local max_count = stack:get_stack_max()
|
||||
if count>max_count then
|
||||
overflow = true
|
||||
count = count - max_count
|
||||
else
|
||||
self.itemstring = ''
|
||||
end
|
||||
local pos=object:getpos()
|
||||
pos.y = pos.y + (count - stack:get_count()) / max_count * 0.15
|
||||
object:moveto(pos, false)
|
||||
local s, c
|
||||
local max_count = stack:get_stack_max()
|
||||
local name = stack:get_name()
|
||||
if not overflow then
|
||||
obj.itemstring = name.." "..count
|
||||
s = 0.15 + 0.15 * (count/max_count)
|
||||
c = 0.8 * s
|
||||
object:set_properties({
|
||||
visual_size = {x=s, y=s},
|
||||
collisionbox = {-c,-c,-c, c,c,c}
|
||||
})
|
||||
self.object:remove()
|
||||
return
|
||||
else
|
||||
s = 0.3
|
||||
c = 0.24
|
||||
object:set_properties({
|
||||
visual_size = {x=s, y=s},
|
||||
collisionbox = {-c,-c,-c, c,c,c}
|
||||
})
|
||||
obj.itemstring = name.." "..max_count
|
||||
s = 0.15 + 0.15 * (count/max_count)
|
||||
c = 0.8 * s
|
||||
self.object:set_properties({
|
||||
visual_size = {x=s, y=s},
|
||||
collisionbox = {-c,-c,-c, c,c,c}
|
||||
})
|
||||
self.itemstring = name.." "..count
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
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.itemstring = ''
|
||||
self.object:remove()
|
||||
end,
|
||||
})
|
|
@ -1,15 +1,22 @@
|
|||
Map Tools
|
||||
==========================================================
|
||||
Calinou's Minetest Mods
|
||||
=====================
|
||||
|
||||
Map Tools for Minetest (http://minetest.net), a free and open source infinite
|
||||
world block sandbox game.
|
||||
Calinou's Mods for Minetest [http://minetest.net], a free and opensource Minecraft-like game.
|
||||
|
||||
**Moved to Gitorious:** https://gitorious.com/calinou/maptools/
|
||||
This Git repository is mostly made for servers; it allows easy updating.
|
||||
|
||||
----------------------
|
||||
To install, just clone this repository somewhere, then copy the "calinou_mods" folder in the "mods/minetest" folder of Minetest's installation folder.
|
||||
|
||||
To install, just clone this repository into your "mods" directory.
|
||||
|
||||
Map Tools code is under CC0, textures are under CC BY-SA 3.0 unported.
|
||||
|
||||
Forum topic: http://minetest.net/forum/viewtopic.php?id=1882
|
||||
Misc stuff
|
||||
=====================
|
||||
|
||||
All these mods' source codes, except More Ores are under the zlib/libpng license. More Ores is under the GNU GPLv3; the mods' textures are under the CC BY-SA 3.0 Unported.
|
||||
|
||||
Mods' forum threads:
|
||||
More Blocks: http://minetest.net/forum/viewtopic.php?id=509
|
||||
More Ores: http://minetest.net/forum/viewtopic.php?id=549
|
||||
Map Tools: http://minetest.net/forum/viewtopic.php?id=1882
|
||||
Doors+: http://minetest.net/forum/viewtopic.php?id=2059
|
||||
Stairs+: http://minetest.net/forum/viewtopic.php?id=2092
|
||||
|
|
|
@ -598,6 +598,7 @@ minetest.register_node("maptools:superapple", {
|
|||
minetest.register_craftitem("maptools:copper_coin", {
|
||||
description = S("Copper Coin"),
|
||||
inventory_image = "maptools_copper_coin.png",
|
||||
wield_scale = {x = 0.5, y = 0.5, z = 0.25},
|
||||
stack_max = 10000,
|
||||
groups = {not_in_creative_inventory = maptools_creative},
|
||||
})
|
||||
|
@ -605,6 +606,7 @@ minetest.register_craftitem("maptools:copper_coin", {
|
|||
minetest.register_craftitem("maptools:silver_coin", {
|
||||
description = S("Silver Coin"),
|
||||
inventory_image = "maptools_silver_coin.png",
|
||||
wield_scale = {x = 0.5, y = 0.5, z = 0.25},
|
||||
stack_max = 10000,
|
||||
groups = {not_in_creative_inventory = maptools_creative},
|
||||
})
|
||||
|
@ -612,6 +614,7 @@ minetest.register_craftitem("maptools:silver_coin", {
|
|||
minetest.register_craftitem("maptools:gold_coin", {
|
||||
description = S("Gold Coin"),
|
||||
inventory_image = "maptools_gold_coin.png",
|
||||
wield_scale = {x = 0.5, y = 0.5, z = 0.25},
|
||||
stack_max = 10000,
|
||||
groups = {not_in_creative_inventory = maptools_creative},
|
||||
})
|
||||
|
|
Before Width: | Height: | Size: 217 B After Width: | Height: | Size: 214 B |
Before Width: | Height: | Size: 217 B After Width: | Height: | Size: 215 B |
Before Width: | Height: | Size: 217 B After Width: | Height: | Size: 215 B |
|
@ -108,8 +108,6 @@ local nodes = {
|
|||
},
|
||||
["split_stone_tile_alt"] = {
|
||||
description = S("Split Stone Tile"),
|
||||
tiles = {"moreblocks_split_stone_tile_alt_top.png",
|
||||
"moreblocks_split_stone_tile_alt.png"},
|
||||
groups = {cracky = 3},
|
||||
sounds = sound_stone,
|
||||
},
|
||||
|
|
|
@ -82,29 +82,26 @@ function stairsplus:register_micro(modname, subname, recipeitem, fields)
|
|||
|
||||
minetest.register_alias(modname..":micro_"..subname.."_bottom", modname..":micro_"..subname)
|
||||
|
||||
-- Some saw-less recipe.
|
||||
-- Some saw-less recipes:
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:micro_" .. subname .. " 6",
|
||||
recipe = {
|
||||
{"moreblocks:stair_" .. subname},
|
||||
},
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:micro_" .. subname .. " 6",
|
||||
recipe = {{"moreblocks:stair_" .. subname}},
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:micro_" .. subname .. " 4",
|
||||
recipe = {
|
||||
{"moreblocks:slab_" .. subname},
|
||||
},
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:micro_" .. subname .. " 4",
|
||||
recipe = {{"moreblocks:slab_" .. subname}},
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:micro_" .. subname .. " 2",
|
||||
recipe = {
|
||||
{"moreblocks:panel_" .. subname},
|
||||
},
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:micro_" .. subname .. " 2",
|
||||
recipe = {{"moreblocks:panel_" .. subname}},
|
||||
})
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = recipeitem,
|
||||
recipe = {"moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname},
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = recipeitem,
|
||||
recipe = {"moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname},
|
||||
})
|
||||
end
|
||||
|
|
|
@ -18,7 +18,6 @@ function register_panel(modname, subname, recipeitem, groups, images, descriptio
|
|||
})
|
||||
end
|
||||
|
||||
|
||||
function stairsplus:register_panel(modname, subname, recipeitem, fields)
|
||||
local defs = {
|
||||
[""] = {
|
||||
|
@ -82,30 +81,33 @@ function stairsplus:register_panel(modname, subname, recipeitem, fields)
|
|||
end
|
||||
minetest.register_alias(modname..":panel_"..subname.."_bottom", modname..":panel_"..subname)
|
||||
|
||||
-- Some saw-less recipe.
|
||||
-- Some saw-less recipes:
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:panel_" .. subname .. " 12",
|
||||
recipe = {
|
||||
{recipeitem, ""},
|
||||
{recipeitem, recipeitem},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:panel_" .. subname .. " 12",
|
||||
recipe = {
|
||||
{recipeitem, ""},
|
||||
{recipeitem, recipeitem},
|
||||
},
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:panel_" .. subname .. " 12",
|
||||
recipe = {
|
||||
{"", recipeitem},
|
||||
{recipeitem, recipeitem},
|
||||
},
|
||||
})
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "moreblocks:panel_" .. subname,
|
||||
recipe = {"moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname},
|
||||
})
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = recipeitem,
|
||||
recipe = {"moreblocks:panel_" .. subname, "moreblocks:panel_" .. subname, "moreblocks:panel_" .. subname, "moreblocks:panel_" .. subname},
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:panel_" .. subname .. " 12",
|
||||
recipe = {
|
||||
{"", recipeitem},
|
||||
{recipeitem, recipeitem},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "moreblocks:panel_" .. subname,
|
||||
recipe = {"moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = recipeitem,
|
||||
recipe = {"moreblocks:panel_" .. subname, "moreblocks:panel_" .. subname, "moreblocks:panel_" .. subname, "moreblocks:panel_" .. subname},
|
||||
})
|
||||
end
|
||||
|
|
|
@ -80,22 +80,34 @@ function stairsplus:register_slab(modname, subname, recipeitem, fields)
|
|||
end
|
||||
minetest.register_alias("stairs:slab_"..subname, modname..":slab_"..subname)
|
||||
|
||||
-- Some saw-less recipe.
|
||||
-- Some saw-less recipes:
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:slab_" .. subname .. " 6",
|
||||
recipe = {
|
||||
{recipeitem, recipeitem, recipeitem},
|
||||
},
|
||||
recipe = {{recipeitem, recipeitem, recipeitem}},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "moreblocks:slab_" .. subname,
|
||||
recipe = {"moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "moreblocks:slab_" .. subname,
|
||||
recipe = {"moreblocks:panel_" .. subname, "moreblocks:panel_" .. subname},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = recipeitem,
|
||||
recipe = {"moreblocks:slab_" .. subname, "moreblocks:slab_" .. subname},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "moreblocks:slab_" .. subname .. " 3",
|
||||
recipe = {"moreblocks:stair_" .. subname, "moreblocks:stair_" .. subname},
|
||||
})
|
||||
end
|
||||
|
|
|
@ -121,72 +121,89 @@ function stairsplus:register_stair(modname, subname, recipeitem, fields)
|
|||
end
|
||||
minetest.register_alias(":stairs:stair_"..subname, modname..":stair_"..subname)
|
||||
|
||||
-- Some saw-less recipes.
|
||||
-- Some saw-less recipes:
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:stair_" .. subname .. " 8",
|
||||
recipe = {
|
||||
{recipeitem, "", ""},
|
||||
{recipeitem, recipeitem, ""},
|
||||
{recipeitem, recipeitem, recipeitem},
|
||||
},
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:stair_" .. subname .. " 8",
|
||||
recipe = {
|
||||
{recipeitem, "", ""},
|
||||
{recipeitem, recipeitem, ""},
|
||||
{recipeitem, recipeitem, recipeitem},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:stair_" .. subname .. " 8",
|
||||
recipe = {
|
||||
{"", "", recipeitem},
|
||||
{"", recipeitem, recipeitem},
|
||||
{recipeitem, recipeitem, recipeitem},
|
||||
},
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:stair_" .. subname,
|
||||
recipe = {
|
||||
{"moreblocks:panel_" .. subname},
|
||||
{"moreblocks:slab_" .. subname},
|
||||
},
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:stair_" .. subname .. "_outer",
|
||||
recipe = {
|
||||
{"moreblocks:micro_" .. subname},
|
||||
{"moreblocks:slab_" .. subname},
|
||||
},
|
||||
})
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "moreblocks:stair_" .. subname .. "_half",
|
||||
recipe = {"moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname},
|
||||
})
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "moreblocks:stair_" .. subname .. "_right_half",
|
||||
recipe = {"moreblocks:stair_" .. subname .. "_half"},
|
||||
})
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "moreblocks:stair_" .. subname .. "_half",
|
||||
recipe = {"moreblocks:stair_" .. subname .. "_right_half"},
|
||||
})
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "moreblocks:stair_" .. subname,
|
||||
recipe = {"moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname},
|
||||
})
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "moreblocks:stair_" .. subname .. "_inner",
|
||||
recipe = {"moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname},
|
||||
})
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "moreblocks:stair_" .. subname .. "_outer",
|
||||
recipe = {"moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname},
|
||||
})
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "moreblocks:stair_" .. subname,
|
||||
recipe = {"moreblocks:panel_" .. subname, "moreblocks:panel_" .. subname, "moreblocks:panel_" .. subname},
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "moreblocks:stair_" .. subname .. " 8",
|
||||
recipe = {
|
||||
{"", "", recipeitem},
|
||||
{"", recipeitem, recipeitem},
|
||||
{recipeitem, recipeitem, recipeitem},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "moreblocks:stair_" .. subname,
|
||||
recipe = {"moreblocks:panel_" .. subname, "moreblocks:slab_" .. subname},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "moreblocks:stair_" .. subname,
|
||||
recipe = {"moreblocks:panel_" .. subname, "moreblocks:panel_" .. subname, "moreblocks:panel_" .. subname},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "moreblocks:stair_" .. subname .. "_outer",
|
||||
recipe = {"moreblocks:micro_" .. subname, "moreblocks:slab_" .. subname},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "moreblocks:stair_" .. subname .. "_half",
|
||||
recipe = {"moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "moreblocks:stair_" .. subname .. "_half",
|
||||
recipe = {"moreblocks:panel_" .. subname, "moreblocks:micro_" .. subname},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "moreblocks:stair_" .. subname .. "_right_half",
|
||||
recipe = {"moreblocks:stair_" .. subname .. "_half"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "moreblocks:stair_" .. subname .. "_half",
|
||||
recipe = {"moreblocks:stair_" .. subname .. "_right_half"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "moreblocks:stair_" .. subname,
|
||||
recipe = {"moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "moreblocks:stair_" .. subname .. "_inner",
|
||||
recipe = {"moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "moreblocks:stair_" .. subname .. "_outer",
|
||||
recipe = {"moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname, "moreblocks:micro_" .. subname},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "moreblocks:stair_" .. subname,
|
||||
recipe = {"moreblocks:panel_" .. subname, "moreblocks:panel_" .. subname, "moreblocks:panel_" .. subname},
|
||||
})
|
||||
end
|
||||
|
|
Before Width: | Height: | Size: 681 B After Width: | Height: | Size: 725 B |
Before Width: | Height: | Size: 280 B After Width: | Height: | Size: 306 B |
Before Width: | Height: | Size: 286 B |
Before Width: | Height: | Size: 272 B After Width: | Height: | Size: 271 B |
Before Width: | Height: | Size: 292 B After Width: | Height: | Size: 310 B |
|
@ -174,25 +174,28 @@ local function add_ore(modname, description, mineral_name, oredef)
|
|||
groupcaps = tooldef
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if toolname == "sword" then
|
||||
tdef.full_punch_interval = oredef.full_punch_interval
|
||||
tdef.damage_groups = oredef.damage_groups
|
||||
tdef.tool_capabilities.full_punch_interval = oredef.full_punch_interval
|
||||
tdef.tool_capabilities.damage_groups = oredef.damage_groups
|
||||
tdef.description = S("%s Sword"):format(S(description))
|
||||
end
|
||||
|
||||
|
||||
if toolname == "pick" then
|
||||
tdef.full_punch_interval = oredef.full_punch_interval
|
||||
tdef.tool_capabilities.full_punch_interval = oredef.full_punch_interval
|
||||
tdef.tool_capabilities.damage_groups = oredef.damage_groups
|
||||
tdef.description = S("%s Pickaxe"):format(S(description))
|
||||
end
|
||||
|
||||
|
||||
if toolname == "axe" then
|
||||
tdef.full_punch_interval = oredef.full_punch_interval
|
||||
tdef.tool_capabilities.full_punch_interval = oredef.full_punch_interval
|
||||
tdef.tool_capabilities.damage_groups = oredef.damage_groups
|
||||
tdef.description = S("%s Axe"):format(S(description))
|
||||
end
|
||||
|
||||
if toolname == "shovel" then
|
||||
tdef.full_punch_interval = oredef.full_punch_interval
|
||||
tdef.tool_capabilities.damage_groups = oredef.damage_groups
|
||||
tdef.description = S("%s Shovel"):format(S(description))
|
||||
end
|
||||
|
||||
|
|
|
@ -146,42 +146,7 @@ minetest.register_craft( {
|
|||
},
|
||||
})
|
||||
|
||||
--Register crafts for plastic powder
|
||||
|
||||
if minetest.get_modpath("technic") then
|
||||
local grinder_recipes = {
|
||||
{"pipeworks:accelerator_tube_1", "plasticbox:plastic_powder 1"},
|
||||
{"pipeworks:conductor_tube_off_1", "plasticbox:plastic_powder 1"},
|
||||
{"pipeworks:crossing_tube_1", "plasticbox:plastic_powder 1"},
|
||||
{"pipeworks:detector_tube_off_1", "plasticbox:plastic_powder 1"},
|
||||
{"pipeworks:mese_sand_tube_1", "plasticbox:plastic_powder 1"},
|
||||
{"pipeworks:mese_tube_000000", "plasticbox:plastic_powder 1"},
|
||||
{"pipeworks:one_way_tube", "plasticbox:plastic_powder 1"},
|
||||
{"pipeworks:sand_tube_1", "plasticbox:plastic_powder 1"},
|
||||
{"pipeworks:teleport_tube_1", "plasticbox:plastic_powder 1"},
|
||||
{"pipeworks:tube_1", "plasticbox:plastic_powder 1"},
|
||||
{"plasticbox:plasticbox", "plasticbox:plastic_powder 2"},
|
||||
{"plasticbox:plasticbox_black", "plasticbox:plastic_powder 2"},
|
||||
{"plasticbox:plasticbox_blue", "plasticbox:plastic_powder 2"},
|
||||
{"plasticbox:plasticbox_brown", "plasticbox:plastic_powder 2"},
|
||||
{"plasticbox:plasticbox_cyan", "plasticbox:plastic_powder 2"},
|
||||
{"plasticbox:plasticbox_darkgreen", "plasticbox:plastic_powder 2"},
|
||||
{"plasticbox:plasticbox_darkgrey", "plasticbox:plastic_powder 2"},
|
||||
{"plasticbox:plasticbox_green", "plasticbox:plastic_powder 2"},
|
||||
{"plasticbox:plasticbox_grey", "plasticbox:plastic_powder 2"},
|
||||
{"plasticbox:plasticbox_magenta", "plasticbox:plastic_powder 2"},
|
||||
{"plasticbox:plasticbox_orange", "plasticbox:plastic_powder 2"},
|
||||
{"plasticbox:plasticbox_pink", "plasticbox:plastic_powder 2"},
|
||||
{"plasticbox:plasticbox_red", "plasticbox:plastic_powder 2"},
|
||||
{"plasticbox:plasticbox_violet", "plasticbox:plastic_powder 2"},
|
||||
{"plasticbox:plasticbox_white", "plasticbox:plastic_powder 2"},
|
||||
{"plasticbox:plasticbox_yellow", "plasticbox:plastic_powder 2"},
|
||||
{"homedecor:plastic_sheeting", "plasticbox:plastic_powder 1"}
|
||||
}
|
||||
for _, data in pairs(grinder_recipes) do
|
||||
technic.register_grinder_recipe({input=data[1], output=data[2]})
|
||||
end
|
||||
else
|
||||
minetest.register_craft( {
|
||||
output = "homedecor:plastic_sheeting 7",
|
||||
recipe = {
|
||||
|
@ -189,7 +154,6 @@ minetest.register_craft( {
|
|||
{ "plasticbox:plasticbox", "plasticbox:plasticbox" },
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
|
|
|
@ -1,20 +1,5 @@
|
|||
-- tubes crafting recipes
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'pipeworks:tube_1 9',
|
||||
recipe = {
|
||||
{'technic:stainless_steel_ingot', 'default:glass', 'technic:stainless_steel_ingot'},
|
||||
{'technic:stainless_steel_ingot', 'default:glass', 'technic:stainless_steel_ingot'},
|
||||
{'technic:stainless_steel_ingot', 'default:glass', 'technic:stainless_steel_ingot'},
|
||||
}
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = 'pipeworks:mese_tube_000000',
|
||||
recipe = {
|
||||
{'default:mese_crystal_fragment', 'pipeworks:tube_1', 'default:mese_crystal_fragment'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'pipeworks:accelerator_tube_1',
|
||||
recipe = {
|
||||
|
@ -22,27 +7,6 @@ minetest.register_craft({
|
|||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'pipeworks:detector_tube_off_1',
|
||||
recipe = {
|
||||
{'mesecons:mesecon', 'pipeworks:tube_1', 'mesecons:mesecon'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'pipeworks:sand_tube_1',
|
||||
recipe = {
|
||||
{'default:sand', 'pipeworks:tube_1', 'default:sand'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'pipeworks:mese_sand_tube_1',
|
||||
recipe = {
|
||||
{'default:mese_crystal_fragment', 'pipeworks:sand_tube_1', 'default:mese_crystal_fragment'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'pipeworks:teleport_tube_1',
|
||||
recipe = {
|
||||
|
@ -167,17 +131,12 @@ minetest.register_craft({
|
|||
}
|
||||
})
|
||||
|
||||
-- Remove some recipes
|
||||
minetest.register_craftitem("technic:nothing", {
|
||||
description = "",
|
||||
inventory_image = "blank.png",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "technic:nothing",
|
||||
recipe = {"default:copper_ingot", "default:steel_ingot"}
|
||||
})
|
||||
|
||||
if minetest.register_craft_predict then
|
||||
minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craft_inv)
|
||||
if itemstack:get_name() == "technic:nothing" then
|
||||
|
@ -186,3 +145,30 @@ if minetest.register_craft_predict then
|
|||
end)
|
||||
end
|
||||
|
||||
-- Bronze
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "technic:nothing",
|
||||
recipe = {"default:copper_ingot", "default:steel_ingot"}
|
||||
})
|
||||
|
||||
-- Accelerator tube
|
||||
minetest.register_craft({
|
||||
output = "technic:nothing",
|
||||
recipe = {
|
||||
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
|
||||
{ "default:mese_crystal_fragment", "default:steel_ingot", "default:mese_crystal_fragment" },
|
||||
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
|
||||
},
|
||||
})
|
||||
|
||||
-- Teleport tube
|
||||
minetest.register_craft({
|
||||
output = "technic:nothing",
|
||||
recipe = {
|
||||
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
|
||||
{ "default:desert_stone", "default:mese_block", "default:desert_stone" },
|
||||
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
|
||||
},
|
||||
})
|
||||
|
||||
|
|
|
@ -25,3 +25,21 @@ function technic.refill_RE_charge(stack)
|
|||
stack:set_metadata(minetest.serialize(meta))
|
||||
return stack
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
local function resolve_name(function_name)
|
||||
local a = _G
|
||||
for key in string.gmatch(function_name, "([^%.]+)(%.?)") do
|
||||
if a[key] then
|
||||
a = a[key]
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
return a
|
||||
end
|
||||
|
||||
function technic.function_exists(function_name)
|
||||
return type(resolve_name(function_name)) == 'function'
|
||||
end
|
||||
--------------------------------------------------------------------------------
|
||||
|
|
|
@ -39,6 +39,7 @@ Inventory move disallowed due to protection =
|
|||
%s Enabled =
|
||||
%s Idle =
|
||||
%s Improperly Placed =
|
||||
%s is empty =
|
||||
%s Unpowered =
|
||||
%s Out Of Fuel =
|
||||
%s Has Bad Cabling =
|
||||
|
|
|
@ -3,11 +3,16 @@ technic.register_tier("HV", "High Voltage")
|
|||
|
||||
local path = technic.modpath.."/machines/HV"
|
||||
|
||||
-- Wiring stuff
|
||||
dofile(path.."/cables.lua")
|
||||
dofile(path.."/quarry.lua")
|
||||
dofile(path.."/forcefield.lua")
|
||||
dofile(path.."/battery_box.lua")
|
||||
|
||||
-- Generators
|
||||
dofile(path.."/solar_array.lua")
|
||||
dofile(path.."/nuclear_reactor.lua")
|
||||
dofile(path.."/generator.lua")
|
||||
|
||||
-- Machines
|
||||
dofile(path.."/quarry.lua")
|
||||
dofile(path.."/forcefield.lua")
|
||||
|
||||
|
|
|
@ -10,5 +10,5 @@ minetest.register_craft({
|
|||
}
|
||||
})
|
||||
|
||||
technic.register_alloy_furnace({tier="LV", cook_time=6, demand={300}})
|
||||
technic.register_alloy_furnace({tier = "LV", speed = 1, demand = {300}})
|
||||
|
||||
|
|
|
@ -12,8 +12,18 @@ minetest.register_craft({
|
|||
}
|
||||
})
|
||||
|
||||
local machine_name = S("Fuel-Fired Alloy Furnace")
|
||||
local formspec =
|
||||
"size[8,9]"..
|
||||
"label[0,0;"..machine_name.."]"..
|
||||
"image[2,2;1,1;default_furnace_fire_bg.png]"..
|
||||
"list[current_name;fuel;2,3;1,1;]"..
|
||||
"list[current_name;src;2,1;2,1;]"..
|
||||
"list[current_name;dst;5,1;2,2;]"..
|
||||
"list[current_player;main;0,5;8,4;]"
|
||||
|
||||
minetest.register_node("technic:coal_alloy_furnace", {
|
||||
description = S("Fuel-Fired Alloy Furnace"),
|
||||
description = machine_name,
|
||||
tiles = {"technic_coal_alloy_furnace_top.png", "technic_coal_alloy_furnace_bottom.png",
|
||||
"technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_side.png",
|
||||
"technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_front.png"},
|
||||
|
@ -23,12 +33,11 @@ minetest.register_node("technic:coal_alloy_furnace", {
|
|||
sounds = default.node_sound_stone_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("formspec", coal_alloy_furnace_formspec)
|
||||
meta:set_string("infotext", S("Fuel-Fired Alloy Furnace"))
|
||||
meta:set_string("formspec", formspec)
|
||||
meta:set_string("infotext", machine_name)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("fuel", 1)
|
||||
inv:set_size("src", 1)
|
||||
inv:set_size("src2", 1)
|
||||
inv:set_size("src", 2)
|
||||
inv:set_size("dst", 4)
|
||||
end,
|
||||
can_dig = technic.machine_can_dig,
|
||||
|
@ -38,7 +47,7 @@ minetest.register_node("technic:coal_alloy_furnace", {
|
|||
})
|
||||
|
||||
minetest.register_node("technic:coal_alloy_furnace_active", {
|
||||
description = S("Fuel-Fired Alloy Furnace"),
|
||||
description = machine_name,
|
||||
tiles = {"technic_coal_alloy_furnace_top.png", "technic_coal_alloy_furnace_bottom.png",
|
||||
"technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_side.png",
|
||||
"technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_front_active.png"},
|
||||
|
@ -61,17 +70,14 @@ minetest.register_abm({
|
|||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
if inv:get_size("src") == 1 then -- Old furnace -> convert it
|
||||
inv:set_size("src", 2)
|
||||
inv:set_stack("src", 2, inv:get_stack("src2", 1))
|
||||
inv:set_size("src2", 0)
|
||||
end
|
||||
|
||||
local recipe = nil
|
||||
local machine_name = S("Fuel-Fired Alloy Furnace")
|
||||
local formspec =
|
||||
"size[8,9]"..
|
||||
"label[0,0;"..machine_name.."]"..
|
||||
"image[2,2;1,1;default_furnace_fire_bg.png]"..
|
||||
"list[current_name;fuel;2,3;1,1;]"..
|
||||
"list[current_name;src;2,1;1,1;]"..
|
||||
"list[current_name;src2;3,1;1,1;]"..
|
||||
"list[current_name;dst;5,1;2,2;]"..
|
||||
"list[current_player;main;0,5;8,4;]"
|
||||
|
||||
for i, name in pairs({
|
||||
"fuel_totaltime",
|
||||
|
@ -84,33 +90,22 @@ minetest.register_abm({
|
|||
end
|
||||
|
||||
-- Get what to cook if anything
|
||||
local srcstack = inv:get_stack("src", 1)
|
||||
local src2stack = inv:get_stack("src2", 1)
|
||||
local recipe = technic.get_alloy_recipe(srcstack, src2stack)
|
||||
if srcstack:get_name() > src2stack:get_name() then
|
||||
local temp = srcstack
|
||||
srcstack = src2stack
|
||||
src2stack = temp
|
||||
end
|
||||
local result = technic.get_recipe("alloy", inv:get_list("src"))
|
||||
|
||||
local was_active = false
|
||||
|
||||
if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
|
||||
was_active = true
|
||||
meta:set_int("fuel_time", meta:get_int("fuel_time") + 1)
|
||||
if recipe then
|
||||
if result then
|
||||
meta:set_int("src_time", meta:get_int("src_time") + 1)
|
||||
if meta:get_int("src_time") == 6 then
|
||||
-- check if there's room for output in "dst" list
|
||||
local dst_stack = ItemStack(recipe.output)
|
||||
if inv:room_for_item("dst", dst_stack) then
|
||||
srcstack:take_item(recipe.input[1].count)
|
||||
inv:set_stack("src", 1, srcstack)
|
||||
src2stack:take_item(recipe.input[2].count)
|
||||
inv:set_stack("src2", 1, src2stack)
|
||||
inv:add_item("dst", dst_stack)
|
||||
end
|
||||
if meta:get_int("src_time") >= result.time then
|
||||
meta:set_int("src_time", 0)
|
||||
local result_stack = ItemStack(result.output)
|
||||
if inv:room_for_item("dst", result_stack) then
|
||||
inv:set_list("src", result.new_input)
|
||||
inv:add_item("dst", result_stack)
|
||||
end
|
||||
end
|
||||
else
|
||||
meta:set_int("src_time", 0)
|
||||
|
@ -128,22 +123,17 @@ minetest.register_abm({
|
|||
"image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:"..
|
||||
(100 - percent)..":default_furnace_fire_fg.png]"..
|
||||
"list[current_name;fuel;2,3;1,1;]"..
|
||||
"list[current_name;src;2,1;1,1;]"..
|
||||
"list[current_name;src2;3,1;1,1;]"..
|
||||
"list[current_name;src;2,1;2,1;]"..
|
||||
"list[current_name;dst;5,1;2,2;]"..
|
||||
"list[current_player;main;0,5;8,4;]")
|
||||
return
|
||||
end
|
||||
|
||||
-- FIXME: Make this look more like the electrical version.
|
||||
-- This code refetches the recipe to see if it can be done again after the iteration
|
||||
srcstack = inv:get_stack("src", 1)
|
||||
srcstack = inv:get_stack("src2", 1)
|
||||
local recipe = technic.get_alloy_recipe(srcstack, src2stack)
|
||||
local recipe = technic.get_recipe("alloy", inv:get_list("src"))
|
||||
|
||||
if recipe then
|
||||
if not recipe then
|
||||
if was_active then
|
||||
meta:set_string("infotext", "Furnace is empty")
|
||||
meta:set_string("infotext", S("%s is empty"):format(machine_name))
|
||||
technic.swap_node(pos, "technic:coal_alloy_furnace")
|
||||
meta:set_string("formspec", formspec)
|
||||
end
|
||||
|
|
|
@ -3,21 +3,31 @@ technic.register_tier("LV", "Low Voltage")
|
|||
|
||||
local path = technic.modpath.."/machines/LV"
|
||||
|
||||
-- Wiring stuff
|
||||
dofile(path.."/cables.lua")
|
||||
dofile(path.."/battery_box.lua")
|
||||
dofile(path.."/alloy_furnace.lua")
|
||||
dofile(path.."/coal_alloy_furnace.lua")
|
||||
dofile(path.."/coal_furnace.lua")
|
||||
|
||||
-- Generators
|
||||
dofile(path.."/solar_panel.lua")
|
||||
dofile(path.."/solar_array.lua")
|
||||
dofile(path.."/geothermal.lua")
|
||||
dofile(path.."/water_mill.lua")
|
||||
dofile(path.."/generator.lua")
|
||||
|
||||
-- Coal-powered machines (TODO -> move to somewhere else?)
|
||||
dofile(path.."/coal_alloy_furnace.lua")
|
||||
dofile(path.."/coal_furnace.lua")
|
||||
|
||||
-- Machines
|
||||
dofile(path.."/alloy_furnace.lua")
|
||||
dofile(path.."/electric_furnace.lua")
|
||||
dofile(path.."/music_player.lua")
|
||||
dofile(path.."/grinder.lua")
|
||||
dofile(path.."/extractor.lua")
|
||||
dofile(path.."/compressor.lua")
|
||||
|
||||
dofile(path.."/music_player.lua")
|
||||
|
||||
dofile(path.."/cnc.lua")
|
||||
dofile(path.."/cnc_api.lua")
|
||||
dofile(path.."/cnc_nodes.lua")
|
||||
dofile(path.."/extractor.lua")
|
||||
dofile(path.."/compressor.lua")
|
||||
|
||||
|
|
|
@ -4,11 +4,11 @@ minetest.register_craft({
|
|||
output = 'technic:mv_alloy_furnace',
|
||||
recipe = {
|
||||
{'technic:stainless_steel_ingot', 'technic:lv_alloy_furnace', 'technic:stainless_steel_ingot'},
|
||||
{'pipeworks:tube_1', 'technic:mv_transformer', 'pipeworks:tube_1'},
|
||||
{'pipeworks:tube_1', 'technic:mv_transformer', 'pipeworks:tube_1'},
|
||||
{'technic:stainless_steel_ingot', 'technic:mv_cable0', 'technic:stainless_steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
technic.register_alloy_furnace({tier="MV", cook_time=4, upgrade=1, tube=1, demand={3000, 2000, 1000}})
|
||||
technic.register_alloy_furnace({tier = "MV", speed = 1.5, upgrade = 1, tube = 1, demand = {3000, 2000, 1000}})
|
||||
|
||||
|
|
|
@ -3,17 +3,25 @@ technic.register_tier("MV", "Medium Voltage")
|
|||
|
||||
local path = technic.modpath.."/machines/MV"
|
||||
|
||||
dofile(path.."/alloy_furnace.lua")
|
||||
dofile(path.."/battery_box.lua")
|
||||
-- Wiring stuff
|
||||
dofile(path.."/cables.lua")
|
||||
dofile(path.."/electric_furnace.lua")
|
||||
dofile(path.."/grinder.lua")
|
||||
dofile(path.."/solar_array.lua")
|
||||
dofile(path.."/tool_workshop.lua")
|
||||
dofile(path.."/battery_box.lua")
|
||||
|
||||
-- Generators
|
||||
if technic.config:get_bool("enable_wind_mill") then
|
||||
dofile(path.."/wind_mill.lua")
|
||||
end
|
||||
dofile(path.."/generator.lua")
|
||||
dofile(path.."/solar_array.lua")
|
||||
|
||||
-- Machines
|
||||
dofile(path.."/alloy_furnace.lua")
|
||||
dofile(path.."/electric_furnace.lua")
|
||||
dofile(path.."/grinder.lua")
|
||||
dofile(path.."/extractor.lua")
|
||||
dofile(path.."/compressor.lua")
|
||||
|
||||
dofile(path.."/tool_workshop.lua")
|
||||
|
||||
-- The power radiator supplies appliances with inductive coupled power:
|
||||
-- Lighting and associated textures is taken directly from VanessaE's homedecor and made electric.
|
||||
|
|
|
@ -1,289 +1,10 @@
|
|||
|
||||
local S = technic.getter
|
||||
|
||||
if unified_inventory and unified_inventory.register_craft_type then
|
||||
unified_inventory.register_craft_type("alloy", {
|
||||
description = S("Alloy cooking"),
|
||||
height = 2,
|
||||
width = 1,
|
||||
})
|
||||
end
|
||||
|
||||
-- Register alloy recipes
|
||||
technic.alloy_recipes = {}
|
||||
|
||||
-- Register recipe in a table
|
||||
technic.register_alloy_recipe = function(metal1, count1, metal2, count2, result, count3)
|
||||
local in1 = {
|
||||
name = metal1,
|
||||
count = count1,
|
||||
}
|
||||
local in2 = {
|
||||
name = metal2,
|
||||
count = count2,
|
||||
}
|
||||
-- Sort the inputs alphebetically
|
||||
if in1.name > in2.name then
|
||||
local temp = in1
|
||||
in1 = in2
|
||||
in2 = temp
|
||||
end
|
||||
technic.alloy_recipes[in1.name.." "..in2.name] = {
|
||||
input = {in1, in2},
|
||||
output = {
|
||||
name = result,
|
||||
count = count3,
|
||||
},
|
||||
}
|
||||
if unified_inventory then
|
||||
unified_inventory.register_craft({
|
||||
type = "alloy",
|
||||
output = result.." "..count3,
|
||||
items = {metal1.." "..count1, metal2.." "..count2},
|
||||
width = 0,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
minetest.after(0.01, function ()
|
||||
for _, recipe in pairs(technic.alloy_recipes) do
|
||||
local in1 = recipe.input[1]
|
||||
local in2 = recipe.input[2]
|
||||
local in1n = in1.name
|
||||
local in2n = in2.name
|
||||
while minetest.registered_aliases[in1n] do
|
||||
in1n = minetest.registered_aliases[in1n]
|
||||
end
|
||||
while minetest.registered_aliases[in2n] do
|
||||
in2n = minetest.registered_aliases[in2n]
|
||||
end
|
||||
if in1n > in2n then
|
||||
local temp = in1
|
||||
in1 = in2
|
||||
in2 = temp
|
||||
temp = in1n
|
||||
in1n = in2n
|
||||
in2n = temp
|
||||
end
|
||||
technic.alloy_recipes[in1n.." "..in2n] = {
|
||||
input = {
|
||||
{ name = in1n, count = in1.count },
|
||||
{ name = in2n, count = in2.count },
|
||||
},
|
||||
output = recipe.output,
|
||||
}
|
||||
end
|
||||
end)
|
||||
|
||||
-- Retrieve a recipe given the input metals.
|
||||
function technic.get_alloy_recipe(stack1, stack2)
|
||||
-- Sort the stacks alphebetically
|
||||
if stack1:get_name() > stack2:get_name() then
|
||||
local temp = stack1
|
||||
stack1 = stack2
|
||||
stack2 = temp
|
||||
end
|
||||
for _, recipe in pairs(technic.alloy_recipes) do
|
||||
if recipe.input[1].name == stack1:get_name() and
|
||||
recipe.input[2].name == stack2:get_name() and
|
||||
stack1:get_count() >= recipe.input[1].count and
|
||||
stack2:get_count() >= recipe.input[2].count then
|
||||
return recipe
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
technic.register_alloy_recipe("technic:copper_dust", 3, "technic:tin_dust", 1, "technic:bronze_dust", 4)
|
||||
technic.register_alloy_recipe("default:copper_ingot", 3, "moreores:tin_ingot", 1, "moreores:bronze_ingot", 4)
|
||||
technic.register_alloy_recipe("technic:wrought_iron_dust", 1, "technic:coal_dust", 1, "technic:carbon_steel_dust", 1)
|
||||
technic.register_alloy_recipe("technic:wrought_iron_ingot", 1, "technic:coal_dust", 1, "technic:carbon_steel_ingot", 1)
|
||||
technic.register_alloy_recipe("technic:carbon_steel_dust", 1, "technic:coal_dust", 1, "technic:cast_iron_dust", 1)
|
||||
technic.register_alloy_recipe("technic:carbon_steel_ingot", 1, "technic:coal_dust", 1, "technic:cast_iron_ingot", 1)
|
||||
technic.register_alloy_recipe("technic:carbon_steel_dust", 3, "technic:chromium_dust", 1, "technic:stainless_steel_dust", 4)
|
||||
technic.register_alloy_recipe("technic:carbon_steel_ingot", 3, "technic:chromium_ingot", 1, "technic:stainless_steel_ingot", 4)
|
||||
technic.register_alloy_recipe("technic:copper_dust", 2, "technic:zinc_dust", 1, "technic:brass_dust", 3)
|
||||
technic.register_alloy_recipe("default:copper_ingot", 2, "technic:zinc_ingot", 1, "technic:brass_ingot", 3)
|
||||
technic.register_alloy_recipe("default:sand", 2, "technic:coal_dust", 2, "technic:silicon_wafer", 1)
|
||||
technic.register_alloy_recipe("technic:silicon_wafer", 1, "technic:gold_dust", 1, "technic:doped_silicon_wafer", 1)
|
||||
|
||||
local tube = {
|
||||
insert_object = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:add_item("src", stack)
|
||||
end,
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:room_for_item("src", stack)
|
||||
end,
|
||||
connect_sides = {left=1, right=1, back=1, top=1, bottom=1},
|
||||
}
|
||||
|
||||
|
||||
function technic.register_alloy_furnace(data)
|
||||
local tier = data.tier
|
||||
local ltier = string.lower(tier)
|
||||
|
||||
local tube_side_texture = data.tube and "technic_"..ltier.."_alloy_furnace_side_tube.png"
|
||||
or "technic_"..ltier.."_alloy_furnace_side.png"
|
||||
|
||||
local groups = {cracky=2}
|
||||
local active_groups = {cracky=2, not_in_creative_inventory=1}
|
||||
if data.tube then
|
||||
groups.tubedevice = 1
|
||||
groups.tubedevice_receiver = 1
|
||||
active_groups.tubedevice = 1
|
||||
active_groups.tubedevice_receiver = 1
|
||||
end
|
||||
|
||||
local formspec =
|
||||
"invsize[8,10;]"..
|
||||
"label[0,0;"..S("%s Alloy Furnace"):format(tier).."]"..
|
||||
"list[current_name;src;3,1;1,2;]"..
|
||||
"list[current_name;dst;5,1;2,2;]"..
|
||||
"list[current_player;main;0,6;8,4;]"
|
||||
if data.upgrade then
|
||||
formspec = formspec..
|
||||
"list[current_name;upgrade1;1,4;1,1;]"..
|
||||
"list[current_name;upgrade2;2,4;1,1;]"..
|
||||
"label[1,5;"..S("Upgrade Slots").."]"
|
||||
end
|
||||
|
||||
minetest.register_node("technic:"..ltier.."_alloy_furnace", {
|
||||
description = S("%s Alloy Furnace"):format(tier),
|
||||
tiles = {"technic_"..ltier.."_alloy_furnace_top.png",
|
||||
"technic_"..ltier.."_alloy_furnace_bottom.png",
|
||||
tube_side_texture,
|
||||
tube_side_texture,
|
||||
"technic_"..ltier.."_alloy_furnace_side.png",
|
||||
"technic_"..ltier.."_alloy_furnace_front.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = groups,
|
||||
tube = data.tube and tube or nil,
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local name = minetest.get_node(pos).name
|
||||
|
||||
meta:set_string("infotext", S("%s Alloy Furnace"):format(tier))
|
||||
meta:set_string("formspec", formspec)
|
||||
meta:set_int("tube_time", 0)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 2)
|
||||
inv:set_size("dst", 4)
|
||||
inv:set_size("upgrade1", 1)
|
||||
inv:set_size("upgrade2", 1)
|
||||
end,
|
||||
can_dig = technic.machine_can_dig,
|
||||
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:"..ltier.."_alloy_furnace_active",{
|
||||
description = S("%s Alloy Furnace"):format(tier),
|
||||
tiles = {"technic_"..ltier.."_alloy_furnace_top.png",
|
||||
"technic_"..ltier.."_alloy_furnace_bottom.png",
|
||||
tube_side_texture,
|
||||
tube_side_texture,
|
||||
"technic_"..ltier.."_alloy_furnace_side.png",
|
||||
"technic_"..ltier.."_alloy_furnace_front_active.png"},
|
||||
paramtype2 = "facedir",
|
||||
light_source = 8,
|
||||
drop = "technic:"..ltier.."_alloy_furnace",
|
||||
groups = active_groups,
|
||||
tube = data.tube and tube or nil,
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
can_dig = technic.machine_can_dig,
|
||||
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"technic:"..ltier.."_alloy_furnace", "technic:"..ltier.."_alloy_furnace_active"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local eu_input = meta:get_int(tier.."_EU_input")
|
||||
|
||||
-- Machine information
|
||||
local machine_name = S("%s Alloy Furnace"):format(tier)
|
||||
local machine_node = "technic:"..ltier.."_alloy_furnace"
|
||||
local machine_demand = data.demand
|
||||
|
||||
-- Setup meta data if it does not exist.
|
||||
if not eu_input then
|
||||
meta:set_int(tier.."_EU_demand", machine_demand[1])
|
||||
meta:set_int(tier.."_EU_input", 0)
|
||||
end
|
||||
|
||||
-- Power off automatically if no longer connected to a switching station
|
||||
technic.switching_station_timeout_count(pos, tier)
|
||||
|
||||
local EU_upgrade, tube_upgrade = 0, 0
|
||||
if data.upgrade then
|
||||
EU_upgrade, tube_upgrade = technic.handle_machine_upgrades(meta)
|
||||
end
|
||||
if data.tube then
|
||||
technic.handle_machine_pipeworks(pos, tube_upgrade)
|
||||
end
|
||||
|
||||
-- Get what to cook if anything
|
||||
local srcstack = inv:get_stack("src", 1)
|
||||
local src2stack = inv:get_stack("src", 2)
|
||||
local recipe = technic.get_alloy_recipe(srcstack, src2stack)
|
||||
local result = recipe and ItemStack(recipe.output) or nil
|
||||
-- Sort the stacks alphabetically
|
||||
if srcstack:get_name() > src2stack:get_name() then
|
||||
local temp = srcstack
|
||||
srcstack = src2stack
|
||||
src2stack = temp
|
||||
end
|
||||
if not result or
|
||||
not inv:room_for_item("dst", result) then
|
||||
technic.swap_node(pos, machine_node)
|
||||
meta:set_string("infotext", S("%s Idle"):format(machine_name))
|
||||
meta:set_int(tier.."_EU_demand", 0)
|
||||
return
|
||||
end
|
||||
|
||||
if eu_input < machine_demand[EU_upgrade+1] then
|
||||
-- Unpowered - go idle
|
||||
technic.swap_node(pos, machine_node)
|
||||
meta:set_string("infotext", S("%s Unpowered"):format(machine_name))
|
||||
elseif eu_input >= machine_demand[EU_upgrade+1] then
|
||||
-- Powered
|
||||
technic.swap_node(pos, machine_node.."_active")
|
||||
meta:set_string("infotext", S("%s Active"):format(machine_name))
|
||||
meta:set_int("src_time", meta:get_int("src_time") + 1)
|
||||
if meta:get_int("src_time") == data.cook_time then
|
||||
meta:set_int("src_time", 0)
|
||||
-- check if there's room for output and that we have the materials
|
||||
if inv:room_for_item("dst", result) then
|
||||
srcstack:take_item(recipe.input[1].count)
|
||||
inv:set_stack("src", 1, srcstack)
|
||||
src2stack:take_item(recipe.input[2].count)
|
||||
inv:set_stack("src", 2, src2stack)
|
||||
-- Put result in "dst" list
|
||||
inv:add_item("dst", result)
|
||||
else
|
||||
next_state = 1
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
meta:set_int(tier.."_EU_demand", machine_demand[EU_upgrade+1])
|
||||
end,
|
||||
})
|
||||
|
||||
technic.register_machine(tier, "technic:"..ltier.."_alloy_furnace", technic.receiver)
|
||||
technic.register_machine(tier, "technic:"..ltier.."_alloy_furnace_active", technic.receiver)
|
||||
|
||||
end -- End registration
|
||||
data.typename = "alloy"
|
||||
data.machine_name = "alloy_furnace"
|
||||
data.machine_desc = S("%s Alloy Furnace")
|
||||
technic.register_base_machine(data)
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
local S = technic.getter
|
||||
|
||||
technic.register_recipe_type("alloy", S("Alloy cooking"), 2)
|
||||
|
||||
function technic.register_alloy_recipe(data)
|
||||
data.time = data.time or 6
|
||||
technic.register_recipe("alloy", data)
|
||||
end
|
||||
|
||||
local recipes = {
|
||||
{"technic:copper_dust 3", "technic:tin_dust", "technic:bronze_dust 4"},
|
||||
{"default:copper_ingot 3", "moreores:tin_ingot", "default:bronze_ingot 4"},
|
||||
{"technic:wrought_iron_dust", "technic:coal_dust", "technic:carbon_steel_dust"},
|
||||
{"technic:wrought_iron_ingot", "technic:coal_dust", "technic:carbon_steel_ingot"},
|
||||
{"technic:carbon_steel_dust", "technic:coal_dust", "technic:cast_iron_dust"},
|
||||
{"technic:carbon_steel_ingot", "technic:coal_dust", "technic:cast_iron_ingot"},
|
||||
{"technic:carbon_steel_dust 3", "technic:chromium_dust", "technic:stainless_steel_dust 4"},
|
||||
{"technic:carbon_steel_ingot 3", "technic:chromium_ingot", "technic:stainless_steel_ingot 4"},
|
||||
{"technic:copper_dust 2", "technic:zinc_dust", "technic:brass_dust 3"},
|
||||
{"default:copper_ingot 2", "technic:zinc_ingot", "technic:brass_ingot 3"},
|
||||
{"default:sand 2", "technic:coal_dust 2", "technic:silicon_wafer"},
|
||||
{"technic:silicon_wafer", "technic:gold_dust", "technic:doped_silicon_wafer"},
|
||||
}
|
||||
|
||||
for _, data in pairs(recipes) do
|
||||
technic.register_alloy_recipe({input = {data[1], data[2]}, output = data[3]})
|
||||
end
|
|
@ -19,6 +19,6 @@ local recipes = {
|
|||
}
|
||||
|
||||
for _, data in pairs(recipes) do
|
||||
technic.register_compressor_recipe({input = data[1], output = data[2]})
|
||||
technic.register_compressor_recipe({input = {data[1]}, output = data[2]})
|
||||
end
|
||||
|
||||
|
|
|
@ -30,6 +30,6 @@ local recipes = {
|
|||
}
|
||||
|
||||
for _, data in pairs(recipes) do
|
||||
technic.register_extractor_recipe({input = data[1], output = data[2]})
|
||||
technic.register_extractor_recipe({input = {data[1]}, output = data[2]})
|
||||
end
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ if minetest.get_modpath("homedecor") then
|
|||
end
|
||||
|
||||
for _, data in pairs(recipes) do
|
||||
technic.register_grinder_recipe({input = data[1], output = data[2]})
|
||||
technic.register_grinder_recipe({input = {data[1]}, output = data[2]})
|
||||
end
|
||||
|
||||
local function register_dust(name, ingot)
|
||||
|
@ -57,7 +57,7 @@ local function register_dust(name, ingot)
|
|||
recipe = "technic:"..lname.."_dust",
|
||||
output = ingot,
|
||||
})
|
||||
technic.register_grinder_recipe({ input = ingot, output = "technic:"..lname.."_dust 1" })
|
||||
technic.register_grinder_recipe({ input = {ingot}, output = "technic:"..lname.."_dust 1" })
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,18 +1,29 @@
|
|||
local path = technic.modpath.."/machines/register"
|
||||
|
||||
dofile(path.."/recipes.lua")
|
||||
dofile(path.."/machine_base.lua")
|
||||
dofile(path.."/alloy_furnace.lua")
|
||||
dofile(path.."/battery_box.lua")
|
||||
dofile(path.."/cables.lua")
|
||||
dofile(path.."/common.lua")
|
||||
dofile(path.."/electric_furnace.lua")
|
||||
dofile(path.."/grinder.lua")
|
||||
dofile(path.."/grinder_recipes.lua")
|
||||
dofile(path.."/extractor.lua")
|
||||
dofile(path.."/extractor_recipes.lua")
|
||||
dofile(path.."/compressor.lua")
|
||||
dofile(path.."/compressor_recipes.lua")
|
||||
|
||||
-- Wiring stuff
|
||||
dofile(path.."/cables.lua")
|
||||
dofile(path.."/battery_box.lua")
|
||||
|
||||
-- Generators
|
||||
dofile(path.."/solar_array.lua")
|
||||
dofile(path.."/generator.lua")
|
||||
|
||||
-- API for machines
|
||||
dofile(path.."/recipes.lua")
|
||||
dofile(path.."/machine_base.lua")
|
||||
|
||||
-- Recipes
|
||||
dofile(path.."/alloy_recipes.lua")
|
||||
dofile(path.."/grinder_recipes.lua")
|
||||
dofile(path.."/extractor_recipes.lua")
|
||||
dofile(path.."/compressor_recipes.lua")
|
||||
|
||||
-- Machines
|
||||
dofile(path.."/alloy_furnace.lua")
|
||||
dofile(path.."/electric_furnace.lua")
|
||||
dofile(path.."/grinder.lua")
|
||||
dofile(path.."/extractor.lua")
|
||||
dofile(path.."/compressor.lua")
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ local tube = {
|
|||
|
||||
function technic.register_base_machine(data)
|
||||
local typename = data.typename
|
||||
local numitems = technic.recipes[typename].numitems
|
||||
local machine_name = data.machine_name
|
||||
local machine_desc = data.machine_desc
|
||||
local tier = data.tier
|
||||
|
@ -34,10 +35,10 @@ function technic.register_base_machine(data)
|
|||
|
||||
local formspec =
|
||||
"invsize[8,9;]"..
|
||||
"list[current_name;src;3,1;1,1;]"..
|
||||
"list[current_name;src;"..(4-numitems)..",1;"..numitems..",1;]"..
|
||||
"list[current_name;dst;5,1;2,2;]"..
|
||||
"list[current_player;main;0,5;8,4;]"..
|
||||
"label[0,0;"..S("%s Grinder"):format(tier).."]"
|
||||
"label[0,0;"..machine_desc:format(tier).."]"
|
||||
if data.upgrade then
|
||||
formspec = formspec..
|
||||
"list[current_name;upgrade1;1,3;1,1;]"..
|
||||
|
@ -65,7 +66,7 @@ function technic.register_base_machine(data)
|
|||
meta:set_int("tube_time", 0)
|
||||
meta:set_string("formspec", formspec)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 1)
|
||||
inv:set_size("src", numitems)
|
||||
inv:set_size("dst", 4)
|
||||
inv:set_size("upgrade1", 1)
|
||||
inv:set_size("upgrade2", 1)
|
||||
|
@ -128,7 +129,7 @@ function technic.register_base_machine(data)
|
|||
technic.handle_machine_pipeworks(pos, tube_upgrade)
|
||||
end
|
||||
|
||||
local result = technic.get_recipe(typename, inv:get_stack("src", 1))
|
||||
local result = technic.get_recipe(typename, inv:get_list("src"))
|
||||
|
||||
if not result then
|
||||
technic.swap_node(pos, machine_node)
|
||||
|
@ -151,9 +152,7 @@ function technic.register_base_machine(data)
|
|||
meta:set_int("src_time", 0)
|
||||
local result_stack = ItemStack(result.output)
|
||||
if inv:room_for_item("dst", result_stack) then
|
||||
srcstack = inv:get_stack("src", 1)
|
||||
srcstack:take_item(ItemStack(result.input):get_count())
|
||||
inv:set_stack("src", 1, srcstack)
|
||||
inv:set_list("src", result.new_input)
|
||||
inv:add_item("dst", result_stack)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,63 +1,88 @@
|
|||
|
||||
technic.recipes = {}
|
||||
function technic.register_recipe_type(typename, desc)
|
||||
technic.recipes = {cooking = {numitems = 1}}
|
||||
function technic.register_recipe_type(typename, desc, numitems)
|
||||
numitems = numitems or 1
|
||||
if unified_inventory and unified_inventory.register_craft_type then
|
||||
unified_inventory.register_craft_type(typename, {
|
||||
description = desc,
|
||||
height = 1,
|
||||
height = numitems,
|
||||
width = 1,
|
||||
})
|
||||
end
|
||||
technic.recipes[typename] = {}
|
||||
technic.recipes[typename] = {numitems = numitems, recipes = {}}
|
||||
end
|
||||
|
||||
function technic.register_recipe(typename, data)
|
||||
local src = ItemStack(data.input):get_name()
|
||||
technic.recipes[typename][src] = data
|
||||
local function get_recipe_index(items)
|
||||
local l = {}
|
||||
for i, stack in ipairs(items) do
|
||||
l[i] = ItemStack(stack):get_name()
|
||||
end
|
||||
table.sort(l)
|
||||
return table.concat(l, "/")
|
||||
end
|
||||
|
||||
local function register_recipe(typename, data)
|
||||
-- Handle aliases
|
||||
for i, stack in ipairs(data.input) do
|
||||
data.input[i] = ItemStack(stack):to_string()
|
||||
end
|
||||
data.output = ItemStack(data.output):to_string()
|
||||
|
||||
local recipe = {time = data.time, input = {}, output = data.output}
|
||||
local index = get_recipe_index(data.input)
|
||||
for _, stack in ipairs(data.input) do
|
||||
recipe.input[ItemStack(stack):get_name()] = ItemStack(stack):get_count()
|
||||
end
|
||||
|
||||
technic.recipes[typename].recipes[index] = recipe
|
||||
if unified_inventory then
|
||||
unified_inventory.register_craft({
|
||||
type = typename,
|
||||
output = data.output,
|
||||
items = {data.input},
|
||||
items = data.input,
|
||||
width = 0,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
function technic.get_recipe(typename, item)
|
||||
function technic.register_recipe(typename, data)
|
||||
minetest.after(0.01, register_recipe, typename, data) -- Handle aliases
|
||||
end
|
||||
|
||||
function technic.get_recipe(typename, items)
|
||||
if typename == "cooking" then -- Already builtin in Minetest, so use that
|
||||
local result = minetest.get_craft_result({
|
||||
local result, new_input = minetest.get_craft_result({
|
||||
method = "cooking",
|
||||
width = 1,
|
||||
items = {item}})
|
||||
items = items})
|
||||
-- Compatibility layer
|
||||
if not result or result.time == 0 then
|
||||
return nil
|
||||
else
|
||||
return {time = result.time,
|
||||
input = item:get_name(),
|
||||
output = result.item:to_string()}
|
||||
new_input = new_input.items,
|
||||
output = result.item}
|
||||
end
|
||||
end
|
||||
local recipe = technic.recipes[typename][item:get_name()]
|
||||
if recipe and item:get_count() >= ItemStack(recipe.input):get_count() then
|
||||
return recipe
|
||||
local index = get_recipe_index(items)
|
||||
local recipe = technic.recipes[typename].recipes[index]
|
||||
if recipe then
|
||||
local new_input = {}
|
||||
for i, stack in ipairs(items) do
|
||||
if stack:get_count() < recipe.input[stack:get_name()] then
|
||||
print(stack:get_name())
|
||||
return nil
|
||||
else
|
||||
new_input[i] = ItemStack(stack)
|
||||
new_input[i]:take_item(recipe.input[stack:get_name()])
|
||||
end
|
||||
end
|
||||
return {time = recipe.time,
|
||||
new_input = new_input,
|
||||
output = recipe.output}
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
-- Handle aliases
|
||||
minetest.after(0.01, function ()
|
||||
for _, recipes_list in pairs(technic.recipes) do
|
||||
for ingredient, recipe in pairs(recipes_list) do
|
||||
ingredient = minetest.registered_aliases[ingredient]
|
||||
while ingredient do
|
||||
recipes_list[ingredient] = recipe
|
||||
ingredient = minetest.registered_aliases[ingredient]
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
|
|
After Width: | Height: | Size: 367 B |
|
@ -13,6 +13,7 @@ dofile(path.."/cans.lua")
|
|||
dofile(path.."/chainsaw.lua")
|
||||
dofile(path.."/tree_tap.lua")
|
||||
dofile(path.."/sonic_screwdriver.lua")
|
||||
dofile(path.."/prospector.lua")
|
||||
|
||||
if minetest.get_modpath("screwdriver") then
|
||||
-- compatibility alias
|
||||
|
|
|
@ -0,0 +1,126 @@
|
|||
local S = technic.getter
|
||||
|
||||
technic.register_power_tool("technic:prospector", 15000)
|
||||
|
||||
local function get_metadata(toolstack)
|
||||
local m = minetest.deserialize(toolstack:get_metadata())
|
||||
if not m then m = {} end
|
||||
if not m.charge then m.charge = 0 end
|
||||
if not m.target then m.target = "" end
|
||||
if not m.look_depth then m.look_depth = 7 end
|
||||
if not m.look_radius then m.look_radius = 1 end
|
||||
return m
|
||||
end
|
||||
|
||||
minetest.register_tool("technic:prospector", {
|
||||
description = S("Prospector"),
|
||||
inventory_image = "technic_prospector.png",
|
||||
wear_represents = "technic_RE_charge",
|
||||
on_refill = technic.refill_RE_charge,
|
||||
on_use = function(toolstack, user, pointed_thing)
|
||||
if not user or not user:is_player() or user.is_fake_player then return end
|
||||
if pointed_thing.type ~= "node" then return end
|
||||
local toolmeta = get_metadata(toolstack)
|
||||
local look_diameter = toolmeta.look_radius * 2 + 1
|
||||
local charge_to_take = toolmeta.look_depth * (toolmeta.look_depth + 1) * look_diameter * look_diameter
|
||||
if toolmeta.charge < charge_to_take then return end
|
||||
if toolmeta.target == "" then
|
||||
minetest.chat_send_player(user:get_player_name(), "Right-click to set target block type")
|
||||
return
|
||||
end
|
||||
toolmeta.charge = toolmeta.charge - charge_to_take
|
||||
toolstack:set_metadata(minetest.serialize(toolmeta))
|
||||
technic.set_RE_wear(toolstack, toolmeta.charge, technic.power_tools[toolstack:get_name()])
|
||||
local start_pos = pointed_thing.under
|
||||
local forward = minetest.facedir_to_dir(minetest.dir_to_facedir(user:get_look_dir(), true))
|
||||
local right = forward.x ~= 0 and { x=0, y=1, z=0 } or (forward.y ~= 0 and { x=0, y=0, z=1 } or { x=1, y=0, z=0 })
|
||||
local up = forward.x ~= 0 and { x=0, y=0, z=1 } or (forward.y ~= 0 and { x=1, y=0, z=0 } or { x=0, y=1, z=0 })
|
||||
local base_pos = vector.add(start_pos, vector.multiply(vector.add(right, up), - toolmeta.look_radius))
|
||||
local found = false
|
||||
for f = 0, toolmeta.look_depth-1 do
|
||||
for r = 0, look_diameter-1 do
|
||||
for u = 0, look_diameter-1 do
|
||||
if minetest.get_node(vector.add(vector.add(vector.add(base_pos, vector.multiply(forward, f)), vector.multiply(right, r)), vector.multiply(up, u))).name == toolmeta.target then found = true end
|
||||
end
|
||||
end
|
||||
end
|
||||
if math.random() < 0.02 then found = not found end
|
||||
minetest.chat_send_player(user:get_player_name(), minetest.registered_nodes[toolmeta.target].description.." is "..(found and "present" or "absent").." in "..look_diameter.."x"..look_diameter.."x"..toolmeta.look_depth.." region")
|
||||
minetest.sound_play("technic_prospector_"..(found and "hit" or "miss"), { pos = vector.add(user:getpos(), { x = 0, y = 1, z = 0 }), gain = 1.0, max_hear_distance = 10 })
|
||||
return toolstack
|
||||
end,
|
||||
on_place = function(toolstack, user, pointed_thing)
|
||||
if not user or not user:is_player() or user.is_fake_player then return end
|
||||
local toolmeta = get_metadata(toolstack)
|
||||
local pointed
|
||||
if pointed_thing.type == "node" then
|
||||
local pname = minetest.get_node(pointed_thing.under).name
|
||||
local pdef = minetest.registered_nodes[pname]
|
||||
if pdef and (pdef.groups.not_in_creative_inventory or 0) == 0 and pname ~= toolmeta.target then
|
||||
pointed = pname
|
||||
end
|
||||
end
|
||||
local look_diameter = toolmeta.look_radius * 2 + 1
|
||||
minetest.show_formspec(user:get_player_name(), "technic:prospector_control",
|
||||
"size[7,8.5]"..
|
||||
"item_image[0,0;1,1;"..toolstack:get_name().."]"..
|
||||
"label[1,0;"..minetest.formspec_escape(toolstack:get_definition().description).."]"..
|
||||
(toolmeta.target ~= "" and
|
||||
"label[0,1.5;Current target:]"..
|
||||
"label[0,2;"..minetest.formspec_escape(minetest.registered_nodes[toolmeta.target].description).."]"..
|
||||
"item_image[0,2.5;1,1;"..toolmeta.target.."]" or
|
||||
"label[0,1.5;No target set]")..
|
||||
(pointed and
|
||||
"label[3.5,1.5;May set new target:]"..
|
||||
"label[3.5,2;"..minetest.formspec_escape(minetest.registered_nodes[pointed].description).."]"..
|
||||
"item_image[3.5,2.5;1,1;"..pointed.."]"..
|
||||
"button_exit[3.5,3.65;2,0.5;target_"..pointed..";Set target]" or
|
||||
"label[3.5,1.5;No new target available]")..
|
||||
"label[0,4.5;Region cross section:]"..
|
||||
"label[0,5;"..look_diameter.."x"..look_diameter.."]"..
|
||||
"label[3.5,4.5;Set region cross section:]"..
|
||||
"button_exit[3.5,5.15;1,0.5;look_radius_0;1x1]"..
|
||||
"button_exit[4.5,5.15;1,0.5;look_radius_1;3x3]"..
|
||||
"button_exit[5.5,5.15;1,0.5;look_radius_3;7x7]"..
|
||||
"label[0,6;Region depth:]"..
|
||||
"label[0,6.5;"..toolmeta.look_depth.."]"..
|
||||
"label[3.5,6;Set region depth:]"..
|
||||
"button_exit[3.5,6.65;1,0.5;look_depth_7;7]"..
|
||||
"button_exit[4.5,6.65;1,0.5;look_depth_14;14]"..
|
||||
"button_exit[5.5,6.65;1,0.5;look_depth_21;21]"..
|
||||
"label[0,7.5;Accuracy:]"..
|
||||
"label[0,8;98%]")
|
||||
return
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_on_player_receive_fields(function(user, formname, fields)
|
||||
if formname ~= "technic:prospector_control" then return false end
|
||||
if not user or not user:is_player() or user.is_fake_player then return end
|
||||
local toolstack = user:get_wielded_item()
|
||||
if toolstack:get_name() ~= "technic:prospector" then return true end
|
||||
local toolmeta = get_metadata(toolstack)
|
||||
for field, value in pairs(fields) do
|
||||
if field:sub(1, 7) == "target_" then
|
||||
toolmeta.target = field:sub(8)
|
||||
end
|
||||
if field:sub(1, 12) == "look_radius_" then
|
||||
toolmeta.look_radius = field:sub(13)
|
||||
end
|
||||
if field:sub(1, 11) == "look_depth_" then
|
||||
toolmeta.look_depth = field:sub(12)
|
||||
end
|
||||
end
|
||||
toolstack:set_metadata(minetest.serialize(toolmeta))
|
||||
user:set_wielded_item(toolstack)
|
||||
return true
|
||||
end)
|
||||
|
||||
minetest.register_craft({
|
||||
output = "technic:prospector",
|
||||
recipe = {
|
||||
{"moreores:pick_silver", "moreores:mithril_block", "pipeworks:teleport_tube_1"},
|
||||
{"technic:brass_ingot", "technic:control_logic_unit", "technic:brass_ingot"},
|
||||
{"", "technic:brass_ingot", ""},
|
||||
}
|
||||
})
|
|
@ -1,83 +0,0 @@
|
|||
datastorage={}
|
||||
datastorage["!registered_players"]={}
|
||||
|
||||
datastorage.save_data = function(table_pointer)
|
||||
local data = minetest.serialize( datastorage[table_pointer] )
|
||||
local path = minetest.get_worldpath().."/datastorage_"..table_pointer..".data"
|
||||
local file = io.open( path, "w" )
|
||||
if( file ) then
|
||||
file:write( data )
|
||||
file:close()
|
||||
return true
|
||||
else return nil
|
||||
end
|
||||
end
|
||||
|
||||
datastorage.load_data = function(table_pointer)
|
||||
local path = minetest.get_worldpath().."/datastorage_"..table_pointer..".data"
|
||||
local file = io.open( path, "r" )
|
||||
if( file ) then
|
||||
local data = file:read("*all")
|
||||
datastorage[table_pointer] = minetest.deserialize( data )
|
||||
file:close()
|
||||
return true
|
||||
else return nil
|
||||
end
|
||||
end
|
||||
|
||||
datastorage.get_container = function (player, key)
|
||||
local player_name = player:get_player_name()
|
||||
local container = datastorage[player_name]
|
||||
if container[key] == nil then
|
||||
container[key] = {}
|
||||
end
|
||||
datastorage.save_data(player_name)
|
||||
return container[key]
|
||||
end
|
||||
|
||||
-- forced save of all player's data
|
||||
datastorage.save_container = function (player)
|
||||
local player_name = player:get_player_name()
|
||||
datastorage.save_data(player_name)
|
||||
end
|
||||
|
||||
|
||||
-- Init
|
||||
if datastorage.load_data("!registered_players") == nil then
|
||||
datastorage["!registered_players"]={}
|
||||
datastorage.save_data("!registered_players")
|
||||
end
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local player_name = player:get_player_name()
|
||||
local registered = nil
|
||||
for __,tab in ipairs(datastorage["!registered_players"]) do
|
||||
if tab["player_name"] == player_name then registered = true break end
|
||||
end
|
||||
if registered == nil then
|
||||
local new={}
|
||||
new["player_name"]=player_name
|
||||
table.insert(datastorage["!registered_players"],new)
|
||||
datastorage[player_name]={}
|
||||
datastorage.save_data("!registered_players")
|
||||
datastorage.save_data(player_name)
|
||||
else
|
||||
datastorage.load_data(player_name)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
local player_name = player:get_player_name()
|
||||
datastorage.save_data(player_name)
|
||||
datastorage[player_name] = nil
|
||||
end
|
||||
)
|
||||
|
||||
minetest.register_on_shutdown(function()
|
||||
for __,tab in ipairs(datastorage["!registered_players"]) do
|
||||
if datastorage[tab["player_name"]] == nil then break end
|
||||
datastorage.save_data(tab["player_name"])
|
||||
end
|
||||
end
|
||||
)
|
|
@ -1,2 +1,4 @@
|
|||
creative?
|
||||
intllib?
|
||||
datastorage?
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@ if creative_inventory then
|
|||
end
|
||||
end
|
||||
|
||||
dofile(modpath.."/datastorage.lua")
|
||||
dofile(modpath.."/group.lua")
|
||||
dofile(modpath.."/api.lua")
|
||||
dofile(modpath.."/internal.lua")
|
||||
|
@ -46,4 +45,7 @@ dofile(modpath.."/callbacks.lua")
|
|||
dofile(modpath.."/register.lua")
|
||||
dofile(modpath.."/bags.lua")
|
||||
dofile(modpath.."/item_names.lua")
|
||||
dofile(modpath.."/waypoints.lua")
|
||||
if minetest.get_modpath("datastorage") then
|
||||
dofile(modpath.."/waypoints.lua")
|
||||
end
|
||||
|
||||
|
|
|
@ -5,88 +5,105 @@ else
|
|||
S = function(s) return s end
|
||||
end
|
||||
|
||||
unified_inventory.hud_colors = {
|
||||
{"#FFFFFF", 0xFFFFFF, S("White")},
|
||||
{"#DBBB00", 0xf1d32c, S("Yellow")},
|
||||
{"#DD0000", 0xDD0000, S("Red")},
|
||||
{"#2cf136", 0x2cf136, S("Green")},
|
||||
{"#2c4df1", 0x2c4df1, S("Blue")},
|
||||
}
|
||||
unified_inventory.hud_colors_max = #unified_inventory.hud_colors
|
||||
|
||||
local hud_colors = {
|
||||
{"#FFFFFF", 0xFFFFFF, S("White")},
|
||||
{"#DBBB00", 0xf1d32c, S("Yellow")},
|
||||
{"#DD0000", 0xDD0000, S("Red")},
|
||||
{"#2cf136", 0x2cf136, S("Green")},
|
||||
{"#2c4df1", 0x2c4df1, S("Blue")},
|
||||
}
|
||||
|
||||
local hud_colors_max = #hud_colors
|
||||
|
||||
-- Stores temporary player data (persists until player leaves)
|
||||
local waypoints_temp = {}
|
||||
|
||||
unified_inventory.register_page("waypoints", {
|
||||
get_formspec = function(player)
|
||||
local waypoints = datastorage.get_container (player, "waypoints")
|
||||
local player_name = player:get_player_name()
|
||||
local waypoints = datastorage.get(player_name, "waypoints")
|
||||
local formspec = "background[0,4.5;8,4;ui_main_inventory.png]" ..
|
||||
"image[0,0;1,1;ui_waypoints_icon.png]" ..
|
||||
"label[1,0;" .. S("Waypoints") .. "]"
|
||||
"label[1,0;" .. S("Waypoints") .. "]"
|
||||
|
||||
-- Tabs buttons:
|
||||
local i
|
||||
for i = 1, 5, 1 do
|
||||
formspec = formspec ..
|
||||
"image_button[0.0," .. 0.2 + i * 0.7 .. ";.8,.8;" ..
|
||||
(i == waypoints.selected and "ui_blue_icon_background.png^" or "") ..
|
||||
"ui_" .. i .. "_icon.png;" ..
|
||||
"select_waypoint" .. i .. ";]" ..
|
||||
"tooltip[select_waypoint" .. i .. ";" .. minetest.formspec_escape(S("Select Waypoint #%d"):format(i)).."]"
|
||||
"tooltip[select_waypoint" .. i .. ";"
|
||||
.. minetest.formspec_escape(S("Select Waypoint #%d"):format(i)).."]"
|
||||
end
|
||||
|
||||
i = waypoints.selected
|
||||
|
||||
|
||||
local i = waypoints.selected or 1
|
||||
local waypoint = waypoints[i] or {}
|
||||
local temp = waypoints_temp[player_name][i] or {}
|
||||
local default_name = "Waypoint "..i
|
||||
|
||||
-- Main buttons:
|
||||
formspec = formspec ..
|
||||
formspec = formspec ..
|
||||
"image_button[4.5,3.7;.8,.8;"..
|
||||
"ui_waypoint_set_icon.png;"..
|
||||
"set_waypoint"..i..";]"..
|
||||
"tooltip[set_waypoint" .. i .. ";" .. minetest.formspec_escape(S("Set waypoint to current location")).."]"
|
||||
"tooltip[set_waypoint" .. i .. ";"
|
||||
.. minetest.formspec_escape(S("Set waypoint to current location")).."]"
|
||||
|
||||
formspec = formspec ..
|
||||
"image_button[5.2,3.7;.8,.8;"..
|
||||
(waypoints[i].active and "ui_on_icon.png" or "ui_off_icon.png")..";"..
|
||||
(waypoint.active and "ui_on_icon.png" or "ui_off_icon.png")..";"..
|
||||
"toggle_waypoint"..i..";]"..
|
||||
"tooltip[toggle_waypoint" .. i .. ";" .. minetest.formspec_escape(S("Make waypoint "..(waypoints[i].active and "invisible" or "visible"))).."]"
|
||||
"tooltip[toggle_waypoint" .. i .. ";"
|
||||
.. minetest.formspec_escape(S("Make waypoint "
|
||||
..(waypoint.active and "invisible" or "visible"))).."]"
|
||||
|
||||
formspec = formspec ..
|
||||
formspec = formspec ..
|
||||
"image_button[5.9,3.7;.8,.8;"..
|
||||
(waypoints[i].display_pos and "ui_green_icon_background.png" or "ui_red_icon_background.png").."^ui_xyz_icon.png;"..
|
||||
(waypoint.display_pos and "ui_green_icon_background.png" or "ui_red_icon_background.png").."^ui_xyz_icon.png;"..
|
||||
"toggle_display_pos" .. i .. ";]"..
|
||||
"tooltip[toggle_display_pos" .. i .. ";" .. minetest.formspec_escape(S((waypoints[i].display_pos and "Disable" or "Enable").." display of waypoint coordinates")).."]"
|
||||
"tooltip[toggle_display_pos" .. i .. ";"
|
||||
.. minetest.formspec_escape(S((waypoint.display_pos and "Disable" or "Enable")
|
||||
.." display of waypoint coordinates")).."]"
|
||||
|
||||
formspec = formspec ..
|
||||
"image_button[6.6,3.7;.8,.8;"..
|
||||
"ui_circular_arrows_icon.png;"..
|
||||
"toggle_color"..i..";]"..
|
||||
"tooltip[toggle_color" .. i .. ";" .. minetest.formspec_escape(S("Change color of waypoint display")).."]"
|
||||
"tooltip[toggle_color" .. i .. ";"
|
||||
.. minetest.formspec_escape(S("Change color of waypoint display")).."]"
|
||||
|
||||
formspec = formspec ..
|
||||
"image_button[7.3,3.7;.8,.8;"..
|
||||
"ui_pencil_icon.png;"..
|
||||
"rename_waypoint"..i..";]"..
|
||||
"tooltip[rename_waypoint" .. i .. ";" .. minetest.formspec_escape(S("Edit waypoint name")).."]"
|
||||
|
||||
-- Waypoint's info:
|
||||
if waypoints[i].active then
|
||||
"tooltip[rename_waypoint" .. i .. ";"
|
||||
.. minetest.formspec_escape(S("Edit waypoint name")).."]"
|
||||
|
||||
-- Waypoint's info:
|
||||
if waypoint.active then
|
||||
formspec = formspec .. "label[1,0.8;"..S("Waypoint active").."]"
|
||||
else
|
||||
else
|
||||
formspec = formspec .. "label[1,0.8;"..S("Waypoint inactive").."]"
|
||||
end
|
||||
|
||||
if waypoints[i].edit then
|
||||
if temp.edit then
|
||||
formspec = formspec ..
|
||||
"field[1.3,3.2;6,.8;rename_box" .. i .. ";;"..waypoints[i].name.."]" ..
|
||||
"field[1.3,3.2;6,.8;rename_box" .. i .. ";;"
|
||||
..(waypoint.name or default_name).."]" ..
|
||||
"image_button[7.3,2.9;.8,.8;"..
|
||||
"ui_ok_icon.png;"..
|
||||
"confirm_rename"..i.. ";]"..
|
||||
"tooltip[confirm_rename" .. i .. ";" .. minetest.formspec_escape(S("Finish editing")).."]"
|
||||
"tooltip[confirm_rename" .. i .. ";"
|
||||
.. minetest.formspec_escape(S("Finish editing")).."]"
|
||||
end
|
||||
|
||||
formspec = formspec .. "label[1,1.3;"..S("World position")..": " ..
|
||||
minetest.pos_to_string(waypoints[i].world_pos) .. "]" ..
|
||||
"label[1,1.8;"..S("Name")..": ".. waypoints[i].name .. "]" ..
|
||||
|
||||
formspec = formspec .. "label[1,1.3;"..S("World position")..": " ..
|
||||
minetest.pos_to_string(waypoint.world_pos or vector.new()) .. "]" ..
|
||||
"label[1,1.8;"..S("Name")..": ".. (waypoint.name or default_name) .. "]" ..
|
||||
"label[1,2.3;"..S("HUD text color")..": " ..
|
||||
unified_inventory.hud_colors[waypoints[i].color][3] .. "]"
|
||||
|
||||
hud_colors[waypoint.color or 1][3] .. "]"
|
||||
|
||||
return {formspec=formspec}
|
||||
end,
|
||||
})
|
||||
|
@ -97,133 +114,132 @@ unified_inventory.register_button("waypoints", {
|
|||
tooltip = S("Waypoints"),
|
||||
})
|
||||
|
||||
unified_inventory.update_hud = function (player, waypoint)
|
||||
local function update_hud(player, waypoints, temp, i)
|
||||
local waypoint = waypoints[i]
|
||||
if not waypoint then return end
|
||||
temp[i] = temp[i] or {}
|
||||
temp = temp[i]
|
||||
local pos = waypoint.world_pos or vector.new()
|
||||
local name
|
||||
if waypoint.display_pos then
|
||||
name = "("..
|
||||
waypoint.world_pos.x .. "," ..
|
||||
waypoint.world_pos.y .. "," ..
|
||||
waypoint.world_pos.z .. ")"
|
||||
if waypoint.name ~= "" then
|
||||
name = name .. ", " ..
|
||||
waypoint.name
|
||||
name = minetest.pos_to_string(pos)
|
||||
if waypoint.name then
|
||||
name = name..", "..waypoint.name
|
||||
end
|
||||
else
|
||||
name = waypoint.name
|
||||
name = waypoint.name or "Waypoint "..i
|
||||
end
|
||||
if waypoint.hud then
|
||||
player:hud_remove(waypoint.hud)
|
||||
if temp.hud then
|
||||
player:hud_remove(temp.hud)
|
||||
end
|
||||
if waypoint.active then
|
||||
waypoint.hud = player:hud_add({
|
||||
temp.hud = player:hud_add({
|
||||
hud_elem_type = "waypoint",
|
||||
number = unified_inventory.hud_colors[waypoint.color][2] ,
|
||||
number = hud_colors[waypoint.color or 1][2] ,
|
||||
name = name,
|
||||
text = "m",
|
||||
world_pos = waypoint.world_pos
|
||||
world_pos = pos
|
||||
})
|
||||
else
|
||||
waypoint.hud = nil
|
||||
else
|
||||
temp.hud = nil
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if formname ~= "" then
|
||||
return
|
||||
end
|
||||
if formname ~= "" then return end
|
||||
|
||||
local player_name = player:get_player_name()
|
||||
local update_formspec = false
|
||||
local update_hud = false
|
||||
|
||||
local waypoints = datastorage.get_container (player, "waypoints")
|
||||
for i = 1, 5, 1 do
|
||||
local need_update_hud = false
|
||||
local hit = false
|
||||
|
||||
local waypoints = datastorage.get(player_name, "waypoints")
|
||||
local temp = waypoints_temp[player_name]
|
||||
for i = 1, 5, 1 do
|
||||
if fields["select_waypoint"..i] then
|
||||
hit = true
|
||||
waypoints.selected = i
|
||||
update_formspec = true
|
||||
end
|
||||
|
||||
if fields["toggle_waypoint"..i] then
|
||||
hit = true
|
||||
waypoints[i] = waypoints[i] or {}
|
||||
waypoints[i].active = not (waypoints[i].active)
|
||||
update_hud = true
|
||||
need_update_hud = true
|
||||
update_formspec = true
|
||||
end
|
||||
|
||||
|
||||
if fields["set_waypoint"..i] then
|
||||
hit = true
|
||||
local pos = player:getpos()
|
||||
pos.x = math.floor(pos.x)
|
||||
pos.y = math.floor(pos.y)
|
||||
pos.z = math.floor(pos.z)
|
||||
waypoints[i] = waypoints[i] or {}
|
||||
waypoints[i].world_pos = pos
|
||||
update_hud = true
|
||||
need_update_hud = true
|
||||
update_formspec = true
|
||||
end
|
||||
|
||||
|
||||
if fields["rename_waypoint"..i] then
|
||||
waypoints[i].edit = true
|
||||
hit = true
|
||||
waypoints[i] = waypoints[i] or {}
|
||||
temp[i].edit = true
|
||||
update_formspec = true
|
||||
end
|
||||
|
||||
if fields["toggle_display_pos"..i] then
|
||||
hit = true
|
||||
waypoints[i] = waypoints[i] or {}
|
||||
waypoints[i].display_pos = not waypoints[i].display_pos
|
||||
update_hud = true
|
||||
need_update_hud = true
|
||||
update_formspec = true
|
||||
end
|
||||
|
||||
if fields["toggle_color"..i] then
|
||||
local color = waypoints[i].color
|
||||
hit = true
|
||||
waypoints[i] = waypoints[i] or {}
|
||||
local color = waypoints[i].color or 1
|
||||
color = color + 1
|
||||
if color > unified_inventory.hud_colors_max then
|
||||
if color > hud_colors_max then
|
||||
color = 1
|
||||
end
|
||||
waypoints[i].color = color
|
||||
update_hud = true
|
||||
need_update_hud = true
|
||||
update_formspec = true
|
||||
end
|
||||
|
||||
if fields["confirm_rename"..i] then
|
||||
waypoints[i].edit = false
|
||||
waypoints[i].name = fields["rename_box"..i]
|
||||
update_hud = true
|
||||
hit = true
|
||||
waypoints[i] = waypoints[i] or {}
|
||||
temp[i].edit = false
|
||||
waypoints[i].name = fields["rename_box"..i]
|
||||
need_update_hud = true
|
||||
update_formspec = true
|
||||
end
|
||||
|
||||
if update_hud then
|
||||
unified_inventory.update_hud (player, waypoints[i])
|
||||
if need_update_hud then
|
||||
update_hud(player, waypoints, temp, i)
|
||||
end
|
||||
|
||||
if update_formspec then
|
||||
unified_inventory.set_inventory_formspec(player, "waypoints")
|
||||
end
|
||||
|
||||
if hit then return end
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local waypoints = datastorage.get_container (player, "waypoints")
|
||||
local need_save = false
|
||||
-- Create new waypoints data
|
||||
for i = 1, 5, 1 do
|
||||
if waypoints[i] == nil then
|
||||
need_save = true
|
||||
waypoints[i] = {
|
||||
edit = false,
|
||||
active = false,
|
||||
display_pos = true,
|
||||
color = 1,
|
||||
name = "Waypoint ".. i,
|
||||
world_pos = {x = 0, y = 0, z = 0},
|
||||
}
|
||||
end
|
||||
end
|
||||
if need_save then datastorage.save_container (player) end
|
||||
|
||||
-- Initialize waypoints
|
||||
minetest.after(0.5, function()
|
||||
waypoints.selected = 1
|
||||
for i = 1, 5, 1 do
|
||||
waypoints[i].edit = false
|
||||
unified_inventory.update_hud (player, waypoints[i])
|
||||
end
|
||||
end)
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local player_name = player:get_player_name()
|
||||
local waypoints = datastorage.get(player_name, "waypoints")
|
||||
local temp = {}
|
||||
waypoints_temp[player_name] = temp
|
||||
for i = 1, 5 do
|
||||
update_hud(player, waypoints, temp, i)
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
waypoints_temp[player:get_player_name()] = nil
|
||||
end)
|
||||
|
||||
|
|
|
@ -98,13 +98,13 @@ Display the volume of the current WorldEdit region.
|
|||
|
||||
//volume
|
||||
|
||||
### `//set <node>`
|
||||
### `//set <node1> ...`
|
||||
|
||||
Set the current WorldEdit region to `<node>`.
|
||||
Set the current WorldEdit region to a random mix of `<node1>`, `...`.
|
||||
|
||||
//set air
|
||||
//set cactus
|
||||
//set Bronze Block
|
||||
//set cactus stone glass
|
||||
//set Bronze
|
||||
//set mesecons:wire_00000000_off
|
||||
|
||||
### `//replace <search node> <replace node>`
|
||||
|
@ -219,6 +219,13 @@ Stack the current WorldEdit region along the x/y/z/? axis `<count>` times.
|
|||
//stack z +5
|
||||
//stack ? 12
|
||||
|
||||
### `//stack2 <count> <x> <y> <z>`
|
||||
|
||||
Stack the current WorldEdit region `<count>` times by offset `<x>`, `<y>`, `<z>`.
|
||||
|
||||
//stack2 5 3 8 2
|
||||
//stack2 1 -1 -1 -1
|
||||
|
||||
### `//scale <factor>`
|
||||
|
||||
Scale the current WorldEdit positions and region by a factor of positive integer `<factor>` with position 1 as the origin.
|
||||
|
|
|
@ -130,6 +130,21 @@ The WorldEdit Schematic format is accessed via the WorldEdit API, or WorldEdit s
|
|||
|
||||
The second is the Minetest Schematic format (MTS). The details of this format may be found in the Minetest documentation and are out of the scope of this document. Access to this format is done via specialized MTS commands such as `//mtschemcreate` and `//mtschemplace`.
|
||||
|
||||
Authors
|
||||
-------
|
||||
WorldEdit would not be possible without the contributions of many developers and designers. Below, they are listed alphabetically:
|
||||
|
||||
cheapie
|
||||
cornernote
|
||||
cyisfor
|
||||
electricface
|
||||
kaeza
|
||||
khonkhortisan
|
||||
sfan5
|
||||
ShadowNinja
|
||||
spillz
|
||||
Uberi/Temperest
|
||||
|
||||
License
|
||||
-------
|
||||
Copyright 2013 sfan5, Anthony Zhang (Uberi/Temperest), and Brett O'Donnell (cornernote).
|
||||
|
|
|
@ -57,6 +57,12 @@ Duplicates the region defined by positions `pos1` and `pos2` along the `axis` ax
|
|||
|
||||
Returns the number of nodes stacked.
|
||||
|
||||
### count = worldedit.stack2(pos1, pos2, direction, amount)
|
||||
|
||||
Duplicates the region defined by positions `pos1` and `pos2` `amount` times with offset vector `direction`.
|
||||
|
||||
Returns the number of nodes stacked.
|
||||
|
||||
### count, newpos1, newpos2 = worldedit.stretch(pos1, pos2, stretchx, stretchy, stretchz)
|
||||
|
||||
Stretches the region defined by positions `pos1` and `pos2` by an factor of positive integers `stretchx`, `stretchy`. and `stretchz` along the X, Y, and Z axes, respectively, with `pos1` as the origin.
|
||||
|
|
|
@ -24,7 +24,11 @@ worldedit.volume = function(pos1, pos2)
|
|||
end
|
||||
|
||||
--sets a region defined by positions `pos1` and `pos2` to `nodename`, returning the number of nodes filled
|
||||
worldedit.set = function(pos1, pos2, nodename)
|
||||
worldedit.set = function(pos1, pos2, nodenames)
|
||||
if type(nodenames) == 'string' then
|
||||
nodenames = {nodenames}
|
||||
end
|
||||
|
||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
--set up voxel manipulator
|
||||
|
@ -40,9 +44,20 @@ worldedit.set = function(pos1, pos2, nodename)
|
|||
end
|
||||
|
||||
--fill selected area with node
|
||||
local node_id = minetest.get_content_id(nodename)
|
||||
for i in area:iterp(pos1, pos2) do
|
||||
nodes[i] = node_id
|
||||
local node_ids = {}
|
||||
for i,v in ipairs(nodenames) do
|
||||
node_ids[i] = minetest.get_content_id(nodenames[i])
|
||||
end
|
||||
if #node_ids == 1 then --only one type of node
|
||||
local id = node_ids[1]
|
||||
for i in area:iterp(pos1, pos2) do
|
||||
nodes[i] = node_ids[id]
|
||||
end
|
||||
else --fill randomly with all types of specified nodes
|
||||
local id_count, rand = #node_ids, math.random
|
||||
for i in area:iterp(pos1, pos2) do
|
||||
nodes[i] = node_ids[rand(id_count)]
|
||||
end
|
||||
end
|
||||
|
||||
--update map nodes
|
||||
|
@ -109,6 +124,7 @@ worldedit.replaceinverse = function(pos1, pos2, searchnode, replacenode)
|
|||
return count
|
||||
end
|
||||
|
||||
--copies the region defined by positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z") by `amount` nodes, returning the number of nodes copied
|
||||
worldedit.copy = function(pos1, pos2, axis, amount) --wip: replace the old version below
|
||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
||||
|
@ -165,6 +181,130 @@ worldedit.copy = function(pos1, pos2, axis, amount) --wip: replace the old versi
|
|||
return worldedit.volume(pos1, pos2)
|
||||
end
|
||||
|
||||
worldedit.copy2 = function(pos1, pos2, direction, volume)
|
||||
-- the overlap shouldn't matter as long as we
|
||||
-- 1) start at the furthest separated corner
|
||||
-- 2) complete an edge before moving inward, either edge works
|
||||
-- 3) complete a face before moving inward, similarly
|
||||
--
|
||||
-- to do this I
|
||||
-- 1) find the furthest destination in the direction, of each axis
|
||||
-- 2) call those the furthest separated corner
|
||||
-- 3) make sure to iterate inward from there
|
||||
-- 4) nested loop to make sure complete edge, complete face, then complete cube.
|
||||
|
||||
local get_node, get_meta, add_node = minetest.get_node, minetest.get_meta, minetest.add_node
|
||||
local somemeta = get_meta(pos1) -- hax lol
|
||||
local to_table = somemeta.to_table
|
||||
local from_table = somemeta.from_table
|
||||
somemeta = nil
|
||||
|
||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
local manip = minetest.get_voxel_manip()
|
||||
manip:read_from_map(pos1, pos2)
|
||||
|
||||
local sx, sy, sz -- direction sign
|
||||
local ix, iy, iz -- initial destination
|
||||
local ex, ey, ez -- final destination
|
||||
local originalx, originaly, originalz -- source
|
||||
-- vim -> :'<,'>s/\<\([ioes]\?\)x\>/\1y/g
|
||||
if direction.x > 0 then
|
||||
originalx = pos2.x
|
||||
ix = originalx + direction.x
|
||||
ex = pos1.x + direction.x
|
||||
sx = -1
|
||||
elseif direction.x < 0 then
|
||||
originalx = pos1.x
|
||||
ix = originalx + direction.x
|
||||
ex = pos2.x + direction.x
|
||||
sx = 1
|
||||
else
|
||||
originalx = pos1.x
|
||||
ix = originalx -- whatever
|
||||
ex = pos2.x
|
||||
sx = 1
|
||||
end
|
||||
|
||||
if direction.y > 0 then
|
||||
originaly = pos2.y
|
||||
iy = originaly + direction.y
|
||||
ey = pos1.y + direction.y
|
||||
sy = -1
|
||||
elseif direction.y < 0 then
|
||||
originaly = pos1.y
|
||||
iy = originaly + direction.y
|
||||
ey = pos2.y + direction.y
|
||||
sy = 1
|
||||
else
|
||||
originaly = pos1.y
|
||||
iy = originaly -- whatever
|
||||
ey = pos2.y
|
||||
sy = 1
|
||||
end
|
||||
|
||||
if direction.z > 0 then
|
||||
originalz = pos2.z
|
||||
iz = originalz + direction.z
|
||||
ez = pos1.z + direction.z
|
||||
sz = -1
|
||||
elseif direction.z < 0 then
|
||||
originalz = pos1.z
|
||||
iz = originalz + direction.z
|
||||
ez = pos2.z + direction.z
|
||||
sz = 1
|
||||
else
|
||||
originalz = pos1.z
|
||||
iz = originalz -- whatever
|
||||
ez = pos2.z
|
||||
sz = 1
|
||||
end
|
||||
-- print('copy',originalx,ix,ex,sx,originaly,iy,ey,sy,originalz,iz,ez,sz)
|
||||
|
||||
local ox,oy,oz
|
||||
|
||||
ox = originalx
|
||||
for x = ix, ex, sx do
|
||||
oy = originaly
|
||||
for y = iy, ey, sy do
|
||||
oz = originalz
|
||||
for z = iz, ez, sz do
|
||||
-- reusing pos1/pos2 as source/dest here
|
||||
pos1.x, pos1.y, pos1.z = ox, oy, oz
|
||||
pos2.x, pos2.y, pos2.z = x, y, z
|
||||
local node = get_node(pos1)
|
||||
local meta = to_table(get_meta(pos1)) --get meta of current node
|
||||
add_node(pos2,node)
|
||||
from_table(get_meta(pos2),meta)
|
||||
oz = oz + sz
|
||||
end
|
||||
oy = oy + sy
|
||||
end
|
||||
ox = ox + sx
|
||||
end
|
||||
end
|
||||
|
||||
--duplicates the region defined by positions `pos1` and `pos2` `amount` times with offset vector `direction`, returning the number of nodes stacked
|
||||
worldedit.stack2 = function(pos1, pos2, direction, amount, finished)
|
||||
local i = 0
|
||||
local translated = {x=0,y=0,z=0}
|
||||
local function nextone()
|
||||
if i <= amount then
|
||||
i = i + 1
|
||||
translated.x = translated.x + direction.x
|
||||
translated.y = translated.y + direction.y
|
||||
translated.z = translated.z + direction.z
|
||||
worldedit.copy2(pos1, pos2, translated, volume)
|
||||
minetest.after(0, nextone)
|
||||
else
|
||||
if finished then
|
||||
finished()
|
||||
end
|
||||
end
|
||||
end
|
||||
nextone()
|
||||
return worldedit.volume(pos1, pos2) * amount
|
||||
end
|
||||
|
||||
--copies the region defined by positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z") by `amount` nodes, returning the number of nodes copied
|
||||
worldedit.copy = function(pos1, pos2, axis, amount)
|
||||
local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
|
||||
|
|
|
@ -278,22 +278,25 @@ minetest.register_chatcommand("/volume", {
|
|||
end,
|
||||
})
|
||||
|
||||
local check_set = function(name, param)
|
||||
local node = get_node(name, param)
|
||||
if not node then return nil end
|
||||
return check_region(name, param)
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("/set", {
|
||||
params = "<node>",
|
||||
description = "Set the current WorldEdit region to <node>",
|
||||
params = "<node1> ...",
|
||||
description = "Set the current WorldEdit region to a random mix of <node1>, ...",
|
||||
privs = {worldedit=true},
|
||||
func = safe_region(function(name, param)
|
||||
local nodes = {}
|
||||
for nodename in param:gmatch("[^%s]+") do
|
||||
local node = get_node(name, nodename)
|
||||
if not node then
|
||||
worldedit.player_notify(name, "Could not identify node \"" .. name .. "\"")
|
||||
return
|
||||
end
|
||||
nodes[#nodes + 1] = node
|
||||
end
|
||||
|
||||
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
|
||||
local node = get_node(name, param)
|
||||
local count = worldedit.set(pos1, pos2, node)
|
||||
local count = worldedit.set(pos1, pos2, nodes)
|
||||
worldedit.player_notify(name, count .. " nodes set")
|
||||
end, check_set),
|
||||
end, check_region),
|
||||
})
|
||||
|
||||
local check_replace = function(name, param)
|
||||
|
@ -615,6 +618,42 @@ minetest.register_chatcommand("/stack", {
|
|||
end),
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("/stack2", {
|
||||
params = "<count> <x> <y> <z>",
|
||||
description = "Stack the current WorldEdit region <count> times by offset <x>, <y>, <z>",
|
||||
privs = {worldedit=true},
|
||||
func = function(name, param)
|
||||
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
|
||||
if pos1 == nil or pos2 == nil then
|
||||
worldedit.player_notify(name, "Select a position first!")
|
||||
return
|
||||
end
|
||||
local repetitions, incs = param:match("(%d+)%s*(.+)")
|
||||
if repetitions == nil then
|
||||
worldedit.player_notify(name, "invalid count: " .. param)
|
||||
return
|
||||
end
|
||||
repetitions = tonumber(repetitions)
|
||||
|
||||
local x, y, z = incs:match("([+-]?%d+) ([+-]%d+) ([+-]%d+)")
|
||||
if x == nil then
|
||||
worldedit.player_notify(name, "invalid increments: " .. param)
|
||||
return
|
||||
end
|
||||
x, y, z = tonumber(x), tonumber(y), tonumber(z)
|
||||
|
||||
local count = worldedit.volume(pos1, pos2) * repetitions
|
||||
|
||||
return safe_region(function()
|
||||
worldedit.stack2(pos1, pos2, {x=x, y=y, z=z}, repetitions,
|
||||
function() worldedit.player_notify(name, count .. " nodes stacked") end)
|
||||
end, function()
|
||||
return count
|
||||
end)(name,param) -- more hax
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
minetest.register_chatcommand("/stretch", {
|
||||
params = "<stretchx> <stretchy> <stretchz>",
|
||||
description = "Scale the current WorldEdit positions and region by a factor of <stretchx>, <stretchy>, <stretchz> along the X, Y, and Z axes, repectively, with position 1 as the origin",
|
||||
|
|