Put back formspec's code readability

This commit is contained in:
jp 2015-11-26 12:19:52 +01:00
parent afdbfc316f
commit a1f8e9e6bf
4 changed files with 55 additions and 14 deletions

View File

@ -3,17 +3,34 @@ screwdriver = screwdriver or {}
function enchanting.formspec(pos, tooltype) function enchanting.formspec(pos, tooltype)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local formspec = "size[9,9;]"..default.gui_slots..default.get_hotbar_bg(0.5,4.5).. local formspec = "size[9,9;]"..
"bgcolor[#080808BB;true]background[0,0;9,9;ench_ui.png]list[context;tool;0.9,2.9;1,1;]list[context;mese;2,2.9;1,1;]image[2,2.9;1,1;mese_layout.png]list[current_player;main;0.5,4.5;8,4;]tooltip[sharp;Your sword kills faster]tooltip[durable;Your tool lasts longer]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)..
"bgcolor[#080808BB;true]"..
"background[0,0;9,9;ench_ui.png]"..
"list[context;tool;0.9,2.9;1,1;]"..
"list[context;mese;2,2.9;1,1;]"..
"image[2,2.9;1,1;mese_layout.png]"..
"list[current_player;main;0.5,4.5;8,4;]"..
"tooltip[sharp;Your sword kills faster]"..
"tooltip[durable;Your tool lasts longer]"..
"tooltip[fast;Your tool digs faster]"..
"tooltip[strong;Your armor is more resistant]"..
"tooltip[speed;Your speed is increased]"
if tooltype == "sword" then if tooltype == "sword" then
formspec = formspec.."image_button[3.9,2.9;4,0.92;bg_btn.png;sharp;Sharpness]" formspec = formspec..
"image_button[3.9,2.9;4,0.92;bg_btn.png;sharp;Sharpness]"
elseif tooltype == "tool" then elseif tooltype == "tool" then
formspec = formspec.."image_button[3.9,0.85;4,0.92;bg_btn.png;fast;Efficiency]image_button[3.9,1.77;4,1.12;bg_btn.png;durable;Durability]" formspec = formspec..
"image_button[3.9,0.85;4,0.92;bg_btn.png;fast;Efficiency]"..
"image_button[3.9,1.77;4,1.12;bg_btn.png;durable;Durability]"
elseif tooltype == "armor" then elseif tooltype == "armor" then
formspec = formspec.."image_button[3.9,0.85;4,0.92;bg_btn.png;strong;Strength]" formspec = formspec..
"image_button[3.9,0.85;4,0.92;bg_btn.png;strong;Strength]"
elseif tooltype == "boots" then elseif tooltype == "boots" then
formspec = formspec.."image_button[3.9,0.85;4,0.92;bg_btn.png;strong;Strength]image_button[3.9,1.77;4,1.12;bg_btn.png;speed;Speed]" formspec = formspec..
"image_button[3.9,0.85;4,0.92;bg_btn.png;strong;Strength]"..
"image_button[3.9,1.77;4,1.12;bg_btn.png;speed;Speed]"
end end
meta:set_string("formspec", formspec) meta:set_string("formspec", formspec)
@ -202,7 +219,6 @@ for _, ench in pairs(tooldef[3]) do
end end
end end
minetest.register_alias("xdecor:enchanted_"..tool.."_"..material.."_"..enchant, mod..":enchanted_"..tool.."_"..material.."_"..enchant) minetest.register_alias("xdecor:enchanted_"..tool.."_"..material.."_"..enchant, mod..":enchanted_"..tool.."_"..material.."_"..enchant)
minetest.register_alias(":"..mod..":enchanted_"..tool.."_"..material.."_"..enchant, mod..":enchanted_"..tool.."_"..material.."_"..enchant)
end end
end end
end end

View File

@ -6,7 +6,11 @@ function hive.construct(pos)
local xbg = default.gui_bg..default.gui_bg_img..default.gui_slots..default.get_hotbar_bg(0,1.35) 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.. 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;]" "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) meta:set_string("formspec", formspec)
meta:set_string("infotext", "Artificial Hive") meta:set_string("infotext", "Artificial Hive")

View File

