Skip to content

Commit 2ebc4ac

Browse files
Replace minetest namespace with core (#158)
Co-authored-by: SX <[email protected]>
1 parent d39ff8a commit 2ebc4ac

34 files changed

+619
-617
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Files related to minetest development cycle
1+
## Files related to luanti development cycle
22
/*.patch
33
# GNU Patch reject file
44
*.rej

.luacheckrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ globals = {
99
}
1010

1111
read_globals = {
12-
-- luanti (TODO: remove after lunarmodules/luacheck releases a version with proper luanti support)
12+
-- remove after luacheck release: https://github.com/lunarmodules/luacheck/issues/121
1313
"core",
1414
-- mods
1515
"default", "mesecon", "digilines",

autocrafter.lua

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
local S = minetest.get_translator("pipeworks")
1+
local S = core.get_translator("pipeworks")
22
-- cache some recipe data to avoid calling the slow function
3-
-- minetest.get_craft_result() every second
3+
-- core.get_craft_result() every second
44
local autocrafterCache = {}
55

66
local craft_time = 1
@@ -20,15 +20,15 @@ end
2020

2121
local function get_item_info(stack)
2222
local name = stack:get_name()
23-
local def = minetest.registered_items[name]
23+
local def = core.registered_items[name]
2424
local description = def and def.description or S("Unknown item")
2525
return description, name
2626
end
2727

2828
-- Get best matching recipe for what user has put in crafting grid.
2929
-- This function does not consider crafting method (mix vs craft)
3030
local function get_matching_craft(output_name, example_recipe)
31-
local recipes = minetest.get_all_craft_recipes(output_name)
31+
local recipes = core.get_all_craft_recipes(output_name)
3232
if not recipes then
3333
return example_recipe
3434
end
@@ -49,7 +49,7 @@ local function get_matching_craft(output_name, example_recipe)
4949
elseif recipe_item_name:sub(1, 6) == "group:" then
5050
group = recipe_item_name:sub(7)
5151
for example_item_name, _ in pairs(index_example) do
52-
if minetest.get_item_group(
52+
if core.get_item_group(
5353
example_item_name, group) ~= 0
5454
then
5555
score = score + 1
@@ -68,12 +68,12 @@ local function get_matching_craft(output_name, example_recipe)
6868
end
6969

7070
local function get_craft(pos, inventory, hash)
71-
local hash = hash or minetest.hash_node_position(pos)
71+
local hash = hash or core.hash_node_position(pos)
7272
local craft = autocrafterCache[hash]
7373
if craft then return craft end
7474

7575
local example_recipe = inventory:get_list("recipe")
76-
local output, decremented_input = minetest.get_craft_result({
76+
local output, decremented_input = core.get_craft_result({
7777
method = "normal", width = 3, items = example_recipe
7878
})
7979

@@ -132,7 +132,7 @@ local function calculate_consumption(inv_index, consumption_with_groups)
132132
local found = 0
133133
local count_ingredient_groups = #ingredient_groups
134134
for i = 1, count_ingredient_groups do
135-
if minetest.get_item_group(name,
135+
if core.get_item_group(name,
136136
ingredient_groups[i]) ~= 0
137137
then
138138
found = found + 1
@@ -241,7 +241,7 @@ local function autocraft(inventory, craft)
241241
for i = 1, 9 do
242242
leftover = inventory:add_item("dst", craft.decremented_input[i])
243243
if leftover and not leftover:is_empty() then
244-
minetest.log("warning", "[pipeworks] autocrafter didn't " ..
244+
core.log("warning", "[pipeworks] autocrafter didn't " ..
245245
"calculate output space correctly.")
246246
end
247247
end
@@ -252,7 +252,7 @@ end
252252
-- is started only from start_autocrafter(pos) after sanity checks and
253253
-- recipe is cached
254254
local function run_autocrafter(pos, elapsed)
255-
local meta = minetest.get_meta(pos)
255+
local meta = core.get_meta(pos)
256256
local inventory = meta:get_inventory()
257257
local craft = get_craft(pos, inventory)
258258
local output_item = craft.output.item
@@ -270,9 +270,9 @@ local function run_autocrafter(pos, elapsed)
270270
end
271271

272272
local function start_crafter(pos)
273-
local meta = minetest.get_meta(pos)
273+
local meta = core.get_meta(pos)
274274
if meta:get_int("enabled") == 1 then
275-
local timer = minetest.get_node_timer(pos)
275+
local timer = core.get_node_timer(pos)
276276
if not timer:is_started() then
277277
timer:start(craft_time)
278278
end
@@ -286,12 +286,12 @@ end
286286
-- note, that this function assumes allready being updated to virtual items
287287
-- and doesn't handle recipes with stacksizes > 1
288288
local function after_recipe_change(pos, inventory)
289-
local hash = minetest.hash_node_position(pos)
290-
local meta = minetest.get_meta(pos)
289+
local hash = core.hash_node_position(pos)
290+
local meta = core.get_meta(pos)
291291
autocrafterCache[hash] = nil
292292
-- if we emptied the grid, there's no point in keeping it running or cached
293293
if inventory:is_empty("recipe") then
294-
minetest.get_node_timer(pos):stop()
294+
core.get_node_timer(pos):stop()
295295
meta:set_string("infotext", S("unconfigured Autocrafter"))
296296
inventory:set_stack("output", 1, "")
297297
return
@@ -307,12 +307,12 @@ end
307307

308308
-- clean out unknown items and groups, which would be handled like unknown
309309
-- items in the crafting grid
310-
-- if minetest supports query by group one day, this might replace them
310+
-- if Luanti supports query by group one day, this might replace them
311311
-- with a canonical version instead
312312
local function normalize(item_list)
313313
for i = 1, #item_list do
314314
local name = item_list[i]
315-
if not minetest.registered_items[name] then
315+
if not core.registered_items[name] then
316316
item_list[i] = ""
317317
end
318318
end
@@ -324,7 +324,7 @@ local function on_output_change(pos, inventory, stack)
324324
inventory:set_list("output", {})
325325
inventory:set_list("recipe", {})
326326
else
327-
local input = minetest.get_craft_recipe(stack:get_name())
327+
local input = core.get_craft_recipe(stack:get_name())
328328
if not input.items or input.type ~= "normal" then return end
329329
local items, width = normalize(input.items), input.width
330330
local item_idx, width_idx = 1, 1
@@ -349,7 +349,7 @@ local function update_meta(meta, enabled)
349349
local state = enabled and "on" or "off"
350350
meta:set_int("enabled", enabled and 1 or 0)
351351
local list_backgrounds = ""
352-
if minetest.get_modpath("i3") or minetest.get_modpath("mcl_formspec") then
352+
if core.get_modpath("i3") or core.get_modpath("mcl_formspec") then
353353
list_backgrounds = "style_type[box;colors=#666]"
354354
for i = 0, 2 do
355355
for j = 0, 2 do
@@ -389,7 +389,7 @@ local function update_meta(meta, enabled)
389389
"listring[current_player;main]" ..
390390
"listring[context;dst]" ..
391391
"listring[current_player;main]"
392-
if minetest.get_modpath("digilines") then
392+
if core.get_modpath("digilines") then
393393
fs = fs .. "field[0.22,4.1;4.5,0.75;channel;" .. S("Channel") ..
394394
";${channel}]" ..
395395
"button[5,4.1;1.5,0.75;set_channel;" .. S("Set") .. "]" ..
@@ -422,7 +422,7 @@ end
422422
-- so we work out way backwards on this history and update each single case
423423
-- to the newest version
424424
local function upgrade_autocrafter(pos, meta)
425-
local meta = meta or minetest.get_meta(pos)
425+
local meta = meta or core.get_meta(pos)
426426
local inv = meta:get_inventory()
427427

428428
if inv:get_size("output") == 0 then -- we are version 2 or 1
@@ -439,7 +439,7 @@ local function upgrade_autocrafter(pos, meta)
439439
if not recipe then return end
440440
for idx, stack in ipairs(recipe) do
441441
if not stack:is_empty() then
442-
minetest.add_item(pos, stack)
442+
core.add_item(pos, stack)
443443
stack:set_count(1)
444444
stack:set_wear(0)
445445
inv:set_stack("recipe", idx, stack)
@@ -448,27 +448,27 @@ local function upgrade_autocrafter(pos, meta)
448448
end
449449

450450
-- update the recipe, cache, and start the crafter
451-
autocrafterCache[minetest.hash_node_position(pos)] = nil
451+
autocrafterCache[core.hash_node_position(pos)] = nil
452452
after_recipe_change(pos, inv)
453453
end
454454
end
455455

456-
minetest.register_node("pipeworks:autocrafter", {
456+
core.register_node("pipeworks:autocrafter", {
457457
description = S("Autocrafter"),
458458
drawtype = "normal",
459459
tiles = {"pipeworks_autocrafter.png"},
460460
groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1, dig_generic = 1, axey=1, handy=1, pickaxey=1},
461461
is_ground_content = false,
462462
_mcl_hardness=0.8,
463463
tube = {insert_object = function(pos, node, stack, direction)
464-
local meta = minetest.get_meta(pos)
464+
local meta = core.get_meta(pos)
465465
local inv = meta:get_inventory()
466466
local added = inv:add_item("src", stack)
467467
after_inventory_change(pos)
468468
return added
469469
end,
470470
can_insert = function(pos, node, stack, direction)
471-
local meta = minetest.get_meta(pos)
471+
local meta = core.get_meta(pos)
472472
local inv = meta:get_inventory()
473473
return inv:room_for_item("src", stack)
474474
end,
@@ -478,7 +478,7 @@ minetest.register_node("pipeworks:autocrafter", {
478478
}
479479
},
480480
on_construct = function(pos)
481-
local meta = minetest.get_meta(pos)
481+
local meta = core.get_meta(pos)
482482
local inv = meta:get_inventory()
483483
inv:set_size("src", 3 * 8)
484484
inv:set_size("recipe", 3 * 3)
@@ -492,10 +492,10 @@ minetest.register_node("pipeworks:autocrafter", {
492492
then
493493
return
494494
end
495-
local meta = minetest.get_meta(pos)
495+
local meta = core.get_meta(pos)
496496
if fields.on then
497497
update_meta(meta, false)
498-
minetest.get_node_timer(pos):stop()
498+
core.get_node_timer(pos):stop()
499499
elseif fields.off then
500500
if update_meta(meta, true) then
501501
start_crafter(pos)
@@ -507,7 +507,7 @@ minetest.register_node("pipeworks:autocrafter", {
507507
end,
508508
can_dig = function(pos, player)
509509
upgrade_autocrafter(pos)
510-
local meta = minetest.get_meta(pos)
510+
local meta = core.get_meta(pos)
511511
local inv = meta:get_inventory()
512512
return (inv:is_empty("src") and inv:is_empty("dst"))
513513
end,
@@ -516,12 +516,12 @@ minetest.register_node("pipeworks:autocrafter", {
516516
pipeworks.scan_for_tube_objects(pos)
517517
end,
518518
on_destruct = function(pos)
519-
autocrafterCache[minetest.hash_node_position(pos)] = nil
519+
autocrafterCache[core.hash_node_position(pos)] = nil
520520
end,
521521
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
522522
if not pipeworks.may_configure(pos, player) then return 0 end
523523
upgrade_autocrafter(pos)
524-
local inv = minetest.get_meta(pos):get_inventory()
524+
local inv = core.get_meta(pos):get_inventory()
525525
if listname == "recipe" then
526526
stack:set_count(1)
527527
inv:set_stack(listname, index, stack)
@@ -536,13 +536,13 @@ minetest.register_node("pipeworks:autocrafter", {
536536
end,
537537
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
538538
if not pipeworks.may_configure(pos, player) then
539-
minetest.log("action", string.format("%s attempted to take from " ..
539+
core.log("action", string.format("%s attempted to take from " ..
540540
"autocrafter at %s",
541-
player:get_player_name(), minetest.pos_to_string(pos)))
541+
player:get_player_name(), core.pos_to_string(pos)))
542542
return 0
543543
end
544544
upgrade_autocrafter(pos)
545-
local inv = minetest.get_meta(pos):get_inventory()
545+
local inv = core.get_meta(pos):get_inventory()
546546
if listname == "recipe" then
547547
inv:set_stack(listname, index, ItemStack(""))
548548
after_recipe_change(pos, inv)
@@ -559,7 +559,7 @@ minetest.register_node("pipeworks:autocrafter", {
559559

560560
if not pipeworks.may_configure(pos, player) then return 0 end
561561
upgrade_autocrafter(pos)
562-
local inv = minetest.get_meta(pos):get_inventory()
562+
local inv = core.get_meta(pos):get_inventory()
563563
local stack = inv:get_stack(from_list, from_index)
564564

565565
if to_list == "output" then
@@ -592,7 +592,7 @@ minetest.register_node("pipeworks:autocrafter", {
592592
receptor = {},
593593
effector = {
594594
action = function(pos,node,channel,msg)
595-
local meta = minetest.get_meta(pos)
595+
local meta = core.get_meta(pos)
596596
if channel ~= meta:get_string("channel") then return end
597597
if type(msg) == "table" then
598598
if #msg < 3 then return end
@@ -601,7 +601,7 @@ minetest.register_node("pipeworks:autocrafter", {
601601
local row = msg[y + 1]
602602
for x = 1, 3, 1 do
603603
local slot = y * 3 + x
604-
if type(row) == "table" and minetest.registered_items[row[x]] then
604+
if type(row) == "table" and core.registered_items[row[x]] then
605605
inv:set_stack("recipe", slot, ItemStack(
606606
row[x]))
607607
else
@@ -611,7 +611,7 @@ minetest.register_node("pipeworks:autocrafter", {
611611
end
612612
after_recipe_change(pos,inv)
613613
elseif msg == "get_recipe" then
614-
local meta = minetest.get_meta(pos)
614+
local meta = core.get_meta(pos)
615615
local inv = meta:get_inventory()
616616
local recipe = {}
617617
for y = 0, 2, 1 do
@@ -634,7 +634,7 @@ minetest.register_node("pipeworks:autocrafter", {
634634
})
635635
elseif msg == "off" then
636636
update_meta(meta, false)
637-
minetest.get_node_timer(pos):stop()
637+
core.get_node_timer(pos):stop()
638638
elseif msg == "on" then
639639
if update_meta(meta, true) then
640640
start_crafter(pos)

autodetect-finite-water.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- enable finite liquid in the presence of dynamic liquid to preserve water volume.
22
local enable = false
33

4-
if minetest.get_modpath("dynamic_liquid") then
4+
if core.get_modpath("dynamic_liquid") then
55
pipeworks.logger("detected mod dynamic_liquid, enabling finite liquid flag")
66
enable = true
77
end

0 commit comments

Comments
 (0)