make default optional

rename sound files and various things
autocrafter: apply latest pipeworks update
init: split in two (common.lua)
This commit is contained in:
waxtatect 2023-08-01 18:38:56 +02:00
parent 3b852c46ba
commit 7f1f6ce7c3
31 changed files with 546 additions and 455 deletions

View File

@ -127,16 +127,44 @@ basic_machines.change_autocrafter_recipe = on_output_change
local function autocraft(inventory, craft)
if not craft then return end
local output_item = craft.output.item
-- check if we have enough room in dst
if not inventory:room_for_item("dst", output_item) then return end
local consumption = craft.consumption
local inv_index = count_index(inventory:get_list("src"))
-- check if we have enough material available
local inv_items = count_index(inventory:get_list("src"))
for itemname, number in pairs(consumption) do
if (not inv_index[itemname]) or inv_index[itemname] < number then return end
local itemcount = inv_items[itemname]
if not itemcount or itemcount < number then return end
end
local output = craft.output.item
local decremented_input_items = craft.decremented_input.items
-- check if output and all replacements fit in dst
local out_items = count_index(decremented_input_items)
local output_name = output:get_name()
out_items[output_name] = (out_items[output_name] or 0) + output:get_count()
local empty_count = 0
for _, item in pairs(inventory:get_list("dst")) do
if item:is_empty() then
empty_count = empty_count + 1
else
local name = item:get_name()
if out_items[name] then
out_items[name] = out_items[name] - item:get_free_space()
end
end
end
for _, count in pairs(out_items) do
if count > 0 then
empty_count = empty_count - 1
end
end
if empty_count < 0 then return end
-- consume material
for itemname, number in pairs(consumption) do
for _ = 1, number do -- we have to do that since remove_item does not work if count > stack_max
@ -145,11 +173,10 @@ local function autocraft(inventory, craft)
end
-- craft the result into the dst inventory and add any "replacements" as well
inventory:add_item("dst", output_item)
inventory:add_item("dst", output)
for i = 1, 9 do
inventory:add_item("dst", craft.decremented_input.items[i])
inventory:add_item("dst", decremented_input_items[i])
end
return
end
minetest.register_node("basic_machines:autocrafter", {
@ -157,7 +184,7 @@ minetest.register_node("basic_machines:autocrafter", {
groups = {cracky = 3},
drawtype = "normal",
tiles = {"basic_machines_autocrafter.png"},
sounds = default.node_sound_wood_defaults(),
sounds = basic_machines.sound_node_machine(),
on_destruct = function(pos)
autocrafterCache[minetest.hash_node_position(pos)] = nil
@ -283,7 +310,7 @@ minetest.register_node("basic_machines:autocrafter", {
}
})
if basic_machines.settings.register_crafts then
if basic_machines.settings.register_crafts and basic_machines.use_default then
minetest.register_craft({
output = "basic_machines:autocrafter",
recipe = {

View File

@ -14,17 +14,32 @@ local max_range = basic_machines.properties.max_range
local max_damage = minetest.PLAYER_MAX_HP_DEFAULT / 4 -- player health 20
-- to be used with bounce setting 2 in ball spawner:
-- 1: bounce in x direction, 2: bounce in z direction, otherwise it bounces in y direction
local bounce_materials = {
["default:glass"] = 2, ["default:wood"] = 1
}
local bounce_materials = {}
local bounce_materials_help, axis = {S(", and for the next blocks:")}, {"x", "z"}
local function add_bounce_material(name, direction)
bounce_materials[name] = direction
bounce_materials_help[#bounce_materials_help + 1] = ("%s: %s"):format(name, axis[direction])
end
if minetest.get_modpath("darkage") then
bounce_materials["darkage:iron_bars"] = 1
add_bounce_material("darkage:iron_bars", 1)
end
if basic_machines.use_default then
add_bounce_material("default:glass", 2)
add_bounce_material("default:wood", 1)
end
if minetest.get_modpath("xpanes") then
bounce_materials["xpanes:bar_10"] = 1
bounce_materials["xpanes:bar_2"] = 1
add_bounce_material("xpanes:bar_2", 1)
add_bounce_material("xpanes:bar_10", 1)
end
if #bounce_materials_help > 1 then
bounce_materials_help = table.concat(bounce_materials_help, "\n")
else
bounce_materials_help = ""
end
local ball_default = {
@ -205,7 +220,7 @@ minetest.register_entity("basic_machines:ball", {
self.object:set_pos(new_pos) -- ball placed a bit further away from box
self.object:set_velocity(v)
minetest.sound_play("default_dig_cracky", {pos = pos, gain = 1, max_hear_distance = 8}, true)
minetest.sound_play(basic_machines.sound_ball_bounce, {pos = pos, gain = 1, max_hear_distance = 8}, true)
else
self.object:remove(); return
end
@ -304,14 +319,6 @@ local function ball_spawner_update_form(meta)
"]button[2.75,5.5;1,0.8;help;" .. F(S("help")) .. "]button_exit[4,5.5;1,0.8;OK;" .. F(S("OK")) .. "]")
end
-- to be used with bounce setting 2 in ball spawner:
-- 1: bounce in x direction, 2: bounce in z direction, otherwise it bounces in y direction
local bounce_materialslist, dirs, i = {}, {"x", "z"}, 1
for material, v in pairs(bounce_materials) do
bounce_materialslist[i] = ("%s: %s"):format(material, dirs[v]); i = i + 1
end
bounce_materialslist = table.concat(bounce_materialslist, "\n")
minetest.register_node("basic_machines:ball_spawner", {
description = S("Ball Spawner"),
groups = {cracky = 3, oddly_breakable_by_hand = 1},
@ -321,7 +328,7 @@ minetest.register_node("basic_machines:ball_spawner", {
paramtype = "light",
param1 = 1,
walkable = false,
sounds = default.node_sound_wood_defaults(),
sounds = basic_machines.sound_node_machine(),
drop = "",
after_place_node = function(pos, placer)
@ -479,14 +486,13 @@ Visual*: "cube" or "sprite"
*: Not available as individual Ball Spawner
**: Set to 2, the ball bounce following y direction and for the next blocks:
@9
**: Set to 2, the ball bounces following y direction@9
***: 0: not punchable, 1: only in protected area, 2: everywhere
Note: Hold sneak while digging to get the Ball Spawner
]], max_range, max_range, max_range, max_range, max_range, max_range,
max_damage, lifetime, bounce_materialslist)) .. "]")
max_damage, lifetime, bounce_materials_help)) .. "]")
end
end,
@ -509,7 +515,7 @@ max_damage, lifetime, bounce_materialslist)) .. "]")
meta:set_int("t", t1); meta:set_int("T", T)
if T > 2 then -- overheat
minetest.sound_play("default_cool_lava", {pos = pos, max_hear_distance = 16, gain = 0.25}, true)
minetest.sound_play(basic_machines.sound_overheat, {pos = pos, max_hear_distance = 16, gain = 0.25}, true)
meta:set_string("infotext", S("Overheat! Temperature: @1", T))
return
end
@ -615,7 +621,7 @@ max_damage, lifetime, bounce_materialslist)) .. "]")
meta:set_int("t", t1); meta:set_int("T", T)
if T > 2 then -- overheat
minetest.sound_play("default_cool_lava", {pos = pos, max_hear_distance = 16, gain = 0.25}, true)
minetest.sound_play(basic_machines.sound_overheat, {pos = pos, max_hear_distance = 16, gain = 0.25}, true)
meta:set_string("infotext", S("Overheat! Temperature: @1", T))
return
end

View File