@ -102,8 +102,10 @@ function mailbox.formspec(pos, owner, num)
end end
end end
return "size[9.5,9]"..xbg..default.get_hotbar_bg(0.75,5.25).. return "size[9.5,9]"..xbg..
"label[0,0;Mailbox :]label[6,0;Last donators :]".. default.get_hotbar_bg(0.75,5.25)..
"label[0,0;Mailbox :]"..
"label[6,0;Last donators :]"..
"tablecolumns[color;text;image,".. "tablecolumns[color;text;image,"..
"1="..img_col(def_stack1)..",".. "1="..img_col(def_stack1)..","..
"2="..img_col(def_stack2)..",".. "2="..img_col(def_stack2)..","..
@ -117,7 +119,8 @@ function mailbox.formspec(pos, owner, num)
"list[nodemeta:"..spos..";mailbox;0,0.75;6,4;]".. "list[nodemeta:"..spos..";mailbox;0,0.75;6,4;]"..
"list[current_player;main;0.75,5.25;8,4;]" "list[current_player;main;0.75,5.25;8,4;]"
else else
return "size[8,5]"..xbg..default.get_hotbar_bg(0,1.25).. return "size[8,5]"..xbg..
default.get_hotbar_bg(0,1.25)..
"label[0.5,0;Send your goods\nto "..owner.." :]".. "label[0.5,0;Send your goods\nto "..owner.." :]"..
"list[nodemeta:"..spos..";drop;3.5,0;1,1;]".. "list[nodemeta:"..spos..";drop;3.5,0;1,1;]"..
"list[current_player;main;0,1.25;8,4;]" "list[current_player;main;0,1.25;8,4;]"

View File

@ -36,13 +36,18 @@ local def = { -- Nodebox name, yield, definition.
function worktable.crafting() function worktable.crafting()
return "size[8,7;]"..xbg.. return "size[8,7;]"..xbg..
"list[current_player;main;0,3.3;8,4;]image[5,1;1,1;gui_furnace_arrow_bg.png^[transformR270]list[current_player;craft;2,0;3,3;]list[current_player;craftpreview;6,1;1,1;]" "list[current_player;main;0,3.3;8,4;]"..
"image[5,1;1,1;gui_furnace_arrow_bg.png^[transformR270]"..
"list[current_player;craft;2,0;3,3;]"..
"list[current_player;craftpreview;6,1;1,1;]"
end end
function worktable.storage(pos) function worktable.storage(pos)
local inv = minetest.get_meta(pos):get_inventory() local inv = minetest.get_meta(pos):get_inventory()
inv:set_size("storage", 8*2) inv:set_size("storage", 8*2)
return "size[8,7]"..xbg.."list[context;storage;0,0;8,2;]list[current_player;main;0,3.25;8,4;]" return "size[8,7]"..xbg..
"list[context;storage;0,0;8,2;]"..
"list[current_player;main;0,3.25;8,4;]"
end end
function worktable.construct(pos) function worktable.construct(pos)
@ -50,7 +55,20 @@ function worktable.construct(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
local formspec = "size[8,7;]"..xbg.. local formspec = "size[8,7;]"..xbg..
"list[context;forms;4,0;4,3;]label[0.95,1.23;Cut]box[-0.05,1;2.05,0.9;#555555]image[3,1;1,1;gui_furnace_arrow_bg.png^[transformR270]label[0.95,2.23;Repair]box[-0.05,2;2.05,0.9;#555555]image[0,1;1,1;worktable_saw.png]image[0,2;1,1;worktable_anvil.png]image[3,2;1,1;hammer_layout.png]list[context;input;2,1;1,1;]list[context;tool;2,2;1,1;]list[context;hammer;3,2;1,1;]button[0,0;2,1;craft;Crafting]button[2,0;2,1;storage;Storage]list[current_player;main;0,3.25;8,4;]" "list[context;forms;4,0;4,3;]"..
"label[0.95,1.23;Cut]"..
"box[-0.05,1;2.05,0.9;#555555]"..
"image[3,1;1,1;gui_furnace_arrow_bg.png^[transformR270]"..
"label[0.95,2.23;Repair]box[-0.05,2;2.05,0.9;#555555]"..
"image[0,1;1,1;worktable_saw.png]"..
"image[0,2;1,1;worktable_anvil.png]"..
"image[3,2;1,1;hammer_layout.png]"..
"list[context;input;2,1;1,1;]"..
"list[context;tool;2,2;1,1;]"..
"list[context;hammer;3,2;1,1;]"..
"button[0,0;2,1;craft;Crafting]"..
"button[2,0;2,1;storage;Storage]"..
"list[current_player;main;0,3.25;8,4;]"
inv:set_size("forms", 4*3) inv:set_size("forms", 4*3)
inv:set_size("input", 1) inv:set_size("input", 1)