summaryrefslogtreecommitdiff
path: root/computer
diff options
context:
space:
mode:
Diffstat (limited to 'computer')
-rw-r--r--computer/computers.lua18
-rw-r--r--computer/depends.txt3
-rw-r--r--computer/init.lua37
-rw-r--r--computer/miscitems.lua3
-rw-r--r--computer/tetris.lua36
5 files changed, 48 insertions, 49 deletions
diff --git a/computer/computers.lua b/computer/computers.lua
index 877ccbd..5a7fed4 100644
--- a/computer/computers.lua
+++ b/computer/computers.lua
@@ -1,3 +1,6 @@
+
+local S = homedecor_i18n.gettext
+
-- Amiga 500 lookalike
computer.register("computer:shefriendSOO", {
description = "SheFriendSOO",
@@ -157,7 +160,7 @@ local mo_sbox = {
}
minetest.register_node("computer:monitor", {
- description = "Monitor and keyboard",
+ description = S("Monitor and keyboard"),
inventory_image = "computer_monitor_inv.png",
drawtype = "mesh",
mesh = "computer_monitor.obj",
@@ -175,7 +178,6 @@ minetest.register_node("computer:monitor", {
})
minetest.register_node("computer:monitor_on", {
- description = "Monitor and keyboard",
drawtype = "mesh",
mesh = "computer_monitor.obj",
tiles = {"monitor_display.png^[transformFX", "monitor_plastic.png", "computer_black.png", "monitor_plastic.png"},
@@ -200,7 +202,7 @@ minetest.register_alias("computer:monitor_desktop", "computer:monitor")
--WIFI Router (linksys look-a-like)
minetest.register_node("computer:router", {
- description = "WIFI Router",
+ description = S("WIFI Router"),
inventory_image = "computer_router_inv.png",
tiles = {"computer_router_t.png","computer_router_bt.png","computer_router_l.png","computer_router_r.png","computer_router_b.png",
{name="computer_router_f_animated.png", animation={type="vertical_frames", aspect_w=32, aspect_h=32, length=1.0}},}, --"computer_router_f.png"},
@@ -228,7 +230,7 @@ local pct_cbox = {
--Modern PC Tower
minetest.register_node("computer:tower", {
- description = "Computer Tower",
+ description = S("Computer Tower"),
inventory_image = "computer_tower_inv.png",
drawtype = "mesh",
mesh = "computer_tower.obj",
@@ -245,7 +247,7 @@ minetest.register_alias("computer:tower_on", "computer:tower")
-- Printer/scaner combo
minetest.register_node("computer:printer", {
- description = "Printer Scaner Combo",
+ description = S("Printer-Scanner Combo"),
inventory_image = "computer_printer_inv.png",
tiles = {"computer_printer_t.png","computer_printer_bt.png","computer_printer_l.png",
"computer_printer_r.png","computer_printer_b.png","computer_printer_f.png"},
@@ -273,7 +275,7 @@ minetest.register_node("computer:printer", {
--Rack Server
minetest.register_node("computer:server", {
drawtype = "nodebox",
- description = "Rack Server",
+ description = S("Rack Server"),
tiles = {
'computer_server_t.png',
'computer_server_bt.png',
@@ -303,7 +305,8 @@ minetest.register_node("computer:server", {
on_place = function(itemstack, placer, pointed_thing)
local pos = pointed_thing.above
if minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name ~= "air" then
- minetest.chat_send_player( placer:get_player_name(), "Not enough vertical space to place a server!" )
+ minetest.chat_send_player( placer:get_player_name(),
+ S("Not enough vertical space to place a server!" ))
return itemstack
end
return minetest.item_place(itemstack, placer, pointed_thing)
@@ -312,7 +315,6 @@ minetest.register_node("computer:server", {
minetest.register_node("computer:server_on", {
drawtype = "nodebox",
- description = "Rack Server",
tiles = {
'computer_server_t.png',
'computer_server_bt.png',
diff --git a/computer/depends.txt b/computer/depends.txt
index c48fe0d..947d2a7 100644
--- a/computer/depends.txt
+++ b/computer/depends.txt
@@ -1,3 +1,2 @@
default
-intllib?
-
+homedecor_i18n
diff --git a/computer/init.lua b/computer/init.lua
index bb690ed..534878d 100644
--- a/computer/init.lua
+++ b/computer/init.lua
@@ -2,19 +2,18 @@ computer = {}
screwdriver = screwdriver or {}
computer.register = function (name, def)
- local nodename = name
if (name:sub(1, 1) == ":") then name = name:sub(2) end
local modname, basename = name:match("^([^:]+):(.*)")
local TEXPFX = modname.."_"..basename.."_"
local ONSTATE = modname..":"..basename
local OFFSTATE = modname..":"..basename.."_off"
- local def = def
+ local cdef = table.copy(def)
minetest.register_node(ONSTATE, {
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
- description = def.description,
- inventory_image = def.inventory_image,
+ description = cdef.description,
+ inventory_image = cdef.inventory_image,
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2},
tiles = {
TEXPFX.."tp.png",
@@ -24,10 +23,10 @@ computer.register = function (name, def)
TEXPFX.."bk.png",
TEXPFX.."ft.png"
},
- node_box = def.node_box,
- selection_box = def.node_box,
+ node_box = cdef.node_box,
+ selection_box = cdef.node_box,
on_rightclick = function (pos, node, clicker, itemstack)
- if def.on_turn_off and def.on_turn_off(pos, node, clicker, itemstack) then
+ if cdef.on_turn_off and cdef.on_turn_off(pos, node, clicker, itemstack) then
return itemstack
end
node.name = OFFSTATE
@@ -41,17 +40,17 @@ computer.register = function (name, def)
paramtype2 = "facedir",
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1},
tiles = {
- (TEXPFX.."tp"..(def.tiles_off.top and "_off" or "")..".png"),
- (TEXPFX.."bt"..(def.tiles_off.bottom and "_off" or "")..".png"),
- (TEXPFX.."rt"..(def.tiles_off.right and "_off" or "")..".png"),
- (TEXPFX.."lt"..(def.tiles_off.left and "_off" or "")..".png"),
- (TEXPFX.."bk"..(def.tiles_off.back and "_off" or "")..".png"),
- (TEXPFX.."ft"..(def.tiles_off.front and "_off" or "")..".png")
+ (TEXPFX.."tp"..(cdef.tiles_off.top and "_off" or "")..".png"),
+ (TEXPFX.."bt"..(cdef.tiles_off.bottom and "_off" or "")..".png"),
+ (TEXPFX.."rt"..(cdef.tiles_off.right and "_off" or "")..".png"),
+ (TEXPFX.."lt"..(cdef.tiles_off.left and "_off" or "")..".png"),
+ (TEXPFX.."bk"..(cdef.tiles_off.back and "_off" or "")..".png"),
+ (TEXPFX.."ft"..(cdef.tiles_off.front and "_off" or "")..".png")
},
- node_box = def.node_box_off or def.node_box,
- selection_box = def.node_box_off or def.node_box,
+ node_box = cdef.node_box_off or cdef.node_box,
+ selection_box = cdef.node_box_off or cdef.node_box,
on_rightclick = function (pos, node, clicker, itemstack)
- if def.on_turn_on and def.on_turn_on(pos, node, clicker, itemstack) then
+ if cdef.on_turn_on and cdef.on_turn_on(pos, node, clicker, itemstack) then
return itemstack
end
node.name = ONSTATE
@@ -63,13 +62,10 @@ computer.register = function (name, def)
end
computer.register_handheld = function (name, def)
- local nodename = name
if (name:sub(1, 1) == ":") then name = name:sub(2) end
local modname, basename = name:match("^([^:]+):(.*)")
local TEXPFX = modname.."_"..basename.."_inv"
local ONSTATE = modname..":"..basename
- local OFFSTATE = modname..":"..basename.."_off"
- local on_use = def.on_use
minetest.register_craftitem(ONSTATE, {
description = def.description,
inventory_image = TEXPFX..".png",
@@ -79,8 +75,7 @@ end
computer.pixelnodebox = function (size, boxes)
local fixed = { }
- local i, box
- for i, box in ipairs(boxes) do
+ for _, box in ipairs(boxes) do
local x, y, z, w, h, l = unpack(box)
fixed[#fixed + 1] = {
(x / size) - 0.5,
diff --git a/computer/miscitems.lua b/computer/miscitems.lua
index c5017a7..5f63c7d 100644
--- a/computer/miscitems.lua
+++ b/computer/miscitems.lua
@@ -4,8 +4,7 @@
-- This file defines some items in order to not have to depend on other mods.
--- Boilerplate to support localized strings if intllib mod is installed.
-local S = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end
+local S = homedecor_i18n.gettext
if (not minetest.get_modpath("homedecor")) then
diff --git a/computer/tetris.lua b/computer/tetris.lua
index 5f0b71c..1683dcc 100644
--- a/computer/tetris.lua
+++ b/computer/tetris.lua
@@ -1,6 +1,9 @@
+
+local S = homedecor_i18n.gettext
+
local shapes = {
{ { x = {0, 1, 0, 1}, y = {0, 0, 1, 1} } },
-
+
{ { x = {1, 1, 1, 1}, y = {0, 1, 2, 3} },
{ x = {0, 1, 2, 3}, y = {1, 1, 1, 1} } },
@@ -35,7 +38,7 @@ local buttons = "button[3,4.5;0.6,0.6;left;<]"
.."button[4.2,5.3;0.6,0.6;drop;V]"
.."button[4.8,4.5;0.6,0.6;rotateright;R]"
.."button[5.4,4.5;0.6,0.6;right;>]"
- .."button[3.5,3;2,2;new;New Game]"
+ .."button[3.5,3;2,2;new;"..minetest.formspec_escape(S("New Game")).."]"
local formsize = "size[5.9,5.7]"
local boardx, boardy = 0, 0
@@ -70,8 +73,8 @@ end
local function step(pos, fields)
local meta = minetest.get_meta(pos)
local t = minetest.deserialize(meta:get_string("tetris"))
-
- local function new_game(pos)
+
+ local function new_game(p)
local nex = math.random(7)
t = {
@@ -81,10 +84,10 @@ local function step(pos, fields)
score = 0,
cur = math.random(7),
nex = nex,
- x=4, y=0, rot=1
+ x=4, y=0, rot=1
}
- local timer = minetest.get_node_timer(pos)
+ local timer = minetest.get_node_timer(p)
timer:set(0.3, 0)
end
@@ -99,7 +102,7 @@ local function step(pos, fields)
i*sizey+boardy, semi,
size, comma, size, semi,
colors[tile[2]], close }
-
+
ins = ins + 1
scr[ins] = concat(tmp)
end
@@ -138,9 +141,9 @@ local function step(pos, fields)
for i=1,4 do
local cx, cy = d.x[i]+x, d.y[i]+y
-
+
if cx < 0 or cx > 9 or cy < 0 or cy > 19 then
- return false
+ return false
end
for _, tile in pairs(t.board[ cy ] or {}) do
@@ -157,7 +160,7 @@ local function step(pos, fields)
end
local function tick()
- if stuck() then
+ if stuck() then
if t.y <= 0 then
return false end
add()
@@ -170,7 +173,7 @@ local function step(pos, fields)
t.y = t.y + 1
end
return true
- end
+ end
local function move(dx, dy)
local newx, newy = t.x+dx, t.y+dy
@@ -225,10 +228,10 @@ local function step(pos, fields)
end
if t then
- local scr = { formsize, background,
+ local scr = { formsize, background,
t.boardstring, t.previewstring,
draw_shape(t.cur, t.x, t.y, t.rot, boardx, boardy),
- "label[3.8,0.1;Next...]label[3.8,2.7;Score: ",
+ "label[3.8,0.1;Next...]label[3.8,2.7;Score: ",
t.score, close, buttons }
@@ -241,7 +244,7 @@ local function step(pos, fields)
end
minetest.register_node("computer:tetris_arcade", {
- description="Tetris Arcade",
+ description=S("Tetris Arcade"),
drawtype = "mesh",
mesh = "tetris_arcade.obj",
tiles = {"tetris_arcade.png"},
@@ -259,7 +262,8 @@ minetest.register_node("computer:tetris_arcade", {
},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
- meta:set_string("formspec", formsize.."button[2,2.5;2,2;new;New Game]"
+ meta:set_string("formspec", formsize
+ .."button[2,2.5;2,2;new;"..minetest.formspec_escape(S("New Game")).."]"
..default.gui_bg..default.gui_bg_img..default.gui_slots)
end,
on_timer = function(pos)
@@ -275,7 +279,7 @@ minetest.register_node("computer:tetris_arcade", {
return itemstack
end
if minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name ~= "air" then
- minetest.chat_send_player(placer:get_player_name(), "No room for place the Arcade!")
+ minetest.chat_send_player(placer:get_player_name(), S("No room for place the Arcade!"))
return itemstack
end
local dir = placer:get_look_dir()