diff --git a/mods/achievements/init.lua b/mods/achievements/init.lua index a279cf9..3bb18a3 100644 --- a/mods/achievements/init.lua +++ b/mods/achievements/init.lua @@ -173,10 +173,10 @@ minetest.register_on_placenode(on_place) -- Formspecs -local form = default.ui.get_page("core") +local form = default.ui.get_page("default:default") form = form .. "tableoptions[background=#DDDDDD30]" form = form .. "tablecolumns[text,align=left,width=11;text,align=left,width=28;text,align=left,width=5]" -default.ui.register_page("core_achievements", form) +default.ui.register_page("achievements:achievements", form) function achievements.get_formspec(name, row) if not row then row = 1 end @@ -211,7 +211,7 @@ function achievements.get_formspec(name, row) achievement_list = achievement_list .. progress end - local form = default.ui.get_page("core_achievements") + local form = default.ui.get_page("achievements:achievements") form = form .. "table[0.25,2.5;7.75,5.5;achievement_list;" .. achievement_list .. ";" .. row .. "]" @@ -242,7 +242,7 @@ end local function receive_fields(player, form_name, fields) local name = player:get_player_name() - if form_name ~= "core_achievements" then return end + if form_name ~= "achievements:achievements" then return end if fields.quit then return end @@ -256,7 +256,7 @@ local function receive_fields(player, form_name, fields) end end - minetest.show_formspec(name, "core_achievements", achievements.get_formspec(name, selected)) + minetest.show_formspec(name, "achievements:achievements", achievements.get_formspec(name, selected)) end minetest.register_on_player_receive_fields(receive_fields) diff --git a/mods/armor/init.lua b/mods/armor/init.lua index 0d0a987..fd0e384 100644 --- a/mods/armor/init.lua +++ b/mods/armor/init.lua @@ -6,7 +6,7 @@ armor = {} armor.player_skin = "character.png" -armor.update_time = 1 +armor.update_time = 3 armor.materials = { -- material craftitem % description @@ -18,8 +18,8 @@ armor.materials = { armor.slots = {"helmet", "chestplate", "boots"} -local form_armor = default.ui.get_page("core_2part") -default.ui.register_page("core_armor", form_armor) +local form_armor = default.ui.get_page("default:2part") +default.ui.register_page("armor:armor", form_armor) local enable_drop = minetest.setting_getbool("drop_items_on_die") or false @@ -87,7 +87,7 @@ function armor.get_groups(player) if armor.is_armor(itemname) then local item = minetest.registered_items[itemname] - + for mat_index, _ in ipairs(armor.materials) do local mat = armor.materials[mat_index][1] @@ -158,7 +158,7 @@ local function on_die(player) } local drop = minetest.add_item(rpos, item) - + if drop then drop:setvelocity( { @@ -190,7 +190,7 @@ minetest.register_craftitem( description = "Chainmail sheet", inventory_image = "armor_chainmail.png", - wield_image = "armor_chainmail.png", + wield_image = "armor_chainmail.png", stack_max = 20, }) @@ -264,12 +264,14 @@ end minetest.register_on_newplayer(on_newplayer) minetest.register_on_joinplayer(on_joinplayer) + if enable_drop then minetest.register_on_dieplayer(on_die) end + minetest.register_globalstep(step) -local form_armor = default.ui.get_page("core_2part") +local form_armor = default.ui.get_page("default:2part") form_armor = form_armor .. "list[current_player;main;0.25,4.75;8,4;]" form_armor = form_armor .. default.ui.get_hotbar_itemslot_bg(0.25, 4.75, 8, 1) form_armor = form_armor .. default.ui.get_itemslot_bg(0.25, 5.75, 8, 3) @@ -290,7 +292,7 @@ form_armor = form_armor .. "list[current_player;armor_helmet;2.25,0.75;1,1;]" form_armor = form_armor .. "listring[current_player;armor_helmet]" form_armor = form_armor .. default.ui.get_itemslot_bg(2.25, 0.75, 1, 1) -default.ui.register_page("core_armor", form_armor) +default.ui.register_page("armor:armor", form_armor) -- Achievements @@ -312,4 +314,4 @@ achievements.register_achievement( craftitem = "group:is_armor", }) -default.log("mod:armor", "loaded") \ No newline at end of file +default.log("mod:armor", "loaded") diff --git a/mods/book/init.lua b/mods/book/init.lua index 2f40895..0442f61 100644 --- a/mods/book/init.lua +++ b/mods/book/init.lua @@ -22,7 +22,7 @@ minetest.register_craftitem( title = data.title end - local form = default.ui.get_page("core_notabs") + local form = default.ui.get_page("default:notabs") form = form .. "field[0.5,1.25;8,0;title;Title:;"..minetest.formspec_escape(title).."]" form = form .. "textarea[0.5,1.75;8,6.75;text;Contents:;"..minetest.formspec_escape(text).."]" form = form .. default.ui.button_exit(2.75, 7.75, 3, 1, "write", "Write") @@ -41,7 +41,7 @@ minetest.register_on_player_receive_fields( if not data then data = {} end data.text = fields.text data.title = fields.title - + itemstack:set_metadata(minetest.serialize(data)) player:set_wielded_item(itemstack) end) @@ -57,4 +57,4 @@ achievements.register_achievement( craftitem = "default:book", }) -default.log("mod:book", "loaded") \ No newline at end of file +default.log("mod:book", "loaded") diff --git a/mods/crafting/init.lua b/mods/crafting/init.lua index 5645c46..c20127b 100644 --- a/mods/crafting/init.lua +++ b/mods/crafting/init.lua @@ -15,6 +15,7 @@ crafting.default_craftdef = { output = nil, description = "", items = {}, + groups = {}, } function crafting.register_craft(output, def) @@ -33,7 +34,8 @@ function crafting.register_craft(output, def) local craftdef = { output = itemstack, description = def.description or minetest.registered_items[itemn].description, - items = def.items or default.default_craftdef.items, + items = def.items or crafting.default_craftdef.items, + groups = def.groups or crafting.default_craftdef.groups, } if #craftdef.items > 4 then @@ -143,6 +145,28 @@ function crafting.craft(output, items) return items end +local form = default.ui.get_page("default:2part") +form = form .. "list[current_player;main;0.25,4.75;8,4;]" +form = form .. "listring[current_player;main]" +form = form .. default.ui.get_hotbar_itemslot_bg(0.25, 4.75, 8, 1) +form = form .. default.ui.get_itemslot_bg(0.25, 5.75, 8, 3) + +form = form .. "list[current_player;craft;2.25,0.75;3,3;]" +form = form .. "listring[current_player;craft]" + +form = form .. "image[5.25,1.75;1,1;ui_arrow_bg.png^[transformR270]" + +form = form .. "list[current_player;craftpreview;6.25,1.75;1,1;]" +form = form .. default.ui.get_itemslot_bg(2.25, 0.75, 3, 3) +form = form .. default.ui.get_itemslot_bg(6.25, 1.75, 1, 1) +default.ui.register_page("crafting:crafting", form) + +function crafting.get_formspec(name) + local form = default.ui.get_page("crafting:crafting") + + return form +end + crafting.register_craft( "default:stone 4", { @@ -156,14 +180,14 @@ crafting.register_craft( crafting.craft( "default:stone 2", { - {name = "default:stick", count = 4}, -- 0 leftover + "default:stick 4", -- 0 leftover {name = "default:stick", count = 5}, -- 3 leftover - {name = "default:fiber", count = 9}, -- 5 leftover + "default:fiber 9", -- 5 leftover {name = "group:stone", count = 4}, -- 0 leftover }) local function on_player_recieve_fields(player, form_name, fields) - if form_name ~= "crafting:crafting" or fields.cancel then return end + if form_name ~= "core:crafting" or fields.cancel then return end local inv = player:get_inventory() diff --git a/mods/default/formspec.lua b/mods/default/formspec.lua index 1289ca2..6cc31d1 100644 --- a/mods/default/formspec.lua +++ b/mods/default/formspec.lua @@ -1,9 +1,9 @@ default.ui = {} -default.ui.core = {} +default.ui.default = {} -default.ui.core.colors = "listcolors[#00000000;#00000010;#00000000;#68B259;#FFF]" -default.ui.core.bg = "bgcolor[#00000000;false]" +default.ui.default.colors = "listcolors[#00000000;#00000010;#00000000;#68B259;#FFF]" +default.ui.default.bg = "bgcolor[#00000000;false]" function default.ui.get_itemslot_bg(x, y, w, h) local out = "" @@ -166,58 +166,42 @@ function default.ui.register_page(name, form) default.ui.registered_pages[name] = form end -local form_core = "" -form_core = form_core .. "size[8.5,9]" -form_core = form_core .. default.ui.core.colors -form_core = form_core .. default.ui.core.bg -form_core = form_core .. default.ui.tab(-0.9, 0.5, "tab_crafting", "ui_icon_crafting.png", "Crafting") +local form_default_default = "" +form_default_default = form_default_default .. "size[8.5,9]" +form_default_default = form_default_default .. default.ui.default.colors +form_default_default = form_default_default .. default.ui.default.bg +form_default_default = form_default_default .. default.ui.tab(-0.9, 0.5, "tab_crafting", "ui_icon_crafting.png", "Crafting") if minetest.get_modpath("armor") ~= nil then - form_core = form_core .. default.ui.tab(-0.9, 1.28, "tab_armor", "ui_icon_armor.png", "Armor") + form_default_default = form_default_default .. default.ui.tab(-0.9, 1.28, "tab_armor", "ui_icon_armor.png", "Armor") end if minetest.get_modpath("achievements") ~= nil then - form_core = form_core .. default.ui.tab(-0.9, 2.06, "tab_achievements", "ui_icon_achievements.png", "Achievements") + form_default_default = form_default_default .. default.ui.tab(-0.9, 2.06, "tab_achievements", "ui_icon_achievements.png", "Achievements") end if minetest.get_modpath("player_skins") ~= nil then - form_core = form_core .. default.ui.tab(-0.9, 2.84, "tab_player_skins", "ui_icon_player_skins.png", "Player Skins") + form_default_default = form_default_default .. default.ui.tab(-0.9, 2.84, "tab_player_skins", "ui_icon_player_skins.png", "Player Skins") end -form_core = form_core .. "background[0,0;8.5,9;ui_formspec_bg_tall.png]" -default.ui.register_page("core", form_core) -default.ui.register_page("core_2part", form_core .. "background[0,0;8.5,4.5;ui_formspec_bg_short.png]") +form_default_default = form_default_default .. "background[0,0;8.5,9;ui_formspec_bg_tall.png]" +default.ui.register_page("default:default", form_default_default) +default.ui.register_page("default:2part", form_default_default .. "background[0,0;8.5,4.5;ui_formspec_bg_short.png]") -local form_core_notabs = "" -form_core_notabs = form_core_notabs .. "size[8.5,9]" -form_core_notabs = form_core_notabs .. default.ui.core.colors -form_core_notabs = form_core_notabs .. default.ui.core.bg -form_core_notabs = form_core_notabs .. "background[0,0;8.5,9;ui_formspec_bg_tall.png]" -default.ui.register_page("core_notabs", form_core_notabs) -default.ui.register_page("core_notabs_2part", form_core_notabs .. "background[0,0;8.5,4.5;ui_formspec_bg_short.png]") +local form_default_notabs = "" +form_default_notabs = form_default_notabs .. "size[8.5,9]" +form_default_notabs = form_default_notabs .. default.ui.default.colors +form_default_notabs = form_default_notabs .. default.ui.default.bg +form_default_notabs = form_default_notabs .. "background[0,0;8.5,9;ui_formspec_bg_tall.png]" +default.ui.register_page("default:notabs", form_default_notabs) +default.ui.register_page("default:notabs_2part", form_default_notabs .. "background[0,0;8.5,4.5;ui_formspec_bg_short.png]") -local form_core_field = "" -form_core_field = form_core_field .. "size[8.5,5]" -form_core_field = form_core_field .. default.ui.core.colors -form_core_field = form_core_field .. default.ui.core.bg -form_core_field = form_core_field .. "background[0,0;8.5,4.5;ui_formspec_bg_short.png]" -form_core_field = form_core_field .. default.ui.button_exit(2.75, 3, 3, 1, "", "Write", false) -form_core_field = form_core_field .. "field[1,1.75;7,0;text;;${text}]" -default.ui.register_page("core_field", form_core_field) +local form_default_field = "" +form_default_field = form_default_field .. "size[8.5,5]" +form_default_field = form_default_field .. default.ui.default.colors +form_default_field = form_default_field .. default.ui.default.bg +form_default_field = form_default_field .. "background[0,0;8.5,4.5;ui_formspec_bg_short.png]" +form_default_field = form_default_field .. default.ui.button_exit(2.75, 3, 3, 1, "", "Write", false) +form_default_field = form_default_field .. "field[1,1.75;7,0;text;;${text}]" +default.ui.register_page("default:field", form_default_field) -local form_crafting = default.ui.get_page("core_2part") -form_crafting = form_crafting .. "list[current_player;main;0.25,4.75;8,4;]" -form_crafting = form_crafting .. "listring[current_player;main]" -form_crafting = form_crafting .. default.ui.get_hotbar_itemslot_bg(0.25, 4.75, 8, 1) -form_crafting = form_crafting .. default.ui.get_itemslot_bg(0.25, 5.75, 8, 3) - -form_crafting = form_crafting .. "list[current_player;craft;2.25,0.75;3,3;]" -form_crafting = form_crafting .. "listring[current_player;craft]" - -form_crafting = form_crafting .. "image[5.25,1.75;1,1;ui_arrow_bg.png^[transformR270]" - -form_crafting = form_crafting .. "list[current_player;craftpreview;6.25,1.75;1,1;]" -form_crafting = form_crafting .. default.ui.get_itemslot_bg(2.25, 0.75, 3, 3) -form_crafting = form_crafting .. default.ui.get_itemslot_bg(6.25, 1.75, 1, 1) -default.ui.register_page("core_crafting", form_crafting) - -local form_bookshelf = default.ui.get_page("core_2part") +local form_bookshelf = default.ui.get_page("default:2part") form_bookshelf = form_bookshelf .. "list[current_player;main;0.25,4.75;8,4;]" form_bookshelf = form_bookshelf .. "listring[current_player;main]" form_bookshelf = form_bookshelf .. default.ui.get_hotbar_itemslot_bg(0.25, 4.75, 8, 1) @@ -226,7 +210,7 @@ form_bookshelf = form_bookshelf .. default.ui.get_itemslot_bg(0.25, 5.75, 8, 3) form_bookshelf = form_bookshelf .. "list[current_name;main;2.25,1.25;4,2;]" form_bookshelf = form_bookshelf .. "listring[current_name;main]" form_bookshelf = form_bookshelf .. default.ui.get_itemslot_bg(2.25, 1.25, 4, 2) -default.ui.register_page("core_bookshelf", form_bookshelf) +default.ui.register_page("default:bookshelf", form_bookshelf) function default.ui.receive_fields(player, form_name, fields) local name = player:get_player_name() @@ -234,13 +218,13 @@ function default.ui.receive_fields(player, form_name, fields) -- print("Received formspec fields from '"..name.."': "..dump(fields)) if fields.tab_crafting then - minetest.show_formspec(name, "core_crafting", default.ui.get_page("core_crafting")) + minetest.show_formspec(name, "crafting:crafting", crafting.get_formspec(name)) elseif minetest.get_modpath("armor") ~= nil and fields.tab_armor then - minetest.show_formspec(name, "core_armor", default.ui.get_page("core_armor")) + minetest.show_formspec(name, "armor:armor", default.ui.get_page("armor:armor")) elseif minetest.get_modpath("achievements") ~= nil and fields.tab_achievements then - minetest.show_formspec(name, "core_achievements", achievements.get_formspec(name)) + minetest.show_formspec(name, "achievements:achievements", achievements.get_formspec(name)) elseif minetest.get_modpath("player_skins") ~= nil and fields.tab_player_skins then - minetest.show_formspec(name, "core_player_skins", player_skins.get_formspec(name)) + minetest.show_formspec(name, "player_skins:player_skins", player_skins.get_formspec(name)) end end @@ -251,5 +235,5 @@ end) minetest.register_on_joinplayer( function(player) - player:set_inventory_formspec(default.ui.get_page("core_crafting")) + player:set_inventory_formspec(default.ui.get_page("crafting:crafting")) end) diff --git a/mods/gold/init.lua b/mods/gold/init.lua index 14e09f0..657f198 100644 --- a/mods/gold/init.lua +++ b/mods/gold/init.lua @@ -131,7 +131,7 @@ end local form_trading = "" -form_trading = form_trading .. default.ui.get_page("core_2part") +form_trading = form_trading .. default.ui.get_page("default:2part") form_trading = form_trading .. "list[current_player;gold_trade_out;3.75,2.25;1,1;]" form_trading = form_trading .. "listring[current_player;gold_trade_out]" diff --git a/mods/jewels/init.lua b/mods/jewels/init.lua index ff93e2d..22da4b9 100644 --- a/mods/jewels/init.lua +++ b/mods/jewels/init.lua @@ -99,7 +99,7 @@ function jewels.register_jewel(toolname, new_toolname, def) end end - new_tooldef.description = desc + new_tooldef.description = desc minetest.register_tool(new_toolname, new_tooldef) end @@ -156,7 +156,7 @@ minetest.register_node( end, on_punch = function(pos, node, player, pointed_thing) local itemstack = player:get_wielded_item() - + if itemstack:get_name() == "jewels:jewel" then local meta = minetest.get_meta(pos) local inv = meta:get_inventory() @@ -170,7 +170,7 @@ minetest.register_node( achievements.trigger_achievement(player, "jeweler") achievements.trigger_achievement(player, "master_jeweler") - end + end end player:set_wielded_item(itemstack) @@ -187,7 +187,7 @@ minetest.register_craft( } }) -local form_bench = default.ui.get_page("core_2part") +local form_bench = default.ui.get_page("default:2part") form_bench = form_bench .. "list[current_name;main;2.25,1.75;1,1;]" form_bench = form_bench .. "listring[current_name;main]" form_bench = form_bench .. default.ui.get_itemslot_bg(2.25, 1.75, 1, 1) diff --git a/mods/locks/init.lua b/mods/locks/init.lua index 745c90a..2cc2675 100644 --- a/mods/locks/init.lua +++ b/mods/locks/init.lua @@ -134,7 +134,7 @@ minetest.register_node( end local np = pos.x .. "," .. pos.y .. "," .. pos.z - local form = default.ui.get_page("core_2part") + local form = default.ui.get_page("default:2part") form = form .. "list[nodemeta:" .. np .. ";main;0.25,0.25;8,4;]" form = form .. "listring[nodemeta:" .. np .. ";main]" form = form .. default.ui.get_itemslot_bg(0.25, 0.25, 8, 4) diff --git a/mods/player_skins/init.lua b/mods/player_skins/init.lua index 724b463..18d9622 100644 --- a/mods/player_skins/init.lua +++ b/mods/player_skins/init.lua @@ -16,7 +16,7 @@ player_skins.skins = {} local update_time = 1 local timer = 10 -local skins_file = minetest.get_worldpath() .. "/player_skins" +local skins_file = minetest.get_worldpath() .. "/player_skins.dat" local function save_skins() local f = io.open(skins_file, "w") @@ -60,7 +60,7 @@ end function player_skins.get_skin(name) return "player_skins_" .. player_skins.skins[name] .. ".png" end - + function player_skins.set_skin(name, tex) if minetest.check_player_privs(name, {player_skin = true}) then if is_valid_skin(tex) then @@ -115,7 +115,7 @@ local function get_chatparams() end function player_skins.get_formspec(playername) - local form = default.ui.get_page("core") + local form = default.ui.get_page("default:default") form = form .. "image[4,0;0.5,10.05;ui_vertical_divider.png]" @@ -129,7 +129,7 @@ function player_skins.get_formspec(playername) end form = form .. default.ui.button(x, y, 2, 1, "skin_select_" .. name, player_skins.skin_names[i]) - form = form .. "image[" .. (x + 2.25) .. "," .. y.. ";1,1;player_skins_icon_" .. name .. ".png]" + form = form .. "image[" .. (x + 2.25) .. "," .. y.. ";1,1;player_skins_icon_" .. name .. ".png]" if player_skins.skins[playername] == name then form = form .. "image[" .. (x + 3.25) .. "," .. (y + 0.25).. ";0.5,0.5;ui_checkmark.png]" end @@ -148,7 +148,7 @@ minetest.register_on_player_receive_fields( if skinname ~= nil then player_skins.set_skin(name, skinname) - minetest.show_formspec(name, "core_player_skins", player_skins.get_formspec(name)) + minetest.show_formspec(name, "player_skins:player_skins", player_skins.get_formspec(name)) end end end) @@ -164,7 +164,7 @@ minetest.register_chatcommand( if is_valid_skin(param) then player_skins.set_skin(name, param) elseif param == "" then - minetest.chat_send_player(name, "Current player skin: " .. player_skins.skins[name]) + minetest.chat_send_player(name, "Current player skin: " .. player_skins.skins[name]) else minetest.chat_send_player(name, "Bad param for /player_skin; type /help player_skin") end @@ -173,4 +173,4 @@ minetest.register_chatcommand( minetest.after(1.0, load_skins) -default.log("mod:player_skins", "loaded") \ No newline at end of file +default.log("mod:player_skins", "loaded") diff --git a/mods/welcome/init.lua b/mods/welcome/init.lua index 1ef89ac..7f96a33 100644 --- a/mods/welcome/init.lua +++ b/mods/welcome/init.lua @@ -20,7 +20,7 @@ function welcome.get_formspec(name) return "" end - local form = default.ui.get_page("core_notabs") + local form = default.ui.get_page("default:notabs") local rules = ""