summaryrefslogtreecommitdiff
path: root/autocrafter.lua
diff options
context:
space:
mode:
authorLouis Royer <4259825-lroyer@users.noreply.gitlab.com>2020-02-18 17:34:52 +0000
committerVanessa Dannenberg <vanessa.e.dannenberg@gmail.com>2020-02-18 17:34:52 +0000
commit62bc13078f4e93993ebf121cc9c74bc31a6e5d90 (patch)
tree359944bcd77a5ec36a32b1475e2818019e105956 /autocrafter.lua
parent84d7104c66459d8785b95d2db5cc8f425a499d89 (diff)
downloadpipeworks-62bc13078f4e93993ebf121cc9c74bc31a6e5d90.tar
pipeworks-62bc13078f4e93993ebf121cc9c74bc31a6e5d90.tar.gz
pipeworks-62bc13078f4e93993ebf121cc9c74bc31a6e5d90.tar.bz2
pipeworks-62bc13078f4e93993ebf121cc9c74bc31a6e5d90.tar.xz
pipeworks-62bc13078f4e93993ebf121cc9c74bc31a6e5d90.zip
Add translation support
- Created `locale/template.txt` - Fixed some typos - Replace some `print("[pipeworks]"..` with `pipeworks.logger()` - Removed "You hacker, you" from descriptions
Diffstat (limited to 'autocrafter.lua')
-rw-r--r--autocrafter.lua23
1 files changed, 12 insertions, 11 deletions
diff --git a/autocrafter.lua b/autocrafter.lua
index ebde77c..db23a14 100644
--- a/autocrafter.lua
+++ b/autocrafter.lua
@@ -1,3 +1,4 @@
+local S = minetest.get_translator("pipeworks")
local autocrafterCache = {} -- caches some recipe data to avoid to call the slow function minetest.get_craft_result() every second
local craft_time = 1
@@ -16,7 +17,7 @@ end
local function get_item_info(stack)
local name = stack:get_name()
local def = minetest.registered_items[name]
- local description = def and def.description or "Unknown item"
+ local description = def and def.description or S("Unknown item")
return description, name
end
@@ -68,7 +69,7 @@ local function run_autocrafter(pos, elapsed)
local output_item = craft.output.item
-- only use crafts that have an actual result
if output_item:is_empty() then
- meta:set_string("infotext", "unconfigured Autocrafter: unknown recipe")
+ meta:set_string("infotext", S("unconfigured Autocrafter: unknown recipe"))
return false
end
@@ -101,7 +102,7 @@ local function after_recipe_change(pos, inventory)
if inventory:is_empty("recipe") then
minetest.get_node_timer(pos):stop()
autocrafterCache[minetest.hash_node_position(pos)] = nil
- meta:set_string("infotext", "unconfigured Autocrafter")
+ meta:set_string("infotext", S("unconfigured Autocrafter"))
inventory:set_stack("output", 1, "")
return
end
@@ -126,7 +127,7 @@ local function after_recipe_change(pos, inventory)
craft = craft or get_craft(pos, inventory, hash)
local output_item = craft.output.item
local description, name = get_item_info(output_item)
- meta:set_string("infotext", string.format("'%s' Autocrafter (%s)", description, name))
+ meta:set_string("infotext", S("'@1' Autocrafter (@2)", description, name))
inventory:set_stack("output", 1, output_item)
after_inventory_change(pos)
@@ -190,8 +191,8 @@ local function update_meta(meta, enabled)
"listring[context;dst]" ..
"listring[current_player;main]"
if minetest.get_modpath("digilines") then
- fs = fs.."field[1,3.5;4,1;channel;Channel;${channel}]"
- fs = fs.."button_exit[5,3.2;2,1;save;Save]"
+ fs = fs.."field[1,3.5;4,1;channel;"..S("Channel")..";${channel}]"
+ fs = fs.."button_exit[5,3.2;2,1;save;"..S("Save").."]"
end
meta:set_string("formspec",fs)
@@ -200,13 +201,13 @@ local function update_meta(meta, enabled)
-- this might be more written code, but actually executes less
local output = meta:get_inventory():get_stack("output", 1)
if output:is_empty() then -- doesn't matter if paused or not
- meta:set_string("infotext", "unconfigured Autocrafter")
+ meta:set_string("infotext", S("unconfigured Autocrafter"))
return false
end
local description, name = get_item_info(output)
- local infotext = enabled and string.format("'%s' Autocrafter (%s)", description, name)
- or string.format("paused '%s' Autocrafter", description)
+ local infotext = enabled and S("'@1' Autocrafter (@2)", description, name)
+ or S("paused '@1' Autocrafter", description)
meta:set_string("infotext", infotext)
return enabled
@@ -226,7 +227,7 @@ local function upgrade_autocrafter(pos, meta)
update_meta(meta, true)
if meta:get_string("virtual_items") == "1" then -- we are version 2
- -- we allready dropped stuff, so lets remove the metadatasetting (we are not being called again for this node)
+ -- we already dropped stuff, so lets remove the metadatasetting (we are not being called again for this node)
meta:set_string("virtual_items", "")
else -- we are version 1
local recipe = inv:get_list("recipe")
@@ -248,7 +249,7 @@ local function upgrade_autocrafter(pos, meta)
end
minetest.register_node("pipeworks:autocrafter", {
- description = "Autocrafter",
+ description = S("Autocrafter"),
drawtype = "normal",
tiles = {"pipeworks_autocrafter.png"},
groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1},