From b32ef86798556e829ad14ba16d85c55df9d26304 Mon Sep 17 00:00:00 2001 From: asl97 Date: Wed, 16 Apr 2014 02:49:33 +0800 Subject: [PATCH] centralize translation `S` code in init.lua to reduce the number of dofile --- bananas.lua | 9 ++------- carrots.lua | 9 ++------- cocoa.lua | 9 ++------- init.lua | 8 ++++++++ oranges.lua | 9 ++------- potatoes.lua | 9 ++------- pumpkin.lua | 9 ++------- rhubarb.lua | 9 ++------- strawberries.lua | 9 ++------- tomatoes.lua | 9 ++------- weed.lua | 9 ++------- 11 files changed, 28 insertions(+), 70 deletions(-) diff --git a/bananas.lua b/bananas.lua index 8d5f3d0..5b90581 100644 --- a/bananas.lua +++ b/bananas.lua @@ -1,11 +1,6 @@ --- Boilerplate to support localized strings if intllib mod is installed. +-- main `S` code in init.lua local S -if (minetest.get_modpath("intllib")) then - dofile(minetest.get_modpath("intllib").."/intllib.lua") - S = intllib.Getter(minetest.get_current_modname()) -else - S = function ( s ) return s end -end +S = farming.S minetest.register_node("farming_plus:banana_sapling", { description = S("Banana Tree Sapling"), diff --git a/carrots.lua b/carrots.lua index b854cc8..1133dde 100644 --- a/carrots.lua +++ b/carrots.lua @@ -1,11 +1,6 @@ --- Boilerplate to support localized strings if intllib mod is installed. +-- main `S` code in init.lua local S -if (minetest.get_modpath("intllib")) then - dofile(minetest.get_modpath("intllib").."/intllib.lua") - S = intllib.Getter(minetest.get_current_modname()) -else - S = function ( s ) return s end -end +S = farming.S minetest.register_craftitem("farming_plus:carrot_seed", { description = S("Carrot Seeds"), diff --git a/cocoa.lua b/cocoa.lua index a734024..c8b0233 100644 --- a/cocoa.lua +++ b/cocoa.lua @@ -1,11 +1,6 @@ --- Boilerplate to support localized strings if intllib mod is installed. +-- main `S` code in init.lua local S -if (minetest.get_modpath("intllib")) then - dofile(minetest.get_modpath("intllib").."/intllib.lua") - S = intllib.Getter(minetest.get_current_modname()) -else - S = function ( s ) return s end -end +S = farming.S minetest.register_node("farming_plus:cocoa_sapling", { description = S("Cocoa Tree Sapling"), diff --git a/init.lua b/init.lua index d10e938..d4a28e7 100644 --- a/init.lua +++ b/init.lua @@ -1,5 +1,13 @@ farming.registered_plants = {} +-- Boilerplate to support localized strings if intllib mod is installed. +if (minetest.get_modpath("intllib")) then + dofile(minetest.get_modpath("intllib").."/intllib.lua") + farming.S = intllib.Getter(minetest.get_current_modname()) +else + farming.S = function ( s ) return s end +end + function farming:add_plant(full_grown, names, interval, chance) minetest.register_abm({ nodenames = names, diff --git a/oranges.lua b/oranges.lua index 09f2516..6f996ab 100644 --- a/oranges.lua +++ b/oranges.lua @@ -1,11 +1,6 @@ --- Boilerplate to support localized strings if intllib mod is installed. +-- main `S` code in init.lua local S -if (minetest.get_modpath("intllib")) then - dofile(minetest.get_modpath("intllib").."/intllib.lua") - S = intllib.Getter(minetest.get_current_modname()) -else - S = function ( s ) return s end -end +S = farming.S minetest.register_craftitem("farming_plus:orange_seed", { description = S("Orange Seeds"), diff --git a/potatoes.lua b/potatoes.lua index 79c0fb7..51600f3 100644 --- a/potatoes.lua +++ b/potatoes.lua @@ -1,11 +1,6 @@ --- Boilerplate to support localized strings if intllib mod is installed. +-- main `S` code in init.lua local S -if (minetest.get_modpath("intllib")) then - dofile(minetest.get_modpath("intllib").."/intllib.lua") - S = intllib.Getter(minetest.get_current_modname()) -else - S = function ( s ) return s end -end +S = farming.S minetest.register_craftitem("farming_plus:potato_seed", { description = ("Potato Seeds"), diff --git a/pumpkin.lua b/pumpkin.lua index 77c0013..478e437 100644 --- a/pumpkin.lua +++ b/pumpkin.lua @@ -1,11 +1,6 @@ --- Boilerplate to support localized strings if intllib mod is installed. +-- main `S` code in init.lua local S -if (minetest.get_modpath("intllib")) then - dofile(minetest.get_modpath("intllib").."/intllib.lua") - S = intllib.Getter(minetest.get_current_modname()) -else - S = function ( s ) return s end -end +S = farming.S minetest.register_craftitem(":farming:pumpkin_seed", { description = S("Pumpkin Seed"), diff --git a/rhubarb.lua b/rhubarb.lua index 23650ea..2c37d1a 100644 --- a/rhubarb.lua +++ b/rhubarb.lua @@ -1,11 +1,6 @@ --- Boilerplate to support localized strings if intllib mod is installed. +-- main `S` code in init.lua local S -if (minetest.get_modpath("intllib")) then - dofile(minetest.get_modpath("intllib").."/intllib.lua") - S = intllib.Getter(minetest.get_current_modname()) -else - S = function ( s ) return s end -end +S = farming.S minetest.register_craftitem("farming_plus:rhubarb_seed", { description = S("Rhubarb Seeds"), diff --git a/strawberries.lua b/strawberries.lua index 43e6f3d..cc2b9f9 100644 --- a/strawberries.lua +++ b/strawberries.lua @@ -1,11 +1,6 @@ --- Boilerplate to support localized strings if intllib mod is installed. +-- main `S` code in init.lua local S -if (minetest.get_modpath("intllib")) then - dofile(minetest.get_modpath("intllib").."/intllib.lua") - S = intllib.Getter(minetest.get_current_modname()) -else - S = function ( s ) return s end -end +S = farming.S minetest.register_craftitem("farming_plus:strawberry_seed", { description = S("Strawberry Seeds"), diff --git a/tomatoes.lua b/tomatoes.lua index a3fbbf7..acb3300 100644 --- a/tomatoes.lua +++ b/tomatoes.lua @@ -1,11 +1,6 @@ --- Boilerplate to support localized strings if intllib mod is installed. +-- main `S` code in init.lua local S -if (minetest.get_modpath("intllib")) then - dofile(minetest.get_modpath("intllib").."/intllib.lua") - S = intllib.Getter(minetest.get_current_modname()) -else - S = function ( s ) return s end -end +S = farming.S minetest.register_craftitem("farming_plus:tomato_seed", { description = S("Tomato Seeds"), diff --git a/weed.lua b/weed.lua index dcaf9f3..b117870 100644 --- a/weed.lua +++ b/weed.lua @@ -1,11 +1,6 @@ --- Boilerplate to support localized strings if intllib mod is installed. +-- main `S` code in init.lua local S -if (minetest.get_modpath("intllib")) then - dofile(minetest.get_modpath("intllib").."/intllib.lua") - S = intllib.Getter(minetest.get_current_modname()) -else - S = function ( s ) return s end -end +S = farming.S minetest.register_node(":farming:weed", { description = S("Weed"),