summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2015-01-26 23:23:44 +0100
committerest31 <MTest31@outlook.com>2015-01-26 23:51:03 +0100
commit8b22593f5528e2d493d5dcb577634d3f7a1ce967 (patch)
tree721b8777447812bc90e52e13b597810a563d933e
parentfb98963810d37f0349d73cbe3808630d5f7b0b23 (diff)
downloadpipeworks-8b22593f5528e2d493d5dcb577634d3f7a1ce967.tar
pipeworks-8b22593f5528e2d493d5dcb577634d3f7a1ce967.tar.gz
pipeworks-8b22593f5528e2d493d5dcb577634d3f7a1ce967.tar.bz2
pipeworks-8b22593f5528e2d493d5dcb577634d3f7a1ce967.tar.xz
pipeworks-8b22593f5528e2d493d5dcb577634d3f7a1ce967.zip
Color up the enable/disable buttons for sorttube
-rwxr-xr-xcommon.lua13
-rw-r--r--textures/pipeworks_button_off.pngbin0 -> 7081 bytes
-rw-r--r--textures/pipeworks_button_on.pngbin0 -> 6838 bytes
-rwxr-xr-xtubes.lua13
4 files changed, 18 insertions, 8 deletions
diff --git a/common.lua b/common.lua
index b50b733..9be13d0 100755
--- a/common.lua
+++ b/common.lua
@@ -126,9 +126,18 @@ end
function fs_helpers.cycling_button(meta, base, meta_name, values)
local current_value = meta:get_int(meta_name)
local new_value = (current_value + 1) % (#values)
- local text = values[current_value + 1]
+ local val = values[current_value + 1]
+ local text
+ local texture_name = nil
+ --when we get a table, we know the caller wants an image_button
+ if type(val) == "table" then
+ text = val["text"]
+ texture_name = val["texture"]
+ else
+ text = val
+ end
local field = "fs_helpers_cycling:"..new_value..":"..meta_name
- return base..";"..field..";"..minetest.formspec_escape(text).."]"
+ return base..";"..(texture_name and texture_name..";" or "")..field..";"..minetest.formspec_escape(text).."]"
end
---------
diff --git a/textures/pipeworks_button_off.png b/textures/pipeworks_button_off.png
new file mode 100644
index 0000000..1933742
--- /dev/null
+++ b/textures/pipeworks_button_off.png
Binary files differ
diff --git a/textures/pipeworks_button_on.png b/textures/pipeworks_button_on.png
new file mode 100644
index 0000000..bb34ceb
--- /dev/null
+++ b/textures/pipeworks_button_on.png
Binary files differ
diff --git a/tubes.lua b/tubes.lua
index 531b4a4..39323a2 100755
--- a/tubes.lua
+++ b/tubes.lua
@@ -249,6 +249,12 @@ if pipeworks.enable_mese_tube then
end
end
end
+ local buttons_formspec = ""
+ for i = 0, 5 do
+ buttons_formspec = buttons_formspec .. fs_helpers.cycling_button(meta,
+ "image_button[7,"..(i)..";1,1", "l"..(i+1).."s",
+ {{text="",texture="pipeworks_button_off.png"}, {text="",texture="pipeworks_button_on.png"}})
+ end
meta:set_string("formspec",
"size[8,11]"..
"list[current_name;line1;1,0;6,1;]"..
@@ -263,12 +269,7 @@ if pipeworks.enable_mese_tube then
"image[0,3;1,1;pipeworks_yellow.png]"..
"image[0,4;1,1;pipeworks_blue.png]"..
"image[0,5;1,1;pipeworks_red.png]"..
- fs_helpers.cycling_button(meta, "button[7,0;1,1", "l1s", {"Off", "On"})..
- fs_helpers.cycling_button(meta, "button[7,1;1,1", "l2s", {"Off", "On"})..
- fs_helpers.cycling_button(meta, "button[7,2;1,1", "l3s", {"Off", "On"})..
- fs_helpers.cycling_button(meta, "button[7,3;1,1", "l4s", {"Off", "On"})..
- fs_helpers.cycling_button(meta, "button[7,4;1,1", "l5s", {"Off", "On"})..
- fs_helpers.cycling_button(meta, "button[7,5;1,1", "l6s", {"Off", "On"})..
+ buttons_formspec..
"list[current_player;main;0,7;8,4;]")
end
pipeworks.register_tube("pipeworks:mese_tube", "Sorting Pneumatic Tube Segment", mese_plain_textures, mese_noctr_textures,