-- 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 . local S=minetest.get_translator("industrialtest") local pages={ introduction={ title=S("Introduction"), icon=industrialtest.elementKeys.paper, content=[[ Introduction 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. ]] } } 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 local index=0 for name,page in pairs(pages) do table.insert(formspec,string.format("container[0,%f]",index*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,name,page.title)) table.insert(formspec,"container_end[]") index=index+1 end table.insert(formspec,"scroll_container_end[]") if pageName and pages[pageName] then table.insert(formspec,string.format("hypertext[4.2,0.4;10.7,10.3;content;%s]",pages[pageName].content)) 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 name,_ in pairs(pages) do if fields[name] then minetest.close_formspec(player:get_player_name(),formname) showGuide(player:get_player_name(),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 })