Fixed formspec for Mineclone.

This commit is contained in:
SFENCE 2022-10-25 18:29:31 +02:00
parent f97ef41d0b
commit 5b5be168c6
6 changed files with 27 additions and 50 deletions

View File

@ -95,11 +95,6 @@ ce_gearbox:control_data_register(
-- Formspec --
--------------
local player_inv = "list[current_player;main;1.5,3.5;8,4;]";
if minetest.get_modpath("hades_core") then
player_inv = "list[current_player;main;0.5,3.5;10,4;]";
end
--function ce_gearbox:get_formspec(meta, production_percent, consumption_percent)
function ce_gearbox:get_formspec(_meta, _, consumption_percent)
local progress;
@ -113,12 +108,12 @@ function ce_gearbox:get_formspec(_meta, _, consumption_percent)
local formspec = "formspec_version[3]" .. "size[12.75,8.5]" ..
local formspec = "size[12.75,8.5]" ..
"background[-1.25,-1.25;15,10;appliances_appliance_formspec.png]" ..
progress..
player_inv ..
"list[context;"..self.use_stack..";2,0.8;1,1;]"..
"list[context;"..self.output_stack..";9.75,0.25;2,2;]" ..
self:get_player_inv() ..
self:get_formspec_list("context", self.use_stack, 2, 0.8, 1, 1)..
self:get_formspec_list("context", self.output_stack, 9.75, 0.25, 2, 2)..
"listring[current_player;main]" ..
"listring[context;"..self.use_stack.."]" ..
"listring[current_player;main]" ..

View File

@ -73,16 +73,11 @@ charger.node_help = S("Connect to power (@1).", charger:get_power_help()).."\n".
--------------
-- form spec
local player_inv = "list[current_player;main;1.5,3;8,4;]";
if minetest.get_modpath("hades_core") then
player_inv = "list[current_player;main;0.5,3;10,4;]";
end
function charger:get_formspec()
local formspec = "formspec_version[3]" .. "size[12.75,8.5]" ..
local formspec = "size[12.75,8.5]" ..
"background[-1.25,-1.25;15,10;appliances_appliance_formspec.png]" ..
player_inv ..
"list[context;"..self.output_stack..";4.75,1.0;1,1;]" ..
self:get_player_inv() ..
self:get_formspec_list("context", self.output_stack, 4.75,1,1,1)..
"listring[current_player;main]" ..
"listring[context;"..self.output_stack.."]" ..
"listring[current_player;main]";
@ -123,10 +118,12 @@ function charger:cb_on_production(timer_step)
-- charge
local stack = timer_step.inv:get_stack(self.output_stack, 1)
local def = stack:get_definition()
local charge, max_charge = def._PG_batt_get_charge(stack)
charge = math.min(charge+200*timer_step.speed, max_charge)
def._PG_batt_set_charge(stack, charge)
timer_step.inv:set_stack(self.output_stack, 1, stack)
if def._PG_batt_get_charge then
local charge, max_charge = def._PG_batt_get_charge(stack)
charge = math.min(charge+200*timer_step.speed, max_charge)
def._PG_batt_set_charge(stack, charge)
timer_step.inv:set_stack(self.output_stack, 1, stack)
end
end
----------

View File

@ -74,11 +74,6 @@ emergency_generator:control_data_register(
-- Formspec --
--------------
local player_inv = "list[current_player;main;1.5,3.5;8,4;]";
if minetest.get_modpath("hades_core") then
player_inv = "list[current_player;main;0.5,3.5;10,4;]";
end
--function emergency_generator:get_formspec(meta, production_percent, consumption_percent)
function emergency_generator:get_formspec(_, _, consumption_percent)
local progress = "image[3.6,0.9;5.5,0.95;appliances_consumption_progress_bar.png^[transformR270]]";
@ -90,12 +85,12 @@ function emergency_generator:get_formspec(_, _, consumption_percent)
local formspec = "formspec_version[3]" .. "size[12.75,8.5]" ..
local formspec = "size[12.75,8.5]" ..
"background[-1.25,-1.25;15,10;appliances_appliance_formspec.png]" ..
progress..
player_inv ..
"list[context;"..self.use_stack..";2,0.8;1,1;]"..
"list[context;"..self.output_stack..";9.75,0.25;2,2;]" ..
self:get_player_inv() ..
self:get_formspec_list("context", self.use_stack, 2, 0.8, 1, 1)..
self:get_formspec_list("context", self.output_stack, 9.75, 0.25, 2, 2)..
"listring[current_player;main]" ..
"listring[context;"..self.use_stack.."]" ..
"listring[current_player;main]" ..

View File

@ -74,11 +74,6 @@ emergency_generator:control_data_register(
-- Formspec --
--------------
local player_inv = "list[current_player;main;1.5,3.5;8,4;]";
if minetest.get_modpath("hades_core") then
player_inv = "list[current_player;main;0.5,3.5;10,4;]";
end
--function emergency_generator:get_formspec(meta, production_percent, consumption_percent)
function emergency_generator:get_formspec(_, _, consumption_percent)
local progress = "image[3.6,0.9;5.5,0.95;appliances_consumption_progress_bar.png^[transformR270]]";
@ -90,12 +85,12 @@ function emergency_generator:get_formspec(_, _, consumption_percent)
local formspec = "formspec_version[3]" .. "size[12.75,8.5]" ..
local formspec = "size[12.75,8.5]" ..
"background[-1.25,-1.25;15,10;appliances_appliance_formspec.png]" ..
progress..
player_inv ..
"list[context;"..self.use_stack..";2,0.8;1,1;]"..
"list[context;"..self.output_stack..";9.75,0.25;2,2;]" ..
self:get_player_inv() ..
self:get_formspec_list("context", self.use_stack, 2, 0.8, 1, 1)..
self:get_formspec_list("context", self.output_stack, 9.75, 0.25, 2, 2)..
"listring[current_player;main]" ..
"listring[context;"..self.use_stack.."]" ..
"listring[current_player;main]" ..

View File

@ -1,5 +1,5 @@
name = power_generators
title = Add some power generators
description = Add power generators based on appliances API.
depends = appliances, tubelib2, basic_materials, adaptation_lib, adaptation_minetest_game, adaptation_hades_revisited, adaptation_mineclone, adaptation_farlands_reloaded, adaptation_biofuel, adaptation_basic_materials, adaptation_technic, adaptation_elepower, adaptation_techage, adaptation_mesecons, adaptation_pipeworks, adaptation_rubber
optional_depends = screw_driver, default, biofuel, farming, hades_core, hades_sounds, hades_biofuel, hades_extrafarming, sounds, mesecons_materials, elepower, techage, technic, hades_technic
depends = appliances, tubelib2, basic_materials, adaptation_lib, adaptation_minetest_game, adaptation_hades_revisited, adaptation_mineclone, adaptation_farlands_reloaded, adaptation_biofuel, adaptation_basic_materials, adaptation_technic, adaptation_elepower, adaptation_techage, adaptation_mesecons, adaptation_pipeworks, adaptation_rubber, adaptation_farming_redo
optional_depends = screw_driver, default, biofuel, farming, hades_core, hades_sounds, hades_biofuel, sounds, mesecons_materials, elepower, techage, technic, hades_technic

View File

@ -69,21 +69,16 @@ shaft_gearbox:power_data_register(
-- Formspec --
--------------
local player_inv = "list[current_player;main;1.5,3.5;8,4;]";
if minetest.get_modpath("hades_core") then
player_inv = "list[current_player;main;0.5,3.5;10,4;]";
end
function shaft_gearbox:get_formspec(meta)
local inv = meta:get_inventory()
local cnt1 = inv:get_stack(self.input_stack, 1):get_count()
local cnt2 = inv:get_stack(self.input_stack, 2):get_count()
local ratio = (cnt1+1).." : "..(cnt2+1)
local formspec = "formspec_version[3]" .. "size[12.75,8.5]" ..
local formspec = "size[12.75,8.5]" ..
"background[-1.25,-1.25;15,10;appliances_appliance_formspec.png]" ..
player_inv ..
"list[context;"..self.input_stack..";2,0.8;1,1;0]"..
"list[context;"..self.input_stack..";9,0.8;1,1;1]"..
self:get_player_inv() ..
self:get_formspec_list("context", self.input_stack, 2, 0.8, 1, 1, 0)..
self:get_formspec_list("context", self.input_stack, 9, 0.8, 1, 1, 1)..
"label[5.5,1.5;"..ratio.."]" ..
"listring[current_player;main]" ..
"listring[context;"..self.input_stack.."]" ..