function realchess.init(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
- local slots = "listcolors[#00000000;#00000000;#00000000;#30434C;#FFF]"
- local formspec
inv:set_size("board", 64)
-
- meta:set_string("formspec",
- "size[8,8.6;]"..
- "bgcolor[#080808BB;true]"..
- "background[0,0;8,8;chess_bg.png]"..
- "button[3.1,7.8;2,2;new;New game]"..
- "list[context;board;0,0;8,8;]"..
- slots)
+
+ local formspec = [[ size[8,8.6;]
+ bgcolor[#080808BB;true]
+ background[0,0;8,8;chess_bg.png]
+ button[3.1,7.8;2,2;new;New game]
+ list[context;board;0,0;8,8;]
+ listcolors[#00000000;#00000000;#00000000;#30434C;#FFF] ]]
+
+ meta:set_string("formspec", formspec)
meta:set_string("infotext", "Chess Board")
meta:set_string("playerBlack", "")
tooltip[fast;Your tool digs faster]
tooltip[strong;Your armor is more resistant]
tooltip[speed;Your speed is increased] ]]
+ ..default.gui_slots..default.get_hotbar_bg(0.5,4.5)
if tooltype == "sword" then
formspec = formspec.."image_button[3.9,2.9;4,0.92;bg_btn.png;sharp;Sharpness]"
image_button[3.9,1.77;4,1.12;bg_btn.png;speed;Speed] ]]
end
- meta:set_string("formspec", formspec..default.gui_slots..default.get_hotbar_bg(0.5,4.5))
+ meta:set_string("formspec", formspec)
return formspec
end
on_receive_fields = enchanting.fields,
on_metadata_inventory_put = enchanting.on_put,
allow_metadata_inventory_put = enchanting.put,
- allow_metadata_inventory_move = function(...) return 0 end,
+ allow_metadata_inventory_move = function() return 0 end,
on_metadata_inventory_take = function(pos, listname, _, _, _)
if listname == "tool" then
enchanting.formspec(pos, nil)
local default_inventory_size = 32
local default_inventory_formspecs = {
- ["8"] = "size[8,6]"..xbg..
- "list[context;main;0,0;8,1;]"..
- "list[current_player;main;0,2;8,4;]"..
- "listring[current_player;main]"..
- "listring[context;main]"..
- default.get_hotbar_bg(0, 2),
-
- ["16"] = "size[8,7]"..xbg..
- "list[context;main;0,0;8,2;]"..
- "list[current_player;main;0,3;8,4;]"..
- "listring[current_player;main]"..
- "listring[context;main]"..
- default.get_hotbar_bg(0, 3),
-
- ["24"] = "size[8,8]"..xbg..
- "list[context;main;0,0;8,3;]"..
- "list[current_player;main;0,4;8,4;]"..
- "listring[current_player;main]"..
- "listring[context;main]"..
- default.get_hotbar_bg(0, 4),
-
- ["32"] = "size[8,9]"..xbg..
- "list[context;main;0,0.3;8,4;]"..
- "list[current_player;main;0,4.85;8,1;]"..
- "list[current_player;main;0,6.08;8,3;8]"..
- "listring[current_player;main]"..
- "listring[context;main]"..
- default.get_hotbar_bg(0, 4.85)
+ ["8"] = [[ size[8,6]
+ list[context;main;0,0;8,1;]
+ list[current_player;main;0,2;8,4;]
+ listring[current_player;main]
+ listring[context;main] ]] ..
+ xbg..default.get_hotbar_bg(0,2),
+
+ ["16"] = [[ size[8,7]
+ list[context;main;0,0;8,2;]
+ list[current_player;main;0,3;8,4;]
+ listring[current_player;main]
+ listring[context;main] ]] ..
+ xbg..default.get_hotbar_bg(0,3),
+
+ ["24"] = [[ size[8,8]
+ list[context;main;0,0;8,3;]
+ list[current_player;main;0,4;8,4;]
+ listring[current_player;main]
+ listring[context;main]" ]] ..
+ xbg..default.get_hotbar_bg(0,4),
+
+ ["32"] = [[ size[8,9]
+ list[context;main;0,0.3;8,4;]
+ list[current_player;main;0,4.85;8,1;]
+ list[current_player;main;0,6.08;8,3;8]
+ listring[current_player;main]
+ listring[context;main] ]] ..
+ xbg..default.get_hotbar_bg(0,4.85)
}
local function get_formspec_by_size(size)
end
local function drop_stuff() -- thanks to LNJplus for this function
- local random = math.random
return function(pos, oldnode, oldmetadata, digger)
local meta = minetest.get_meta(pos)
meta:from_table(oldmetadata)
local stack = inv:get_stack("main", i)
if not stack:is_empty() then
local p = {
- x = pos.x + random(0,5) / 5 - 0.5,
+ x = pos.x + math.random(0,5) / 5 - 0.5,
y = pos.y,
- z = pos.z + random(0,5) / 5 - 0.5}
+ z = pos.z + math.random(0,5) / 5 - 0.5
+ }
minetest.add_item(p, stack)
end
end
local inv = meta:get_inventory()
local xbg = default.gui_bg..default.gui_bg_img..default.gui_slots..default.get_hotbar_bg(0,1.35)
- local formspec = "size[8,5;]"..xbg..
- "label[1.35,0;Bees are making honey\nwith pollen around...]"..
- "image[6,0;1,1;hive_bee.png]"..
- "image[5,0;1,1;hive_layout.png]"..
- "list[context;honey;5,0;1,1;]"..
- "list[current_player;main;0,1.35;8,4;]"
-
- meta:set_string("formspec", formspec)
+ local formspec = [[ size[8,5;]
+ label[1.35,0;Bees are making honey]
+ label[1.35,0.5;with pollen around...]
+ image[6,0;1,1;hive_bee.png]
+ image[5,0;1,1;hive_layout.png]
+ list[context;honey;5,0;1,1;]
+ list[current_player;main;0,1.35;8,4;] ]]
+
+ meta:set_string("formspec", formspec..xbg)
meta:set_string("infotext", "Artificial Hive")
inv:set_size("honey", 1)
end
local health = clicker:get_hp()
clicker:set_hp(health - 1)
end,
- allow_metadata_inventory_put = function(...) return 0 end
+ allow_metadata_inventory_put = function() return 0 end
})
minetest.register_abm({
end
end
- return "size[9.5,9]"..xbg..
- default.get_hotbar_bg(0.75,5.25)..
- "label[0,0;Mailbox]"..
- "label[6,0;Last donators]"..
- "box[6,0.72;3.3,3.5;#555555]"..
+ return [[ size[9.5,9]
+ label[0,0;Mailbox]
+ label[6,0;Last donators]
+ box[6,0.72;3.3,3.5;#555555]
+ listring[current_player;main]
+ list[current_player;main;0.75,5.25;8,4;]
+ tableoptions[background=#00000000;highlight=#00000000;border=false] ]]..
"tablecolumns[color;text;image,"..img.."0;color;text]"..
- "tableoptions[background=#00000000;highlight=#00000000;border=false]"..
"table[6,0.75;3.3,4;givers;"..giver.."]"..
"list[nodemeta:"..spos..";mailbox;0,0.75;6,4;]"..
- "list[current_player;main;0.75,5.25;8,4;]"..
"listring[nodemeta:"..spos..";mailbox]"..
- "listring[current_player;main]"
+ xbg..default.get_hotbar_bg(0.75,5.25)
else
- return "size[8,5]"..xbg..
- default.get_hotbar_bg(0,1.25)..
- "tablecolumns[color;text;color;text]"..
- "tableoptions[background=#00000000;highlight=#00000000;border=false]"..
+ return [[ size[8,5]
+ list[current_player;main;0,1.25;8,4;]
+ tablecolumns[color;text;color;text]
+ tableoptions[background=#00000000;highlight=#00000000;border=false] ]]..
"table[0,0;3,1;sendform;#FFFFFF,Send your goods to,,,#FFFF00,"..owner.."]"..
"list[nodemeta:"..spos..";drop;3.5,0;1,1;]"..
- "list[current_player;main;0,1.25;8,4;]"
+ xbg..default.get_hotbar_bg(0,1.25)
end
end
local inventory_size = #meta:to_table().inventory.inv_items_list
local pagemax = math.floor((inventory_size - 1) / (8*4) + 1)
- local formspec = "size[8,8;]"..xbg..
+ local formspec = [[ size[8,8;]
+ list[context;item_craft_input;3,6.3;1,1;]
+ tablecolumns[color;text;color;text]
+ tableoptions[background=#00000000;highlight=#00000000;border=false]
+ button[5.5,0;0.7,1;prev;<]
+ button[7.3,0;0.7,1;next;>]
+ button[4,0.2;0.7,0.5;search;?]
+ button[4.6,0.2;0.7,0.5;clearfilter;X]
+ button[0,0;1.5,1;backcraft;< Back]
+ tooltip[search;Search]
+ tooltip[clearfilter;Reset]
+ label[3,5.8;Input] ]]..
"list[context;inv_items_list;0,1;8,4;"..tostring(start_i).."]"..
- "list[context;item_craft_input;3,6.3;1,1;]"..
- "tablecolumns[color;text;color;text]"..
- "tableoptions[background=#00000000;highlight=#00000000;border=false]"..
"table[6.1,0.2;1.1,0.5;pagenum;#FFFF00,"..tostring(math.floor(pagenum))..
",#FFFFFF,/ "..tostring(pagemax).."]"..
- "button[5.5,0;0.7,1;prev;<]"..
- "button[7.3,0;0.7,1;next;>]"..
- "button[4,0.2;0.7,0.5;search;?]"..
- "button[4.6,0.2;0.7,0.5;clearfilter;X]"..
- "button[0,0;1.5,1;backcraft;< Back]"..
- "tooltip[search;Search]"..
- "tooltip[clearfilter;Reset]"..
- "label[3,5.8;Input]"..
- "field[1.8,0.32;2.6,1;filter;;"..filter.."]"
+ "field[1.8,0.32;2.6,1;filter;;"..filter.."]"..xbg
if stackname then
local items_num = #minetest.get_all_craft_recipes(stackname)
local stack_count = stack_output:match("%s(%d+)")
if items_num > 1 then
- formspec = formspec..
- "button[0,5.7;1.6,1;alternate;Alternate]"..
+ formspec = formspec.."button[0,5.7;1.6,1;alternate;Alternate]"..
"label[0,5.2;Recipe "..recipe_num.." of "..items_num.."]"
end
end
elseif stack_width == 3 then
if stack_type == "cooking" then
- formspec = formspec.."list[context;craft_output_recipe;5,6.3;1,1;]"..
- "image[4.25,5.9;0.5,0.5;default_furnace_fire_fg.png]"
+ formspec = formspec..[[ list[context;craft_output_recipe;5,6.3;1,1;]
+ image[4.25,5.9;0.5,0.5;default_furnace_fire_fg.png] ]]
inv:set_size("craft_output_recipe", 1)
else
formspec = formspec.."list[context;craft_output_recipe;5,5.3;3,3;]"
inv:set_size("craft_output_recipe", 3*3)
end
elseif stack_type == "cooking" and stack_width > 3 then
- formspec = formspec..
- "list[context;craft_output_recipe;5,6.3;1,1;]"..
- "image[4.25,5.9;0.5,0.5;default_furnace_fire_fg.png]"
+ formspec = formspec..[[ list[context;craft_output_recipe;5,6.3;1,1;]
+ image[4.25,5.9;0.5,0.5;default_furnace_fire_fg.png] ]]
inv:set_size("craft_output_recipe", 1)
end
def = def:gsub("group", "default")
else
for node, definition in pairs(minetest.registered_items) do
- for group in pairs(definition.groups) do
- if group == def:match("^group:([%w_]+)$") then
- inv:set_stack("craft_output_recipe", k, node)
- end
+ for group in pairs(definition.groups) do
+ if def:match("^group:"..group.."$") then
+ inv:set_stack("craft_output_recipe", k, node)
end
end
+ end
end
end
end
end
end
- formspec = formspec..
- "image[4,6.3;1,1;gui_furnace_arrow_bg.png^[transformR90]"..
- "button[0,6.5;1.6,1;trash;Clear]"..
- "label[0,7.5;"..stackname:sub(1,30).."]"
+ formspec = formspec..[[ image[4,6.3;1,1;gui_furnace_arrow_bg.png^[transformR90]
+ button[0,6.5;1.6,1;trash;Clear] ]]..
+ "label[0,7.5;"..stackname:sub(1,30).."]"
end
meta:set_string("formspec", formspec)
list[current_player;craftpreview;6,1;1,1;]
listring[current_player;main]
listring[current_player;craft] ]]
+ ..xbg..default.get_hotbar_bg(0,3.3)
- meta:set_string("formspec", formspec..xbg..default.get_hotbar_bg(0,3.3))
+ meta:set_string("formspec", formspec)
end
function worktable.storage(pos)
listring[context;storage]
listring[current_player;main]
button[0,0;1.5,1;back;< Back] ]]
+ ..xbg..default.get_hotbar_bg(0,3.25)
- meta:set_string("formspec", formspec..xbg..default.get_hotbar_bg(0,3.25))
+ meta:set_string("formspec", formspec)
end
function worktable.main(pos)
list[current_player;main;0,3.25;8,4;]
button[0,0;2,1;craft;Crafting]
button[2,0;2,1;storage;Storage] ]]
+ ..xbg..default.get_hotbar_bg(0,3.25)
- meta:set_string("formspec", formspec..xbg..default.get_hotbar_bg(0,3.25))
+ meta:set_string("formspec", formspec)
end
function worktable.construct(pos)