From 91950ee0266032c7bcefcbb63a5504011ffee52d Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 17 Feb 2017 23:06:52 +0100 Subject: [PATCH] Move global core variables to mcl_init --- mods/CORE/mcl_core/depends.txt | 1 + mods/CORE/mcl_core/init.lua | 16 ---------------- mods/CORE/mcl_init/description.txt | 1 + mods/CORE/mcl_init/init.lua | 18 ++++++++++++++++++ mods/CORE/mcl_init/mod.conf | 1 + mods/ENTITIES/mobs/api.lua | 4 ++-- mods/HUD/craftingpack/crafting/creative.lua | 2 +- mods/HUD/craftingpack/crafting/depends.txt | 1 + mods/HUD/craftingpack/crafting/init.lua | 4 ++-- mods/HUD/mcl_craftguide/init.lua | 4 ++-- mods/ITEMS/REDSTONE/mcl_dispensers/depends.txt | 1 + mods/ITEMS/REDSTONE/mcl_dispensers/init.lua | 2 +- mods/ITEMS/REDSTONE/mcl_droppers/depends.txt | 1 + mods/ITEMS/REDSTONE/mcl_droppers/init.lua | 2 +- mods/ITEMS/mcl_chests/depends.txt | 1 + mods/ITEMS/mcl_chests/init.lua | 12 ++++++------ mods/ITEMS/mcl_furnaces/depends.txt | 1 + mods/ITEMS/mcl_furnaces/init.lua | 4 ++-- mods/ITEMS/mcl_hoppers/init.lua | 2 +- 19 files changed, 44 insertions(+), 34 deletions(-) create mode 100644 mods/CORE/mcl_init/description.txt create mode 100644 mods/CORE/mcl_init/init.lua create mode 100644 mods/CORE/mcl_init/mod.conf diff --git a/mods/CORE/mcl_core/depends.txt b/mods/CORE/mcl_core/depends.txt index 673d7e42..78b6676b 100644 --- a/mods/CORE/mcl_core/depends.txt +++ b/mods/CORE/mcl_core/depends.txt @@ -1,2 +1,3 @@ +mcl_init mcl_sounds mcl_util diff --git a/mods/CORE/mcl_core/init.lua b/mods/CORE/mcl_core/init.lua index 8b1c9800..baadff30 100644 --- a/mods/CORE/mcl_core/init.lua +++ b/mods/CORE/mcl_core/init.lua @@ -1,24 +1,8 @@ --- Minetest 0.4 mod: default --- See README.txt for licensing and other information. --- The API documentation in here was moved into doc/lua_api.txt - --- Definitions made by this mod that other mods can use too mcl_core = {} -mcl_core.gui_slots = "listcolors[#9990;#FFF7;#FFF0;#000;#FFF]" -mcl_core.gui_bg = "bgcolor[#080808BB;true]" -mcl_core.gui_bg_img = "" - -mcl_core.inventory_header = mcl_core.gui_slots .. mcl_core.gui_bg -- Repair percentage for toolrepair mcl_core.repair = 0.05 -minetest.nodedef_default.stack_max = 64 -minetest.craftitemdef_default.stack_max = 64 - --- Set random seed for all other mods (Remember to make sure no other mod calls this function) -math.randomseed(os.time()) - -- Load files dofile(minetest.get_modpath("mcl_core").."/functions.lua") dofile(minetest.get_modpath("mcl_core").."/nodes.lua") diff --git a/mods/CORE/mcl_init/description.txt b/mods/CORE/mcl_init/description.txt new file mode 100644 index 00000000..4ab7458f --- /dev/null +++ b/mods/CORE/mcl_init/description.txt @@ -0,0 +1 @@ +Initialization mod of MineClone 2. Defines some common shared variables and sets up initial default settings which have to be set at the beginning. diff --git a/mods/CORE/mcl_init/init.lua b/mods/CORE/mcl_init/init.lua new file mode 100644 index 00000000..d1b519f6 --- /dev/null +++ b/mods/CORE/mcl_init/init.lua @@ -0,0 +1,18 @@ +-- Some global variables (don't overwrite them!) +mcl_vars = {} + +--- GUI / inventory menu colors +mcl_vars.gui_slots = "listcolors[#9990;#FFF7;#FFF0;#000;#FFF]" +mcl_vars.gui_bg = "bgcolor[#080808BB;true]" +mcl_vars.gui_bg_img = "" + +mcl_vars.inventory_header = mcl_vars.gui_slots .. mcl_vars.gui_bg + +-- Set default stack sizes +minetest.nodedef_default.stack_max = 64 +minetest.craftitemdef_default.stack_max = 64 + +-- Set random seed for all other mods (Remember to make sure no other mod calls this function) +math.randomseed(os.time()) + + diff --git a/mods/CORE/mcl_init/mod.conf b/mods/CORE/mcl_init/mod.conf new file mode 100644 index 00000000..5a3e4b6b --- /dev/null +++ b/mods/CORE/mcl_init/mod.conf @@ -0,0 +1 @@ +name = mcl_init diff --git a/mods/ENTITIES/mobs/api.lua b/mods/ENTITIES/mobs/api.lua index f7d3e478..c0c7865d 100644 --- a/mods/ENTITIES/mobs/api.lua +++ b/mods/ENTITIES/mobs/api.lua @@ -3039,8 +3039,8 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame) local tag = self.nametag or "" minetest.show_formspec(name, "mobs_nametag", "size[8,4]" - .. default.gui_bg - .. default.gui_bg_img + .. mcl_vars.gui_bg + .. mcl_vars.gui_bg_img .. "field[0.5,1;7.5,0;name;" .. S("Enter name:") .. ";" .. tag .. "]" .. "button_exit[2.5,3.5;3,1;mob_rename;" .. S("Rename") .. "]") diff --git a/mods/HUD/craftingpack/crafting/creative.lua b/mods/HUD/craftingpack/crafting/creative.lua index 4cf6aae9..43002158 100644 --- a/mods/HUD/craftingpack/crafting/creative.lua +++ b/mods/HUD/craftingpack/crafting/creative.lua @@ -232,7 +232,7 @@ crafting.set_creative_formspec = function(player, start_i, pagenum, show, page, "image[" .. boffset[check] .. ";1,1;crafting_creative_marker.png]" end formspec = "size[10,9.3]".. - mcl_core.inventory_header.. + mcl_vars.inventory_header.. "background[-0.19,-0.25;10.5,9.87;"..inv_bg.."]".. "label[-5,-5;"..name.."]".. "item_image_button[-0.1,0;1,1;mcl_core:brick_block;blocks;]".. --build blocks diff --git a/mods/HUD/craftingpack/crafting/depends.txt b/mods/HUD/craftingpack/crafting/depends.txt index 97bf5106..fac8788a 100644 --- a/mods/HUD/craftingpack/crafting/depends.txt +++ b/mods/HUD/craftingpack/crafting/depends.txt @@ -1,2 +1,3 @@ +mcl_init mcl_core mcl_sounds diff --git a/mods/HUD/craftingpack/crafting/init.lua b/mods/HUD/craftingpack/crafting/init.lua index 9edc664a..c55e44b2 100644 --- a/mods/HUD/craftingpack/crafting/init.lua +++ b/mods/HUD/craftingpack/crafting/init.lua @@ -66,7 +66,7 @@ local function set_inventory(player) local form = "size[9,8.75]".. "background[-0.19,-0.25;9.41,9.49;crafting_formspec_bg.png^crafting_inventory.png"..armor_img.."]".. - mcl_core.inventory_header.. + mcl_vars.inventory_header.. img_element.. --armor "list[detached:"..player_name.."_armor;armor;0,0;1,1;1]".. @@ -98,7 +98,7 @@ local function set_workbench(player) local form = "size[9,8.75]".. "background[-0.19,-0.25;9.41,9.49;crafting_formspec_bg.png^crafting_inventory_workbench.png]".. - mcl_core.inventory_header.. + mcl_vars.inventory_header.. "list[current_player;main;0,4.5;9,3;9]".. "list[current_player;main;0,7.74;9,1;]".. "list[current_player;craft;1.75,0.5;3,3;]".. diff --git a/mods/HUD/mcl_craftguide/init.lua b/mods/HUD/mcl_craftguide/init.lua index 4c3c1f85..409a86a8 100644 --- a/mods/HUD/mcl_craftguide/init.lua +++ b/mods/HUD/mcl_craftguide/init.lua @@ -251,8 +251,8 @@ function craftguide:get_formspec(player_name, is_fuel) data.pagemax = max(1, ceil(#data.items / ipp)) local formspec = "size["..data.iX..","..(iY+3)..".6;]".. - mcl_core.gui_slots .. - mcl_core.gui_bg .. + mcl_vars.gui_slots .. + mcl_vars.gui_bg .. [[background[1,1;1,1;craftguide_bg.png;true] button[2.4,0.21;0.8,0.5;search;?] button[3.05,0.21;0.8,0.5;clear;X] diff --git a/mods/ITEMS/REDSTONE/mcl_dispensers/depends.txt b/mods/ITEMS/REDSTONE/mcl_dispensers/depends.txt index 329cd815..69e11317 100644 --- a/mods/ITEMS/REDSTONE/mcl_dispensers/depends.txt +++ b/mods/ITEMS/REDSTONE/mcl_dispensers/depends.txt @@ -1,3 +1,4 @@ +mcl_init mesecons mcl_core mcl_sounds diff --git a/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua b/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua index d8f7f6c6..b91eb4b1 100644 --- a/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua @@ -13,7 +13,7 @@ local setup_dispenser = function(pos) -- Set formspec and inventory local form = "size[9,8.75]".. "background[-0.19,-0.25;9.41,9.49;crafting_inventory_9_slots.png]".. - mcl_core.inventory_header.. + mcl_vars.inventory_header.. "image[3,-0.2;5,0.75;mcl_dispensers_fnt_dispenser.png]".. "list[current_player;main;0,4.5;9,3;9]".. "list[current_player;main;0,7.74;9,1;]".. diff --git a/mods/ITEMS/REDSTONE/mcl_droppers/depends.txt b/mods/ITEMS/REDSTONE/mcl_droppers/depends.txt index 95222145..397b9b10 100644 --- a/mods/ITEMS/REDSTONE/mcl_droppers/depends.txt +++ b/mods/ITEMS/REDSTONE/mcl_droppers/depends.txt @@ -1,2 +1,3 @@ +mcl_init mesecons mcl_util diff --git a/mods/ITEMS/REDSTONE/mcl_droppers/init.lua b/mods/ITEMS/REDSTONE/mcl_droppers/init.lua index 8bba6ff4..dc4ff5c6 100644 --- a/mods/ITEMS/REDSTONE/mcl_droppers/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_droppers/init.lua @@ -13,7 +13,7 @@ local setup_dropper = function(pos) -- Set formspec and inventory local form = "size[9,8.75]".. "background[-0.19,-0.25;9.41,9.49;crafting_inventory_9_slots.png]".. - mcl_core.inventory_header.. + mcl_vars.inventory_header.. "image[3,-0.2;5,0.75;mcl_droppers_fnt_dropper.png]".. "list[current_player;main;0,4.5;9,3;9]".. "list[current_player;main;0,7.74;9,1;]".. diff --git a/mods/ITEMS/mcl_chests/depends.txt b/mods/ITEMS/mcl_chests/depends.txt index 02419c23..2b6d0295 100644 --- a/mods/ITEMS/mcl_chests/depends.txt +++ b/mods/ITEMS/mcl_chests/depends.txt @@ -1,3 +1,4 @@ +mcl_init mcl_core mcl_sounds mcl_end diff --git a/mods/ITEMS/mcl_chests/init.lua b/mods/ITEMS/mcl_chests/init.lua index d89ce710..ca528b3b 100644 --- a/mods/ITEMS/mcl_chests/init.lua +++ b/mods/ITEMS/mcl_chests/init.lua @@ -40,7 +40,7 @@ minetest.register_node("mcl_chests:chest", { meta:set_string("formspec", "size[9,11.5]".. "background[-0.19,-0.25;9.41,12.5;crafting_inventory_chest_large.png]".. - mcl_core.inventory_header.. + mcl_vars.inventory_header.. "list[nodemeta:"..p.x..","..p.y..","..p.z..";main;0,0.5;9,3;]".. "list[current_name;main;0,3.5;9,3;]".. "list[current_player;main;0,7.5;9,3;9]".. @@ -54,7 +54,7 @@ minetest.register_node("mcl_chests:chest", { m:set_string("formspec", "size[9,11.5]".. "background[-0.19,-0.25;9.41,12.5;crafting_inventory_chest_large.png]".. - mcl_core.inventory_header.. + mcl_vars.inventory_header.. "list[current_name;main;0,0.5;9,3;]".. "list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,3.5;9,3;]".. "list[current_player;main;0,7.5;9,3;9]".. @@ -69,7 +69,7 @@ minetest.register_node("mcl_chests:chest", { meta:set_string("formspec", "size[9,11.5]".. "background[-0.19,-0.25;9.41,12.5;crafting_inventory_chest_large.png]".. - mcl_core.inventory_header.. + mcl_vars.inventory_header.. "list[current_name;main;0,0.5;9,3;]".. "list[nodemeta:"..p.x..","..p.y..","..p.z..";main;0,3.5;9,3;]".. "list[current_player;main;0,7.5;9,3;9]".. @@ -83,7 +83,7 @@ minetest.register_node("mcl_chests:chest", { m:set_string("formspec", "size[9,11.5]".. "background[-0.19,-0.25;9.41,12.5;crafting_inventory_chest_large.png]".. - mcl_core.inventory_header.. + mcl_vars.inventory_header.. "list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,0.5;9,3;]".. "list[current_name;main;0,3.5;9,3;]".. "list[current_player;main;0,7.5;9,3;9]".. @@ -95,7 +95,7 @@ minetest.register_node("mcl_chests:chest", { else meta:set_string("formspec", "size[9,8.75]".. - mcl_core.inventory_header.. + mcl_vars.inventory_header.. "background[-0.19,-0.25;9.41,10.48;crafting_inventory_chest.png]".. "image[0,-0.2;5,0.75;fnt_chest.png]".. "list[current_name;main;0,0.5;9,3;]".. @@ -158,7 +158,7 @@ minetest.register_node("mcl_chests:chest_left", { "size[9,8.75]".. "background[-0.19,-0.25;9.41,10.48;crafting_inventory_chest.png]".. "image[0,-0.2;5,0.75;fnt_chest.png]".. - mcl_core.inventory_header.. + mcl_vars.inventory_header.. "list[current_name;main;0,0.5;9,3;]".. "list[current_player;main;0,4.5;9,3;9]".. "list[current_player;main;0,7.74;9,1;]".. diff --git a/mods/ITEMS/mcl_furnaces/depends.txt b/mods/ITEMS/mcl_furnaces/depends.txt index 8cee8436..b264f482 100644 --- a/mods/ITEMS/mcl_furnaces/depends.txt +++ b/mods/ITEMS/mcl_furnaces/depends.txt @@ -1,3 +1,4 @@ +mcl_init mcl_core mcl_sounds mcl_craftguide diff --git a/mods/ITEMS/mcl_furnaces/init.lua b/mods/ITEMS/mcl_furnaces/init.lua index 2e98dd1e..a7a5eff9 100644 --- a/mods/ITEMS/mcl_furnaces/init.lua +++ b/mods/ITEMS/mcl_furnaces/init.lua @@ -1,7 +1,7 @@ local furnace_inactive_formspec = "size[9,8.75]".. "background[-0.19,-0.25;9.41,9.49;crafting_formspec_bg.png^crafting_inventory_furnace.png]".. - mcl_core.inventory_header.. + mcl_vars.inventory_header.. "list[current_player;main;0,4.5;9,3;9]".. "list[current_player;main;0,7.74;9,1;]".. "list[current_name;src;2.75,0.5;1,1;]".. @@ -208,7 +208,7 @@ minetest.register_abm({ meta:set_string("formspec", "size[9,8.75]".. "background[-0.19,-0.25;9.41,9.49;crafting_formspec_bg.png^crafting_inventory_furnace.png]".. - mcl_core.inventory_header.. + mcl_vars.inventory_header.. "list[current_player;main;0,4.5;9,3;9]".. "list[current_player;main;0,7.74;9,1;]".. "list[current_name;src;2.75,0.5;1,1;]".. diff --git a/mods/ITEMS/mcl_hoppers/init.lua b/mods/ITEMS/mcl_hoppers/init.lua index 61ee24ac..40c68ad0 100644 --- a/mods/ITEMS/mcl_hoppers/init.lua +++ b/mods/ITEMS/mcl_hoppers/init.lua @@ -5,7 +5,7 @@ local chest = minetest.get_content_id("mcl_chests:chest") local mcl_hoppers_formspec = "size[9,7]".. "background[-0.19,-0.25;9.41,10.48;mcl_hoppers_inventory.png]".. - mcl_core.inventory_header.. + mcl_vars.inventory_header.. "list[current_name;main;2,0.5;5,1;]".. "list[current_player;main;0,2.5;9,3;9]".. "list[current_player;main;0,5.74;9,1;]"..