@ -31,7 +31,7 @@ minetest.register_node("basic_machines:clockgen", {
description = S("Clock Generator"),
groups = {cracky = 3},
tiles = {"basic_machines_clock_generator.png"},
sounds = default.node_sound_wood_defaults(),
sounds = basic_machines.sound_node_machine(),
after_place_node = function(pos, placer)
if not placer then return end
@ -57,7 +57,7 @@ minetest.register_node("basic_machines:clockgen", {
end
})
if basic_machines.settings.register_crafts then
if basic_machines.settings.register_crafts and basic_machines.use_default then
minetest.register_craft({
output = "basic_machines:clockgen",
recipe = {

183
common.lua Normal file
View File

@ -0,0 +1,183 @@
basic_machines = {
F = minetest.formspec_escape,
S = minetest.get_translator("basic_machines"),
version = "10/02/2021a custom",
properties = {
no_clock = false, -- if true all continuously running activities (clockgen/keypad) are disabled
machines_TTL = 16, -- time to live for signals, how many hops before signal dissipates
machines_minstep = 1, -- minimal allowed activation timestep, if faster machines overheat
machines_operations = 10, -- 1 coal will provide 10 mover basic operations (moving dirt 1 block distance)
machines_timer = 5, -- main timestep
max_range = 10, -- machines normal range of operation
mover_upgrade_max = 10 -- upgrade mover to increase range and to reduce fuel consumption
},
settings = { -- can be added to server configuration file, example: basic_machines_energy_multiplier = 1
-- ball spawner
max_balls = 2, -- balls count limit per player, minimum 0
-- crystals
energy_multiplier = 1, -- energy crystals multiplier
power_stackmax = 25, -- power crystals stack max
-- grinder
grinder_register_dusts = true, -- dusts/extractors for lumps/ingots, needed for the others grinder settings
grinder_dusts_quantity = 2, -- quantity of dusts produced by lump/ingot, minimum 0
grinder_dusts_legacy = false, -- legacy dust mode: dust_33 (smelt) -> dust_66 (smelt) -> ingot
grinder_extractors_type = 1, -- recipe priority if optional mod present, 1: farming_redo, 2: x_farming
-- mover
mover_add_removed_items = false, -- always add the removed items in normal mode with target chest
mover_no_large_stacks = false, -- limit the stack count to its max in normal, drop and inventory mode
mover_max_temp = 176, -- overheat above this temperature, minimum 1
-- technic_power
generator_upgrade = 0, -- upgrade available in addition to the current limit (50)
-- space
space_start_eff = 1500, -- space efficiency height
space_start = 1100, -- space height, set to false to disable
space_textures = "", -- skybox space textures replacement with up to 6 texture names separated by commas
exclusion_height = 6666, -- above, without "include" priv, player is teleported to a random location
space_effects = false, -- enable damage mechanism
--
register_crafts = false -- machines crafts recipes
},
-- form
get_form_player_inventory = function(x, y, w, h, s)
local player_inv = {
("list[current_player;main;%g,%g;%i,1]"):format(x, y, w),
("list[current_player;main;%g,%g;%i,%i;%i]"):format(x, y + 1.4, w, h - 1, w)
}
for i = 0 , w - 1 do
player_inv[i + 3] = ("image[%g,%g;1,1;[combine:1x1^[noalpha^[colorize:black^[opacity:43]"):format(x + (s + 1) * i, y)
end
return table.concat(player_inv)
end,
use_default = minetest.global_exists("default"), -- require minetest_game default mod
--[[ interfaces
-- autocrafter
change_autocrafter_recipe = function() end,
-- distributor
get_distributor_form = function() end,
-- enviro
player_sneak = nil, -- table used by optional mod player_monoids
-- grinder
get_grinder_recipes = function() end,
set_grinder_recipes = function() end,
-- keypad
use_keypad = function() end,
-- mover
add_mover_mode = function() end,
check_mover_filter = function() end,
check_mover_target = nil, -- function used with mover_no_large_stacks setting
check_palette_index = function() end,
clamp_item_count = nil, -- function used with mover_no_large_stacks setting
find_and_connect_battery = function() end,
get_distance = function() end,
get_mover = function() end,
get_mover_form = function() end,
get_palette_index = function() end,
itemstring_to_stack = function() end,
node_to_stack = function() end,
set_mover = function() end,
-- technic_power
check_power = function() end
--]]
}
-- read settings from configuration file
for k, v in pairs(basic_machines.settings) do
local setting = nil
if type(v) == "boolean" then
setting = minetest.settings:get_bool("basic_machines_" .. k)
elseif type(v) == "number" then
setting = tonumber(minetest.settings:get("basic_machines_" .. k))
elseif type(v) == "string" then
setting = minetest.settings:get("basic_machines_" .. k)
end
if setting ~= nil then
basic_machines.settings[k] = setting
end
end
-- creative check
local creative_cache = minetest.settings:get_bool("creative_mode")
basic_machines.creative = function(name)
return creative_cache or minetest.check_player_privs(name,
{creative = true})
end
-- result: float with precision up to two digits or integer number
local modf = math.modf
basic_machines.twodigits_float = function(number)
local r
if number ~= 0 then
local i, f = modf(number)
if f ~= 0 then r = i + ("%.2f"):format(f) else r = number end
else
r = 0
end
return r
end
if basic_machines.use_default then
basic_machines.sound_node_machine = default.node_sound_wood_defaults
basic_machines.sound_overheat = "default_cool_lava"
basic_machines.sound_ball_bounce = "default_dig_cracky"
else
basic_machines.sound_node_machine = function(sound_table) return sound_table end
end
local S = basic_machines.S
-- test: toggle machine running with clockgen/keypad repeats, useful for debugging
-- i.e. seeing how machines running affect server performance
minetest.register_chatcommand("clockgen", {
description = S("Toggle clock generator/keypad repeats"),
privs = {privs = true},
func = function(name, _)
basic_machines.properties.no_clock = not basic_machines.properties.no_clock
minetest.chat_send_player(name, S("No clock set to @1", tostring(basic_machines.properties.no_clock)))
end
})
-- "machines" privilege
minetest.register_privilege("machines", {
description = S("Player is expert basic_machines user: his machines work while not present on server," ..
" can spawn more than @1 balls at once", basic_machines.settings.max_balls),
give_to_singleplayer = false,
give_to_admin = false
})
-- unified_inventory "machines" category
if (basic_machines.settings.register_crafts or creative_cache) and
minetest.global_exists("unified_inventory") and
unified_inventory.registered_categories and
not unified_inventory.registered_categories["machines"]
then
unified_inventory.register_category("machines", {
symbol = "basic_machines:mover",
label = S("Machines and Components"),
items = {
"basic_machines:autocrafter",
"basic_machines:ball_spawner",
"basic_machines:battery_0",
"basic_machines:clockgen",
"basic_machines:constructor",
"basic_machines:detector",
"basic_machines:distributor",
"basic_machines:enviro",
"basic_machines:generator",
"basic_machines:grinder",
"basic_machines:keypad",
"basic_machines:light_on",
"basic_machines:mesecon_adapter",
"basic_machines:mover",
"basic_machines:recycler"
}
})
end
-- for translations script (inventory list names)
--[[
S("dst"); S("fuel"); S("main"); S("output");
S("recipe"); S("src"); S("upgrade")
--]]
-- COMPATIBILITY
minetest.register_alias("basic_machines:battery", "basic_machines:battery_0")

View File

@ -48,7 +48,7 @@ local function constructor_process(pos, constructor, name)
if craft then
local item = craft.item
local stack = ItemStack(item)
local def = stack:get_definition()
local def = minetest.registered_items[stack:get_name()]
if def then
local inv = meta:get_inventory()
@ -80,17 +80,16 @@ local function constructor_process(pos, constructor, name)
end
end
end
local function add_constructor(name, def)
craft_recipes[name] = def.craft_recipes
recipes_order[name] = def.recipes_order
recipes_order_translated[name] = table.concat(def.recipes_order_translated, ",")
local function add_constructor(name, items, description, recipe)
craft_recipes[name] = items.craft_recipes
recipes_order[name] = items.recipes_order
recipes_order_translated[name] = table.concat(items.recipes_order_translated, ",")
minetest.register_node(name, {
description = def.description,
description = description,
groups = {cracky = 3, constructor = 1},
tiles = {name:gsub(":", "_") .. ".png"},
sounds = default.node_sound_wood_defaults(),
sounds = basic_machines.sound_node_machine(),
after_place_node = function(pos, placer)
if not placer then return end
@ -100,7 +99,7 @@ local function add_constructor(name, def)
S("Constructor: to operate it insert materials, select item to make and click craft button"))
meta:set_string("owner", placer:get_player_name())
meta:set_string("craft", def.recipes_order[1])
meta:set_string("craft", items.recipes_order[1])
meta:set_int("selected", 1)
local inv = meta:get_inventory()
@ -167,21 +166,17 @@ local function add_constructor(name, def)
}
})
minetest.register_craft({
output = name,
recipe = def.recipe
})
if recipe then
minetest.register_craft({
output = name,
recipe = recipe
})
end
end
-- CONSTRUCTOR
local def = {
description = S("Constructor"),
recipe = {
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
{"default:steel_ingot", "default:copperblock", "default:steel_ingot"},
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"}
},
local items = {
craft_recipes = {
["Autocrafter"] = {
item = "basic_machines:autocrafter",
@ -306,13 +301,23 @@ local def = {
}
if minetest.global_exists("mesecon") then -- add mesecon adapter
def.craft_recipes["Mesecon Adapter"] = {
items.craft_recipes["Mesecon Adapter"] = {
item = "basic_machines:mesecon_adapter",
description = S("Interface between machines and mesecons"),
craft = {"default:mese_crystal_fragment"}
}
def.recipes_order[#def.recipes_order + 1] = "Mesecon Adapter"
def.recipes_order_translated[#def.recipes_order_translated + 1] = F(S("Mesecon Adapter"))
items.recipes_order[#items.recipes_order + 1] = "Mesecon Adapter"
items.recipes_order_translated[#items.recipes_order_translated + 1] = F(S("Mesecon Adapter"))
end
add_constructor("basic_machines:constructor", def)
local recipe
if basic_machines.use_default then
recipe = {
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
{"default:steel_ingot", "default:copperblock", "default:steel_ingot"},
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"}
}
end
add_constructor("basic_machines:constructor", items, S("Constructor"), recipe)

View File

@ -133,41 +133,43 @@ for _, trapdoor in ipairs(trapdoors) do
make_it_noclip(trapdoor .. "_open")
end
--[[
local function make_it_nondiggable_but_removable(name, dropname, door)
minetest.override_item(name, {
diggable = false,
on_punch = function(pos, _, puncher) -- remove node if owner repeatedly punches it 3x
local player_name = puncher:get_player_name()
local meta = minetest.get_meta(pos)
-- can be dug by owner or if unprotected
if player_name == meta:get_string("owner") or not minetest.is_protected(pos, player_name) then
local t0, t = meta:get_int("punchtime"), minetest.get_gametime()
local count = meta:get_int("punchcount")
if use_doors then
local function make_it_nondiggable_but_removable(name, dropname, door)
minetest.override_item(name, {
diggable = false,
on_punch = function(pos, _, puncher) -- remove node if owner repeatedly punches it 3x
local player_name = puncher:get_player_name()
local meta = minetest.get_meta(pos)
-- can be dug by owner or if unprotected
if player_name == meta:get_string("owner") or not minetest.is_protected(pos, player_name) then
local t0, t = meta:get_int("punchtime"), minetest.get_gametime()
local count = meta:get_int("punchcount")
if t - t0 < 2 then count = (count + 1) % 3 else count = 0 end
meta:set_int("punchtime", t); meta:set_int("punchcount", count)
if t - t0 < 2 then count = (count + 1) % 3 else count = 0 end
meta:set_int("punchtime", t); meta:set_int("punchcount", count)
if count == 1 then
minetest.chat_send_player(player_name, S("@1: Punch me one more time to remove me", door))
elseif count == 2 then -- remove steel door and drop it
minetest.set_node(pos, {name = "air"})
minetest.add_item(pos, ItemStack(dropname))
if count == 1 then
minetest.chat_send_player(player_name, S("@1: Punch me one more time to remove me", door))
elseif count == 2 then -- remove steel door and drop it
minetest.set_node(pos, {name = "air"})
minetest.add_item(pos, ItemStack(dropname))
end
end
end
end
})
end
})
end
local impervious_steel = {
{"doors:door_steel_a", "doors:door_steel", S("Steel Door")},
{"doors:door_steel_b", "doors:door_steel", S("Steel Door")},
{"doors:door_steel_c", "doors:door_steel", S("Steel Door")},
{"doors:door_steel_d", "doors:door_steel", S("Steel Door")},
{"doors:trapdoor_steel", "doors:trapdoor_steel", S("Steel Trapdoor")},
{"doors:trapdoor_steel_open", "doors:trapdoor_steel", S("Steel Trapdoor")}
}
local impervious_steel = {
{"doors:door_steel_a", "doors:door_steel", S("Steel Door")},
{"doors:door_steel_b", "doors:door_steel", S("Steel Door")},
{"doors:door_steel_c", "doors:door_steel", S("Steel Door")},
{"doors:door_steel_d", "doors:door_steel", S("Steel Door")},
{"doors:trapdoor_steel", "doors:trapdoor_steel", S("Steel Trapdoor")},
{"doors:trapdoor_steel_open", "doors:trapdoor_steel", S("Steel Trapdoor")}
}
for _, door in ipairs(impervious_steel) do
make_it_nondiggable_but_removable(door[1], door[2], door[3])
for _, door in ipairs(impervious_steel) do
make_it_nondiggable_but_removable(door[1], door[2], door[3])
end
end
--]]

View File

@ -30,19 +30,21 @@ local function enable_toggle_light(name)
end
-- lights
local lights = {
"default:mese_post_light",
"default:mese_post_light_acacia_wood",
"default:mese_post_light_aspen_wood",
"default:mese_post_light_junglewood",
"default:mese_post_light_pine_wood",
"default:meselamp"
}
local lights = {}
if minetest.get_modpath("darkage") then
table.insert(lights, "darkage:lamp")
end
if basic_machines.use_default then
table.insert(lights, "default:mese_post_light")
table.insert(lights, "default:mese_post_light_acacia_wood")
table.insert(lights, "default:mese_post_light_aspen_wood")
table.insert(lights, "default:mese_post_light_junglewood")
table.insert(lights, "default:mese_post_light_pine_wood")
table.insert(lights, "default:meselamp")
end
if minetest.global_exists("moreblocks") then
table.insert(lights, "moreblocks:slab_meselamp_1")
table.insert(lights, "moreblocks:slab_super_glow_glass")

View File

@ -1,11 +1,6 @@
if minetest.get_modpath("darkage") then
minetest.register_craft({
type = "cooking",
output = "darkage:basalt",
recipe = "default:stone",
cooktime = 60
})
local use_default = basic_machines.use_default
if minetest.get_modpath("darkage") then
minetest.register_craft({
type = "cooking",
output = "darkage:schist",
@ -21,27 +16,38 @@ if minetest.get_modpath("darkage") then
cooktime = 20
})
minetest.register_craft({
output = "darkage:serpentine",
recipe = {
{"darkage:marble", "default:cactus"}
}
})
if use_default then
minetest.register_craft({
type = "cooking",
output = "darkage:basalt",
recipe = "default:stone",
cooktime = 60
})
minetest.register_craft({
output = "darkage:mud",
recipe = {
{"default:dirt", "default:water_flowing"}
}
})
minetest.register_craft({
output = "darkage:serpentine",
recipe = {
{"darkage:marble", "default:cactus"}
}
})
minetest.register_craft({
output = "darkage:mud",
recipe = {
{"default:dirt", "default:water_flowing"}
}
})
end
end
minetest.register_craft({
type = "cooking",
output = "default:water_flowing",
recipe = "default:ice",
cooktime = 4
})
if use_default then
minetest.register_craft({
type = "cooking",
output = "default:water_flowing",
recipe = "default:ice",
cooktime = 4
})
end
-- CHARCOAL
minetest.register_craftitem("basic_machines:charcoal", {
@ -57,13 +63,15 @@ minetest.register_craft({
cooktime = 30
})
minetest.register_craft({
output = "default:coal_lump",
recipe = {
{"basic_machines:charcoal"},
{"basic_machines:charcoal"}
}
})
if use_default then
minetest.register_craft({
output = "default:coal_lump",
recipe = {
{"basic_machines:charcoal"},
{"basic_machines:charcoal"}
}
})
end
minetest.register_craft({
type = "fuel",

View File

@ -11,7 +11,7 @@ minetest.register_node("basic_machines:detector", {
description = S("Detector"),
groups = {cracky = 3},
tiles = {"basic_machines_detector.png"},
sounds = default.node_sound_wood_defaults(),
sounds = basic_machines.sound_node_machine(),
after_place_node = function(pos, placer)
if not placer then return end
@ -112,7 +112,7 @@ minetest.register_node("basic_machines:detector", {
meta:set_int("t", t1); meta:set_int("T", T)
if T > 2 then -- overheat
minetest.sound_play("default_cool_lava", {pos = pos, max_hear_distance = 16, gain = 0.25}, true)
minetest.sound_play(basic_machines.sound_overheat, {pos = pos, max_hear_distance = 16, gain = 0.25}, true)
meta:set_string("infotext", S("Overheat! Temperature: @1", T))
return
end
@ -282,7 +282,7 @@ minetest.register_node("basic_machines:detector", {
}
})
if basic_machines.settings.register_crafts then
if basic_machines.settings.register_crafts and basic_machines.use_default then
minetest.register_craft({
output = "basic_machines:detector",
recipe = {

View File

@ -53,7 +53,7 @@ minetest.register_node("basic_machines:distributor", {
description = S("Distributor"),
groups = {cracky = 3},
tiles = {"basic_machines_distributor.png"},
sounds = default.node_sound_wood_defaults(),
sounds = basic_machines.sound_node_machine(),
on_secondary_use = function(_, user)
if user then
@ -116,7 +116,7 @@ minetest.register_node("basic_machines:distributor", {
meta:set_int("t", t1); meta:set_int("T", T)
if T > 2 then -- overheat
minetest.sound_play("default_cool_lava", {pos = pos, max_hear_distance = 16, gain = 0.25}, true)
minetest.sound_play(basic_machines.sound_overheat, {pos = pos, max_hear_distance = 16, gain = 0.25}, true)
meta:set_string("infotext", S("Overheat! Temperature: @1", T))
return
end
@ -180,7 +180,7 @@ minetest.register_node("basic_machines:distributor", {
meta:set_int("t", t1); meta:set_int("T", T)
if T > 2 then -- overheat
minetest.sound_play("default_cool_lava", {pos = pos, max_hear_distance = 16, gain = 0.25}, true)
minetest.sound_play(basic_machines.sound_overheat, {pos = pos, max_hear_distance = 16, gain = 0.25}, true)
meta:set_string("infotext", S("Overheat! Temperature: @1", T))
return
end
@ -213,7 +213,7 @@ minetest.register_node("basic_machines:distributor", {
}
})
if basic_machines.settings.register_crafts then
if basic_machines.settings.register_crafts and basic_machines.use_default then
minetest.register_craft({
output = "basic_machines:distributor",
recipe = {

View File

@ -87,7 +87,7 @@ minetest.register_node("basic_machines:enviro", {
drawtype = "allfaces",
paramtype = "light",
param1 = 1,
sounds = default.node_sound_wood_defaults(),
sounds = basic_machines.sound_node_machine(),
after_place_node = function(pos, placer)
if not placer then return end

View File

@ -6,10 +6,11 @@ local machines_minstep = basic_machines.properties.machines_minstep
local twodigits_float = basic_machines.twodigits_float
local use_unified_inventory = minetest.global_exists("unified_inventory")
local use_i3 = minetest.global_exists("i3")
local use_default = basic_machines.use_default
-- grinder recipes:
-- ["in"] = {fuel cost, "out", quantity of material produced, quantity of material required for processing}
local grinder_recipes = {}
local grinder_recipes_translated, grinder_recipes_help = {S("Recipes:\n")}, nil
local grinder_recipes_translated, grinder_recipes_help = {S("\nRecipes:\n")}, nil
if use_unified_inventory then
unified_inventory.register_craft_type("basic_machines_grinding", {
@ -91,19 +92,24 @@ basic_machines.set_grinder_recipes = function(recipes)
end
end
-- default
register_recipe("default:cobble", {1, "default:gravel", 1, 1})
register_recipe("default:desert_stone", {2, "default:desert_sand", 4, 1})
register_recipe("default:dirt", {0.5, "default:clay_lump", 4, 1})
register_recipe("default:gravel", {0.5, "default:dirt", 1, 1})
register_recipe("default:ice", {1, "default:snow", 4, 1})
register_recipe("default:obsidian_shard", {199, "default:lava_source", 1, 1})
register_recipe("default:stone", {2, "default:sand", 1, 1})
if minetest.get_modpath("darkage") then
register_recipe("darkage:silt_lump", {1, "darkage:chalk_powder", 1, 1})
end
if use_default then
register_recipe("default:cobble", {1, "default:gravel", 1, 1})
register_recipe("default:desert_stone", {2, "default:desert_sand", 4, 1})
register_recipe("default:dirt", {0.5, "default:clay_lump", 4, 1})
register_recipe("default:gravel", {0.5, "default:dirt", 1, 1})
register_recipe("default:ice", {1, "default:snow", 4, 1})
register_recipe("default:obsidian_shard", {199, "default:lava_source", 1, 1})
register_recipe("default:stone", {2, "default:sand", 1, 1})
if minetest.get_modpath("gloopblocks") then
register_recipe("gloopblocks:basalt", {1, "default:cobble", 1, 1})
end
end
if minetest.global_exists("es") then
register_recipe("es:aikerum_crystal", {16, "es:aikerum_dust", 2, 1})
register_recipe("es:emerald_crystal", {16, "es:emerald_dust", 2, 1})
@ -111,10 +117,6 @@ if minetest.global_exists("es") then
register_recipe("es:ruby_crystal", {16, "es:ruby_dust", 2, 1})
end
if minetest.get_modpath("gloopblocks") then
register_recipe("gloopblocks:basalt", {1, "default:cobble", 1, 1})
end
if basic_machines.settings.grinder_register_dusts then
local farming_table, farming_mod = {}, nil
if minetest.global_exists("farming") and farming.mod == "redo" then
@ -154,18 +156,20 @@ if basic_machines.settings.grinder_register_dusts then
local moreores_tin_lump_present = minetest.registered_items["moreores:tin_lump"]
for i, purity in ipairs(purity_table) do
register_dust("basic_machines:iron_dust_" .. purity,
S("Iron Dust (purity @1%)", purity), "999999", purity)
register_dust("basic_machines:copper_dust_" .. purity,
S("Copper Dust (purity @1%)", purity), "C8800D", purity)
register_dust("basic_machines:tin_dust_" .. purity,
S("Tin Dust (purity @1%)", purity), "9F9F9F", purity)
register_dust("basic_machines:gold_dust_" .. purity,
S("Gold Dust (purity @1%)", purity), "FFFF00", purity)
register_dust("basic_machines:mese_dust_" .. purity,
S("Mese Dust (purity @1%)", purity), "CCCC00", purity)
register_dust("basic_machines:diamond_dust_" .. purity,
S("Diamond Dust (purity @1%)", purity), "00EEFF", purity, light_source[1][i])
if use_default then
register_dust("basic_machines:iron_dust_" .. purity,
S("Iron Dust (purity @1%)", purity), "999999", purity)
register_dust("basic_machines:copper_dust_" .. purity,
S("Copper Dust (purity @1%)", purity), "C8800D", purity)
register_dust("basic_machines:tin_dust_" .. purity,
S("Tin Dust (purity @1%)", purity), "9F9F9F", purity)
register_dust("basic_machines:gold_dust_" .. purity,
S("Gold Dust (purity @1%)", purity), "FFFF00", purity)
register_dust("basic_machines:mese_dust_" .. purity,
S("Mese Dust (purity @1%)", purity), "CCCC00", purity)
register_dust("basic_machines:diamond_dust_" .. purity,
S("Diamond Dust (purity @1%)", purity), "00EEFF", purity, light_source[1][i])
end
if moreores_tin_lump_present then -- are moreores (tin, silver, mithril) present ?
-- register_dust("basic_machines:tin_dust_" .. purity,
@ -203,12 +207,14 @@ if basic_machines.settings.grinder_register_dusts then
end
end
register_dust_recipe("iron", "default:iron_lump", 4, "default:steel_ingot", 8)
register_dust_recipe("copper", "default:copper_lump", 4, "default:copper_ingot", 8)
register_dust_recipe("tin", "default:tin_lump", 4, "default:tin_ingot", 8)
register_dust_recipe("gold", "default:gold_lump", 6, "default:gold_ingot", 25)
register_dust_recipe("mese", "default:mese_crystal", 8, nil, 250)
register_dust_recipe("diamond", "default:diamond", 16, nil, 500) -- 0.3hr cooking time to make diamond!
if use_default then
register_dust_recipe("iron", "default:iron_lump", 4, "default:steel_ingot", 8)
register_dust_recipe("copper", "default:copper_lump", 4, "default:copper_ingot", 8)
register_dust_recipe("tin", "default:tin_lump", 4, "default:tin_ingot", 8)
register_dust_recipe("gold", "default:gold_lump", 6, "default:gold_ingot", 25)
register_dust_recipe("mese", "default:mese_crystal", 8, nil, 250)
register_dust_recipe("diamond", "default:diamond", 16, nil, 500) -- 0.3hr cooking time to make diamond!
end
if moreores_tin_lump_present then
-- register_dust_recipe("tin", "moreores:tin_lump", 4, "moreores:tin_ingot", 8)
@ -241,27 +247,29 @@ if basic_machines.settings.grinder_register_dusts then
})
end
local recipe = {}
if use_default then
local recipe = {}
if farming_mod == "farming_redo" then
recipe.tin = {"farming:cocoa_beans", "farming:cocoa_beans", "basic_machines:tin_dust_00"}
recipe.mese = {"farming:rhubarb", "farming:rhubarb", "basic_machines:mese_dust_00"}
elseif farming_mod == "x_farming" then
recipe.tin = {"x_farming:salt", "x_farming:salt", "basic_machines:tin_dust_00"}
recipe.mese = {"x_farming:strawberry", "x_farming:strawberry", "basic_machines:mese_dust_00"}
if farming_mod == "farming_redo" then
recipe.tin = {"farming:cocoa_beans", "farming:cocoa_beans", "basic_machines:tin_dust_00"}
recipe.mese = {"farming:rhubarb", "farming:rhubarb", "basic_machines:mese_dust_00"}
elseif farming_mod == "x_farming" then
recipe.tin = {"x_farming:salt", "x_farming:salt", "basic_machines:tin_dust_00"}
recipe.mese = {"x_farming:strawberry", "x_farming:strawberry", "basic_machines:mese_dust_00"}
end
register_extractor("iron", S("Iron Extractor"), "999999",
{"default:leaves", "default:leaves", "basic_machines:iron_dust_00"})
register_extractor("copper", S("Copper Extractor"), "C8800D",
{"default:papyrus", "default:papyrus", "basic_machines:copper_dust_00"})
register_extractor("tin", S("Tin Extractor"), "C89F9F", recipe.tin)
register_extractor("gold", S("Gold Extractor"), "FFFF00",
{"basic_machines:tin_extractor", "basic_machines:copper_extractor", "basic_machines:gold_dust_00"})
register_extractor("mese", S("Mese Extractor"), "CCCC00", recipe.mese)
register_extractor("diamond", S("Diamond Extractor"), "00EEFF",
{"farming:wheat", "farming:cotton", "basic_machines:diamond_dust_00"})
end
register_extractor("iron", S("Iron Extractor"), "999999",
{"default:leaves", "default:leaves", "basic_machines:iron_dust_00"})
register_extractor("copper", S("Copper Extractor"), "C8800D",
{"default:papyrus", "default:papyrus", "basic_machines:copper_dust_00"})
register_extractor("tin", S("Tin Extractor"), "C89F9F", recipe.tin)
register_extractor("gold", S("Gold Extractor"), "FFFF00",
{"basic_machines:tin_extractor", "basic_machines:copper_extractor", "basic_machines:gold_dust_00"})
register_extractor("mese", S("Mese Extractor"), "CCCC00", recipe.mese)
register_extractor("diamond", S("Diamond Extractor"), "00EEFF",
{"farming:wheat", "farming:cotton", "basic_machines:diamond_dust_00"})
if moreores_tin_lump_present then
register_extractor("silver", S("Silver Extractor"), "BBBBBB",
{"flowers:geranium", "flowers:tulip_black", "basic_machines:silver_dust_00"})
@ -390,7 +398,7 @@ minetest.register_node("basic_machines:grinder", {
description = S("Grinder"),
groups = {cracky = 3},
tiles = {"basic_machines_grinder.png"},
sounds = default.node_sound_wood_defaults(),
sounds = basic_machines.sound_node_machine(),
after_place_node = function(pos, placer)
if not placer then return end
@ -434,12 +442,16 @@ minetest.register_node("basic_machines:grinder", {
elseif fields.help then
if grinder_recipes_help == nil then
grinder_recipes_help = F(table.concat(grinder_recipes_translated, "\n"))
if #grinder_recipes_translated > 1 then
grinder_recipes_help = F(table.concat(grinder_recipes_translated, "\n"))
else
grinder_recipes_help = ""
end
end
minetest.show_formspec(sender:get_player_name(), "basic_machines:help_grinder",
"formspec_version[4]size[8,9.3]textarea[0,0.35;8,8.95;help;" .. F(S("Grinder help")) .. ";" ..
F(S("To upgrade grinder, put grinders in upgrade slot." ..
" Each upgrade adds ability to process additional materials.\n\n")) .. grinder_recipes_help .. "]")
" Each upgrade adds ability to process additional materials.\n")) .. grinder_recipes_help .. "]")
end
end,
@ -482,7 +494,7 @@ minetest.register_node("basic_machines:grinder", {
}
})
if basic_machines.settings.register_crafts then
if basic_machines.settings.register_crafts and use_default then
minetest.register_craft({
output = "basic_machines:grinder",
recipe = {

195
init.lua
View File

@ -16,132 +16,18 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
--]]
basic_machines = {
F = minetest.formspec_escape,
S = minetest.get_translator("basic_machines"),
version = "10/02/2021a custom",
properties = {
no_clock = false, -- if true all continuously running activities (clockgen/keypad) are disabled
machines_TTL = 16, -- time to live for signals, how many hops before signal dissipates
machines_minstep = 1, -- minimal allowed activation timestep, if faster machines overheat
machines_operations = 10, -- 1 coal will provide 10 mover basic operations (moving dirt 1 block distance)
machines_timer = 5, -- main timestep
max_range = 10, -- machines normal range of operation
mover_upgrade_max = 10 -- upgrade mover to increase range and to reduce fuel consumption
},
settings = { -- can be added to server configuration file, example: basic_machines_energy_multiplier = 1
-- ball spawner
max_balls = 2, -- balls count limit per player, minimum 0
-- crystals
energy_multiplier = 1, -- energy crystals multiplier
power_stackmax = 25, -- power crystals stack max
-- grinder
grinder_register_dusts = true, -- dusts/extractors for lumps/ingots, needed for the others grinder settings
grinder_dusts_quantity = 2, -- quantity of dusts produced by lump/ingot, minimum 0
grinder_dusts_legacy = false, -- legacy dust mode: dust_33 (smelt) -> dust_66 (smelt) -> ingot
grinder_extractors_type = 1, -- recipe priority if optional mod present, 1: farming_redo, 2: x_farming
-- mover
mover_add_removed_items = false, -- always add the removed items in normal mode with target chest
mover_no_large_stacks = false, -- limit the stack count to its max in normal, drop and inventory mode
mover_max_temp = 176, -- overheat above this temperature, minimum 1
-- technic_power
generator_upgrade = 0, -- upgrade available in addition to the current limit (50)
-- space
space_start_eff = 1500, -- space efficiency height
space_start = 1100, -- space height, set to false to disable
space_textures = "", -- skybox space textures replacement with up to 6 texture names separated by commas
exclusion_height = 6666, -- above, without "include" priv, player is teleported to a random location
space_effects = false, -- enable damage mechanism
--
register_crafts = false -- machines crafts recipes
},
-- form
get_form_player_inventory = function(x, y, w, h, s)
local player_inv = {
("list[current_player;main;%g,%g;%i,1]"):format(x, y, w),
("list[current_player;main;%g,%g;%i,%i;%i]"):format(x, y + 1.4, w, h - 1, w)
}
for i = 0 , w - 1 do
player_inv[i + 3] = ("image[%g,%g;1,1;[combine:1x1^[noalpha^[colorize:black^[opacity:43]"):format(x + (s + 1) * i, y)
end
return table.concat(player_inv)
end,
--[[ interfaces
-- autocrafter
change_autocrafter_recipe = function() end,
-- distributor
get_distributor_form = function() end,
-- enviro
player_sneak = nil, -- table used by optional mod player_monoids
-- grinder
get_grinder_recipes = function() end,
set_grinder_recipes = function() end,
-- keypad
use_keypad = function() end,
-- mover
add_mover_mode = function() end,
check_mover_filter = function() end,
check_mover_target = nil, -- function used with mover_no_large_stacks setting
check_palette_index = function() end,
clamp_item_count = nil, -- function used with mover_no_large_stacks setting
find_and_connect_battery = function() end,
get_distance = function() end,
get_mover = function() end,
get_mover_form = function() end,
get_palette_index = function() end,
itemstring_to_stack = function() end,
node_to_stack = function() end,
set_mover = function() end,
-- technic_power
check_power = function() end
--]]
}
-- read settings from configuration file
for k, v in pairs(basic_machines.settings) do
local setting = nil
if type(v) == "boolean" then
setting = minetest.settings:get_bool("basic_machines_" .. k)
elseif type(v) == "number" then
setting = tonumber(minetest.settings:get("basic_machines_" .. k))
elseif type(v) == "string" then
setting = minetest.settings:get("basic_machines_" .. k)
end
if setting ~= nil then
basic_machines.settings[k] = setting
end
end
-- creative check
local creative_cache = minetest.settings:get_bool("creative_mode")
basic_machines.creative = function(name)
return creative_cache or minetest.check_player_privs(name,
{creative = true})
end
-- result: float with precision of two digits or integer number
local modf = math.modf
basic_machines.twodigits_float = function(number)
local r
if number ~= 0 then
local i, f = modf(number)
if f ~= 0 then r = i + ("%.2f"):format(f) else r = number end
else
r = 0
end
return r
end
-- load files
local MP = minetest.get_modpath("basic_machines") .. "/"
dofile(MP .. "common.lua") -- basic_machines global table, settings and functions
dofile(MP .. "autocrafter.lua") -- borrowed and adapted from pipeworks mod
dofile(MP .. "ball.lua") -- interactive flying ball, can activate blocks or be used as a weapon
dofile(MP .. "clockgen.lua") -- periodically activates machine on top of it
dofile(MP .. "constructor.lua") -- enable machines constructor
dofile(MP .. "detector.lua") -- detect block/player/object and activate machine
dofile(MP .. "distributor.lua") -- forward signal to targets
dofile(MP .. "enviro.lua") -- enviro blocks that can change surrounding environment physics
dofile(MP .. "enviro.lua") -- change surrounding environment physics
dofile(MP .. "grinder.lua") -- grind materials into dusts
dofile(MP .. "keypad.lua") -- activate machine by sending signal
dofile(MP .. "light.lua") -- light on/off
@ -157,76 +43,21 @@ if minetest.global_exists("mesecon") then
dofile(MP .. "mesecon_adapter.lua")
end
-- OPTIONAL content
dofile(MP .. "crafts.lua") -- adds additional craft recipes
-- GRAVELSIEVE compatibility
if minetest.global_exists("gravelsieve") then
dofile(MP .. "control_gravelsieve.lua") -- adds compatibility to gravelsieve mod
dofile(MP .. "control_gravelsieve.lua")
end
dofile(MP .. "control_doors.lua") -- if you want open/close doors/trapdoors with signal,
-- also walk through trapdoors, steel doors/trapdoors are made impervious to dig through,
-- removal by repeated punches
dofile(MP .. "control_lights.lua") -- adds ability to toggle light for other light blocks
-- SPACE
if basic_machines.settings.space_start then
dofile(MP .. "space.lua") -- change global physics (skybox, gravity, damage mechanism...)
end
local S = basic_machines.S
-- test: toggle machine running with clockgen/keypad repeats, useful for debugging
-- i.e. seeing how machines running affect server performance
minetest.register_chatcommand("clockgen", {
description = S("Toggle clock generator/keypad repeats"),
privs = {privs = true},
func = function(name, _)
basic_machines.properties.no_clock = not basic_machines.properties.no_clock
minetest.chat_send_player(name, S("No clock set to @1", tostring(basic_machines.properties.no_clock)))
end
})
-- "machines" privilege
minetest.register_privilege("machines", {
description = S("Player is expert basic_machines user: his machines work while not present on server," ..
" can spawn more than @1 balls at once", basic_machines.settings.max_balls),
give_to_singleplayer = false,
give_to_admin = false
})
-- unified_inventory "machines" category
if (basic_machines.settings.register_crafts or creative_cache) and
minetest.global_exists("unified_inventory") and
unified_inventory.registered_categories and
not unified_inventory.registered_categories["machines"]
then
unified_inventory.register_category("machines", {
symbol = "basic_machines:mover",
label = S("Machines and Components"),
items = {
"basic_machines:autocrafter",
"basic_machines:ball_spawner",
"basic_machines:battery_0",
"basic_machines:clockgen",
"basic_machines:constructor",
"basic_machines:detector",
"basic_machines:distributor",
"basic_machines:enviro",
"basic_machines:generator",
"basic_machines:grinder",
"basic_machines:keypad",
"basic_machines:light_on",
"basic_machines:mesecon_adapter",
"basic_machines:mover",
"basic_machines:recycler"
}
})
end
-- for translations script (inventory list names)
--[[
S("dst"); S("fuel"); S("main"); S("output");
S("recipe"); S("src"); S("upgrade")
--]]
-- COMPATIBILITY
minetest.register_alias("basic_machines:battery", "basic_machines:battery_0")
-- OPTIONAL content
dofile(MP .. "crafts.lua") -- additional craft recipes
dofile(MP .. "control_doors.lua") -- if you want open/close doors/trapdoors with signal,
-- also walk through trapdoors, steel doors/trapdoors are made impervious to dig through,
-- removal by repeated punches
dofile(MP .. "control_lights.lua") -- ability to toggle light for other light blocks
print("[MOD] basic_machines " .. basic_machines.version .. " loaded.")

View File

@ -6,6 +6,7 @@ local mover_no_large_stacks = basic_machines.settings.mover_no_large_stacks
local string_byte = string.byte
local signs -- when activated with keypad their text will be updated
local use_signs_lib = minetest.global_exists("signs_lib")
local use_default = basic_machines.use_default
local use_unifieddyes = minetest.global_exists("unifieddyes")
if use_signs_lib then
@ -13,11 +14,13 @@ if use_signs_lib then
for _, sign_name in ipairs(signs_lib.lbm_restore_nodes or {}) do
signs[sign_name] = true
end
else -- minetest_game default mod
elseif use_default then
signs = {
["default:sign_wall_steel"] = true,
["default:sign_wall_wood"] = true
}
else
signs = {}
end
-- position, time to live (how many times can signal travel before vanishing to prevent infinite recursion),
@ -44,15 +47,13 @@ basic_machines.use_keypad = function(pos, ttl, reset, reset_msg)
meta:set_int("t", t1); meta:set_int("T", T)
if T > 2 then -- overheat
minetest.sound_play("default_cool_lava", {pos = pos, max_hear_distance = 16, gain = 0.25}, true)
minetest.sound_play(basic_machines.sound_overheat, {pos = pos, max_hear_distance = 16, gain = 0.25}, true)
meta:set_string("infotext", S("Overheat! Temperature: @1", T))
return
end
-- protection check
local owner = meta:get_string("owner")
if minetest.is_protected(pos, owner) then
if minetest.is_protected(pos, meta:get_string("owner")) then
meta:set_int("count", 0)
meta:set_int("T", T + 2)
meta:set_string("infotext", S("Protection fail. Reset."))
@ -149,17 +150,20 @@ basic_machines.use_keypad = function(pos, ttl, reset, reset_msg)
if use_signs_lib then -- with signs_lib
if signs_lib.update_sign then
signs_lib.update_sign(tpos, {text = text})
else
return
end
else -- minetest_game default mod
elseif use_default then -- minetest_game default mod
local infotext
if text:len() > 512 then
minetest.chat_send_player(owner, S("KEYPAD: Text too long.")); return
infotext = S("KEYPAD: Text too long.")
text = infotext
else
local tmeta = minetest.get_meta(tpos)
tmeta:set_string("infotext", S('"@1"', text))
tmeta:set_string("text", text)
infotext = S('"@1"', text)
end
local tmeta = minetest.get_meta(tpos)
tmeta:set_string("infotext", infotext)
tmeta:set_string("text", text)
end
-- target is keypad, special functions: @, % that output to target keypad's text
@ -178,7 +182,7 @@ basic_machines.use_keypad = function(pos, ttl, reset, reset_msg)
end, 16) -- up to 16 replacements
if text:len() > 4896 then
minetest.chat_send_player(owner, S("KEYPAD: Text too long.")); return
tmeta:set_string("text", S("KEYPAD: Text too long."))
else -- set target keypad's text
tmeta:set_string("text", text)
end
@ -291,7 +295,7 @@ minetest.register_node("basic_machines:keypad", {
description = S("Keypad"),
groups = {cracky = 2},
tiles = {"basic_machines_keypad.png"},
sounds = default.node_sound_wood_defaults(),
sounds = basic_machines.sound_node_machine(),
after_place_node = function(pos, placer)
if not placer then return end
@ -354,7 +358,7 @@ minetest.register_node("basic_machines:keypad", {
}
})
if basic_machines.settings.register_crafts then
if basic_machines.settings.register_crafts and use_default then
minetest.register_craft({
output = "basic_machines:keypad",
recipe = {

View File

@ -1,3 +1,7 @@
-- (c) 2015-2016 rnd
-- Copyright (C) 2022-2023 мтест
-- See README.md for license details
local F, S = basic_machines.F, basic_machines.S
local def = {groups = {cracky = 3}}
if minetest.global_exists("unifieddyes") then
@ -68,11 +72,11 @@ end
minetest.register_node("basic_machines:light_on", {
description = S("Light"),
groups = def.groups,
light_source = default.LIGHT_MAX,
light_source = 14,
tiles = {"basic_machines_light.png"},
paramtype2 = def.paramtype2,
palette = def.palette,
sounds = default.node_sound_wood_defaults(),
sounds = basic_machines.sound_node_machine(),
after_place_node = function(pos)
local meta = minetest.get_meta(pos)
@ -111,12 +115,12 @@ minetest.register_node("basic_machines:light_off", {
tiles = {"basic_machines_light_off.png"},
paramtype2 = def.paramtype2,
palette = def.palette,
sounds = default.node_sound_wood_defaults(),
sounds = basic_machines.sound_node_machine(),
effector = def.light_off_action
})
if basic_machines.settings.register_crafts then
if basic_machines.settings.register_crafts and basic_machines.use_default then
minetest.register_craft({
output = "basic_machines:light_on",
recipe = {

View File

@ -20,7 +20,8 @@ Visual=
@nLifetime: [1, +∞[=
Ball spawner help=
Ball Spell=
Values:@n@nTarget*: Direction of velocity@n x: [-@1, @2], y: [-@3, @4], z: [-@5, @6]@nSpeed: [-10, 10]@nEnergy: [-1, 1]@nBounce**: [0, 2]@nGravity: [0, 40]@nPunchable***: [0, 2]@nHp: [0, +∞[@nHurt: ]-∞, @7]@8@nSolid*: [0, 1]@nTexture: Texture name with extension, up to 512 characters@nScale*: [1, 1000]@nVisual*: "cube" or "sprite"@n@n*: Not available as individual Ball Spawner@n@n**: Set to 2, the ball bounce following y direction and for the next blocks:@n@9@n@n***: 0: not punchable, 1: only in protected area, 2: everywhere@n@nNote: Hold sneak while digging to get the Ball Spawner@n=
, and for the next blocks:=
Values:@n@nTarget*: Direction of velocity@n x: [-@1, @2], y: [-@3, @4], z: [-@5, @6]@nSpeed: [-10, 10]@nEnergy: [-1, 1]@nBounce**: [0, 2]@nGravity: [0, 40]@nPunchable***: [0, 2]@nHp: [0, +∞[@nHurt: ]-∞, @7]@8@nSolid*: [0, 1]@nTexture: Texture name with extension, up to 512 characters@nScale*: [1, 1000]@nVisual*: "cube" or "sprite"@n@n*: Not available as individual Ball Spawner@n@n**: Set to 2, the ball bounces following y direction@9@n@n***: 0: not punchable, 1: only in protected area, 2: everywhere@n@nNote: Hold sneak while digging to get the Ball Spawner@n=
Ball Spawner=
Speed=
Gravity=
@ -93,7 +94,7 @@ Values:@n@nTarget: Center position of the area to apply environment effects@n
Environment Changer=
-=
Radius=
Recipes:@n=
@nRecipes:@n=
Grinding=
In (@1): @2@nOut (@3): @4@n=
In: @1@nOut (@2): @3@n=
@ -120,7 +121,7 @@ Recipe requires at least @1 of '@2' (@3)=
Need at least @1 fuel to complete operation=
Grinder: to operate it insert fuel, then insert item to grind or activate with signal=
Grinder help=
To upgrade grinder, put grinders in upgrade slot. Each upgrade adds ability to process additional materials.@n@n=
To upgrade grinder, put grinders in upgrade slot. Each upgrade adds ability to process additional materials.@n=
Grinder=
Toggle clock generator/keypad repeats=
No clock set to @1=

View File

@ -49,7 +49,7 @@ minetest.register_node("basic_machines:mesecon_adapter", {
tiles = {"basic_machines_clock_generator.png", "basic_machines_clock_generator.png",
"jeija_luacontroller_top.png", "jeija_luacontroller_top.png",
"jeija_luacontroller_top.png", "jeija_luacontroller_top.png"},
sounds = default.node_sound_wood_defaults(),
sounds = basic_machines.sound_node_machine(),
after_place_node = function(pos)
minetest.get_meta(pos):set_string("infotext", S("Mesecon Adapter: place machine to be activated on top"))
@ -66,7 +66,7 @@ minetest.register_node("basic_machines:mesecon_adapter", {
}
})
if basic_machines.settings.register_crafts then
if basic_machines.settings.register_crafts and basic_machines.use_default then
minetest.register_craft({
output = "basic_machines:mesecon_adapter",
recipe = {{"default:mese_crystal_fragment"}}

View File

@ -1,6 +1,5 @@
name = basic_machines
description = lightweight automation mod
depends = default
optional_depends = """
basic_protect,
beerchat,
@ -29,6 +28,7 @@ optional_depends = """
willow,
darkage,
default,
doors,
es,
extra_doors,

View File

@ -36,15 +36,7 @@ local mover = {
},
-- define which nodes are dug up completely, like a tree
dig_up_table = {
["default:acacia_tree"] = {h = 6, r = 2}, -- acacia trees grow wider than others
["default:aspen_tree"] = {h = 10, r = 0},
["default:cactus"] = {h = 5, r = 2},
["default:jungletree"] = {h = 11}, -- not emergent jungle tree
["default:papyrus"] = {h = 3, r = 0},
["default:pine_tree"] = {h = 13, r = 0},
["default:tree"] = {h = 4, r = 1}
},
dig_up_table = {},
-- how hard it is to move blocks, default factor 1,
-- note: fuel cost is this multiplied by distance and divided by machine_operations..
@ -158,6 +150,18 @@ local mover = {
plants_table = {}
}
if basic_machines.use_default then
mover.dig_up_table = {
["default:acacia_tree"] = {h = 6, r = 2}, -- acacia trees grow wider than others
["default:aspen_tree"] = {h = 10, r = 0},
["default:cactus"] = {h = 5, r = 2},
["default:jungletree"] = {h = 11}, -- not emergent jungle tree
["default:papyrus"] = {h = 3, r = 0},
["default:pine_tree"] = {h = 13, r = 0},
["default:tree"] = {h = 4, r = 1}
}
end
-- cool_trees
local cool_trees = { -- all but pineapple
{"baldcypress", h = 17, r = 5}, -- why the trunk isn't centered at the sapling position
@ -299,7 +303,7 @@ local function pos1list_checks(pos, length_pos, owner, upgrade, meta)
node[i], node_name[i] = nodei, nodei_name
else
local nodei_hardness = mover_hardness[nodei_name] or 1
if nodei_hardness < 596 then -- (3 * 99 diamonds blocks + 1)
if nodei_hardness < 596 then -- (3 * 99 diamond blocks + 1)
node[i], node_name[i] = nodei, nodei_name
hardness = hardness + nodei_hardness
else
@ -341,7 +345,7 @@ minetest.register_node("basic_machines:mover", {
description = S("Mover"),
groups = {cracky = 2},
tiles = {"basic_machines_mover.png"},
sounds = default.node_sound_wood_defaults(),
sounds = basic_machines.sound_node_machine(),
after_place_node = function(pos, placer)
if not placer then return end
@ -557,7 +561,7 @@ minetest.register_node("basic_machines:mover", {
meta:set_int("t", t1); meta:set_int("T", T)
if T > mover_max_temp or third_upgradetype and T > 2 then
minetest.sound_play("default_cool_lava", {pos = pos, max_hear_distance = 16, gain = 0.25}, true)
minetest.sound_play(basic_machines.sound_overheat, {pos = pos, max_hear_distance = 16, gain = 0.25}, true)
meta:set_string("infotext", S("Overheat! Temperature: @1", T))
return
end
@ -784,7 +788,7 @@ minetest.register_node("basic_machines:mover", {
elseif supply < 0 then -- no battery at target location, try to find it!
if not basic_machines.find_and_connect_battery(pos, meta) then
meta:set_string("infotext", S("Can not find nearby battery to connect to!"))
minetest.sound_play("default_cool_lava", {pos = pos, gain = 1, max_hear_distance = 8}, true)
minetest.sound_play(basic_machines.sound_overheat, {pos = pos, gain = 1, max_hear_distance = 8}, true)
return
end
end
@ -830,7 +834,7 @@ minetest.register_node("basic_machines:mover", {
}
})
if basic_machines.settings.register_crafts then
if basic_machines.settings.register_crafts and basic_machines.use_default then
minetest.register_craft({
output = "basic_machines:mover",
recipe = {

View File

@ -409,7 +409,7 @@ local function dig(pos, meta, owner, prefer, pos1, node1, node1_name, source_che
-- play sound
local activation_count = meta:get_int("activation_count")
if activation_count < 16 then
minetest.sound_play("basic_machines_transporter", {pos = last_pos2 or pos2, gain = 1, max_hear_distance = 8}, true)
minetest.sound_play("basic_machines_transport", {pos = last_pos2 or pos2, gain = 1, max_hear_distance = 8}, true)
end
return activation_count, new_fuel_cost

View File

@ -101,7 +101,7 @@ local function drop(_, meta, owner, prefer, pos1, node1, node1_name, source_ches
-- play sound
local activation_count = meta:get_int("activation_count")
if activation_count < 16 then
minetest.sound_play("basic_machines_transporter", {pos = pos2, gain = 1, max_hear_distance = 8}, true)
minetest.sound_play("basic_machines_transport", {pos = pos2, gain = 1, max_hear_distance = 8}, true)
end
return activation_count

View File

@ -82,7 +82,7 @@ local function inventory(_, meta, _, prefer, pos1, _, node1_name, _, pos2, mreve
-- play sound
local activation_count = meta:get_int("activation_count")
if activation_count < 16 then
minetest.sound_play("basic_machines_chest_inventory_move", {pos = pos2, gain = 1, max_hear_distance = 8}, true)
minetest.sound_play("basic_machines_inventory_move", {pos = pos2, gain = 1, max_hear_distance = 8}, true)
end
return activation_count

View File

@ -207,7 +207,7 @@ local function normal(pos, meta, owner, prefer, pos1, node1, node1_name, source_
-- play sound
local activation_count = meta:get_int("activation_count")
if activation_count < 16 then
minetest.sound_play("basic_machines_transporter", {pos = last_pos2 or pos2, gain = 1, max_hear_distance = 8}, true)
minetest.sound_play("basic_machines_transport", {pos = last_pos2 or pos2, gain = 1, max_hear_distance = 8}, true)
end
return activation_count, new_fuel_cost

View File

@ -123,7 +123,7 @@ local function object(pos, meta, owner, prefer, pos1, _, _, _, pos2, mreverse)
if no_sound then
return activation_count
elseif activation_count < 16 then -- play sound
minetest.sound_play("basic_machines_tng_transporter1", {pos = pos2, gain = 1, max_hear_distance = 8}, true)
minetest.sound_play("basic_machines_object_move", {pos = pos2, gain = 1, max_hear_distance = 8}, true)
return activation_count
end
end

View File

@ -52,7 +52,7 @@ local function transport(pos, meta, owner, prefer, pos1, node1, node1_name, sour
-- play sound
local activation_count = meta:get_int("activation_count")
if activation_count < 16 then
minetest.sound_play("basic_machines_transporter", {pos = pos2, gain = 1, max_hear_distance = 8}, true)
minetest.sound_play("basic_machines_transport", {pos = pos2, gain = 1, max_hear_distance = 8}, true)
end
return activation_count

View File

@ -194,7 +194,7 @@ minetest.register_node("basic_machines:recycler", {
description = S("Recycler"),
groups = {cracky = 3},
tiles = {"basic_machines_recycler.png"},
sounds = default.node_sound_wood_defaults(),
sounds = basic_machines.sound_node_machine(),
after_place_node = function(pos, placer)
if not placer then return end
@ -280,7 +280,7 @@ minetest.register_node("basic_machines:recycler", {
}
})
if basic_machines.settings.register_crafts then
if basic_machines.settings.register_crafts and basic_machines.use_default then
minetest.register_craft({
output = "basic_machines:recycler",
recipe = {

View File

@ -147,43 +147,45 @@ minetest.register_globalstep(function(dtime)
end)
--[[
-- AIR EXPERIMENT
minetest.register_node("basic_machines:air", {
description = S("Enable breathing in space"),
groups = {not_in_creative_inventory = 1},
drawtype = "glasslike", -- drawtype = "liquid",
tiles = {"default_water_source_animated.png"},
use_texture_alpha = "blend",
paramtype = "light",
sunlight_propagates = true, -- Sunlight shines through
walkable = false, -- Would make the player collide with the air node
pointable = false, -- You can't select the node
diggable = false, -- You can't dig the node
buildable_to = true,
drop = "",
if basic_machines.use_default then
minetest.register_node("basic_machines:air", {
description = S("Enable breathing in space"),
groups = {not_in_creative_inventory = 1},
drawtype = "glasslike", -- drawtype = "liquid",
tiles = {"default_water_source_animated.png"},
use_texture_alpha = "blend",
paramtype = "light",
sunlight_propagates = true, -- Sunlight shines through
walkable = false, -- Would make the player collide with the air node
pointable = false, -- You can't select the node
diggable = false, -- You can't dig the node
buildable_to = true,
drop = "",
after_place_node = function(pos)
local r = 3
for i = -r, r do
for j = -r, r do
for k = -r, r do
local p = {x = pos.x + i, y = pos.y + j, z = pos.z + k}
if minetest.get_node(p).name == "air" then
minetest.set_node(p, {name = "basic_machines:air"})
after_place_node = function(pos)
local r = 3
for i = -r, r do
for j = -r, r do
for k = -r, r do
local p = {x = pos.x + i, y = pos.y + j, z = pos.z + k}
if minetest.get_node(p).name == "air" then
minetest.set_node(p, {name = "basic_machines:air"})
end
end
end
end
end
end
})
})
minetest.register_abm({
label = "[basic_machines] Air experiment",
nodenames = {"basic_machines:air"},
neighbors = {"air"},
interval = 10,
chance = 1,
action = function(pos)
minetest.set_node(pos, {name = "air"})
end
})
minetest.register_abm({
label = "[basic_machines] Air experiment",
nodenames = {"basic_machines:air"},
neighbors = {"air"},
interval = 10,
chance = 1,
action = function(pos)
minetest.set_node(pos, {name = "air"})
end
})
end
--]]

View File

@ -193,13 +193,13 @@ local function battery_upgrade(meta, pos)
end
-- this function will activate furnace
local machines_activate_furnace = minetest.registered_nodes["default:furnace"].on_metadata_inventory_put
local machines_activate_furnace = (minetest.registered_nodes["default:furnace"] or {}).on_metadata_inventory_put
minetest.register_node("basic_machines:battery_0", {
description = S("Battery"),
groups = {cracky = 3},
tiles = {"basic_machines_outlet.png", "basic_machines_battery.png", "basic_machines_battery_0.png"},
sounds = default.node_sound_wood_defaults(),
sounds = basic_machines.sound_node_machine(),
after_place_node = function(pos, placer)
if not placer then return end
@ -463,7 +463,7 @@ minetest.register_node("basic_machines:generator", {
description = S("Generator"),
groups = {cracky = 3},
tiles = {"basic_machines_generator.png"},
sounds = default.node_sound_wood_defaults(),
sounds = basic_machines.sound_node_machine(),
after_place_node = function(pos, placer)
if not placer then return end
@ -613,7 +613,7 @@ minetest.register_craftitem("basic_machines:power_rod", {
light_source = 12
})
if basic_machines.settings.register_crafts then
if basic_machines.settings.register_crafts and basic_machines.use_default then
minetest.register_craft({
output = "basic_machines:battery_0",
recipe = {