154 lines
5.7 KiB
Lua
154 lines
5.7 KiB
Lua
-- IndustrialTest
|
|
-- Copyright (C) 2025 mrkubax10
|
|
|
|
-- This program is free software: you can redistribute it and/or modify
|
|
-- it under the terms of the GNU General Public License as published by
|
|
-- the Free Software Foundation, either version 3 of the License, or
|
|
-- (at your option) any later version.
|
|
|
|
-- This program is distributed in the hope that it will be useful,
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
-- GNU General Public License for more details.
|
|
|
|
-- You should have received a copy of the GNU General Public License
|
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
local S=minetest.get_translator("industrialtest")
|
|
|
|
local pages={
|
|
{
|
|
name="introduction",
|
|
title=S("Introduction"),
|
|
icon=industrialtest.elementKeys.paper,
|
|
content=[[
|
|
<big>Introduction</big>
|
|
<left>
|
|
IndustrialTest implements finite power functionality which can be used to perform various tasks using generators and consumers. Such features are not a new thing in Luanti, as there are older mods which do that already. This mod, however, proves to be more flexible.
|
|
</left>
|
|
]]
|
|
},
|
|
{
|
|
name="electricalNetwork",
|
|
title=S("Electrical network"),
|
|
icon="industrialtest:insulated_copper_cable",
|
|
content=[[
|
|
<big>Electrical network</big>
|
|
<left>
|
|
In order to attach electricity consumers to power sources (like generators, batteries, further just called generators) electrical network is used. Consumers can get connected either directly to generators or through various cables. Each generator can output certain voltage (this is actually amperage, however since this mod doesn't simulate electricity accurately, it's called voltage), the same situation is for consumers as they can only handle up to certain voltage.
|
|
Figure 1 shows voltage levels present in this mod.
|
|
If voltage is too high for cable it will melt without dropping anything while consumer will explode also without dropping anything and possibly destroying terrain around. Power capacity is measured in EU (Energy Units) and the voltage is EU/update.
|
|
</left>
|
|
<mono>
|
|
--------------------------------------------
|
|
| Voltage level | EU/update | Cable |
|
|
--------------------------------------------
|
|
| LV | 600 | Tin |
|
|
| MV | 2400 | Copper |
|
|
| HV | 10200 | Gold |
|
|
| EV | 40800 | Iron |
|
|
| IV | 163800 | Glass Fibre |
|
|
--------------------------------------------
|
|
Figure 1. Voltage levels and respective cables
|
|
</mono>
|
|
]]
|
|
},
|
|
{
|
|
name="cableFormer",
|
|
title=S("Cable Former"),
|
|
icon="industrialtest:cable_former",
|
|
content=[[
|
|
<big>Cable Former</big>
|
|
<left>
|
|
Cable Former can be used to produce cables with higher material efficiency. It can, however, only produce cables from metals so for example Glass Fibre Cable can't be produced in it.
|
|
</left>
|
|
<mono>
|
|
---------------------------------------
|
|
| Input voltage level | LV |
|
|
| Recipe type | Cable forming |
|
|
| Power capacity | 1400 EU |
|
|
| Power per operation | 80 EU |
|
|
---------------------------------------
|
|
Figure 1. Machine information for Cable Former
|
|
</mono>
|
|
]]
|
|
},
|
|
{
|
|
name="canningMachine",
|
|
title=S("Canning Machine"),
|
|
icon="industrialtest:canning_machine",
|
|
content=[[
|
|
<big>Canning Machine</big>
|
|
<left>
|
|
Canning Machine is used to move certain fluid from one item to another. The common usage is to refill fuel in Jetpack or Fuel Can.
|
|
</left>
|
|
<mono>
|
|
---------------------------------------
|
|
| Input voltage level | LV |
|
|
| Power per operation | 200 EU |
|
|
| Power capacity | 1200 EU |
|
|
| Canning completion time | 5 seconds |
|
|
---------------------------------------
|
|
Figure 1. Machine information for Canning Machine
|
|
</mono>
|
|
]]
|
|
}
|
|
}
|
|
|
|
local function getGuideFormspec(playerName,pageName)
|
|
local formspec={
|
|
"formspec_version[4]",
|
|
"size[15,10.8]",
|
|
"label[0.1,0.2;"..S("IndustrialTest Guide").."]",
|
|
--"scrollbaroptions[]",
|
|
"scrollbar[3.6,0.4;0.5,10.3;vertical;scrollbarList;0]",
|
|
"scroll_container[0.1,0.4;4,10.3;scrollbarList;vertical]"
|
|
}
|
|
|
|
-- Contents sidebar
|
|
local PAGE_BUTTON_HEIGHT=0.7
|
|
for i,page in ipairs(pages) do
|
|
table.insert(formspec,string.format("container[0,%f]",(i-1)*PAGE_BUTTON_HEIGHT))
|
|
table.insert(formspec,string.format("item_image[0,0;%f,%f;%s]",PAGE_BUTTON_HEIGHT,PAGE_BUTTON_HEIGHT,page.icon))
|
|
table.insert(formspec,string.format("button[%f,0;%f,%f;%s;%s]",PAGE_BUTTON_HEIGHT+0.05,3.45-PAGE_BUTTON_HEIGHT,PAGE_BUTTON_HEIGHT,page.name,page.title))
|
|
table.insert(formspec,"container_end[]")
|
|
end
|
|
table.insert(formspec,"scroll_container_end[]")
|
|
|
|
if pageName then
|
|
for _,page in ipairs(pages) do
|
|
if page.name==pageName then
|
|
table.insert(formspec,string.format("hypertext[4.2,0.4;10.7,10.3;content;%s]",page.content))
|
|
break
|
|
end
|
|
end
|
|
end
|
|
|
|
return table.concat(formspec,"")
|
|
end
|
|
|
|
local function showGuide(playerName,page)
|
|
minetest.show_formspec(playerName,"industrialtest:guide",getGuideFormspec(playerName,page))
|
|
return true
|
|
end
|
|
|
|
local function handleGuideFields(player,formname,fields)
|
|
if formname~="industrialtest:guide" then
|
|
return
|
|
end
|
|
|
|
for _,page in ipairs(pages) do
|
|
if fields[page.name] then
|
|
minetest.close_formspec(player:get_player_name(),formname)
|
|
showGuide(player:get_player_name(),page.name)
|
|
break
|
|
end
|
|
end
|
|
end
|
|
minetest.register_on_player_receive_fields(handleGuideFields)
|
|
|
|
minetest.register_chatcommand("industrialtest_guide",{
|
|
description=S("Shows graphical guide for content and features provided by IndustrialTest"),
|
|
func=showGuide
|
|
})
|