Tablet Update

This commit is contained in:
Vitaliy olkhin 2025-02-04 18:15:45 +05:00
parent a2520e2932
commit 227377f411
7 changed files with 30 additions and 10 deletions

View File

@ -1,11 +1,27 @@
local S = minetest.get_translator("surface_effect")
local winsize = "size[15,10]"
local bgimage = "image[0,0;15,10;surface_effect_tablet_bg.png]"
surface_effect.display = {}
local version = "0.0.1"
local width = 15
local height = 10
local winsize = "size["..width..",".. height .."]"
local bgimage = "no_prepend[] bgcolor[#FFFFFF;true] background[0,-1;15,11;surface_effect_tablet_bg.png]"
surface_effect.display = {}
function surface_effect.display.main(player)
local function get_charge_indicator(power)
local arm = 65535 / 100
local percent = (65535 - (power - 65535))/arm
if percent > 55 then
return 3
elseif percent > 15 then
return 2
elseif percent < 10 then
return 1
end
return 0
end
function surface_effect.display.main(player, power)
local pos = player:get_pos()
local info_biome = minetest.get_biome_data(pos)
--minetest.log(dump(info_biome))
@ -13,9 +29,14 @@ function surface_effect.display.main(player)
"formspec_version[4]",
winsize,
bgimage,
"style[label;textcolor=green;size=2]",
"label[0.5,0.5;"..S("Software version: @1", version).."]",
"label[0.5,1.0;"..S("Air temperature: @1", math.floor(info_biome.heat)).."]",
"container[0,0]",
"style_type[label;textcolor=green;bgcolor=red]",
"label[1.0,0.5;"..S("Software version: @1", minetest.colorize("#FF0000", version)).."]",
"image[".. width - 2 ..",0.3;1.0,0.5;surface_effect_tablet_charge_level".. get_charge_indicator(power) .. ".png]",
"container_end[]",
"image[1.0,1.0;0.7,0.7;surface_effect_thermometer.png]",
"label[1.5,1.0;"..math.floor(info_biome.heat).."]",
"button[".. width / 2 .. ",".. height - 1 ..";0.5,0.5;home;|]"
--"style[weather;textcolor=black;size=2]",
--"image_button[0.5,0.5;1.5,1.5;surface_effect_weather_btn.png;weather;Weather]"
}
@ -46,14 +67,13 @@ minetest.register_tool("surface_effect:tablet", {
if charge > 0 then
technic.set_RE_wear(stack, charge, 65535)
meta:set_int("technic:charge", charge)
minetest.show_formspec(name, "surface_effect:display_main", surface_effect.display.main(player))
minetest.show_formspec(name, "surface_effect:display_main", surface_effect.display.main(player, charge))
--stack:set_stack()
end
minetest.log(dump(charge))
return stack
end,
})
if minetest.get_modpath("technic") then
technic.register_power_tool("surface_effect:tablet", 65535)
end
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 597 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 603 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 603 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB