<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.figuramc.org/index.php?action=history&amp;feed=atom&amp;title=Tutorials%2FActionWheel-Advanced</id>
	<title>Tutorials/ActionWheel-Advanced - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.figuramc.org/index.php?action=history&amp;feed=atom&amp;title=Tutorials%2FActionWheel-Advanced"/>
	<link rel="alternate" type="text/html" href="https://wiki.figuramc.org/index.php?title=Tutorials/ActionWheel-Advanced&amp;action=history"/>
	<updated>2026-04-14T23:48:30Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://wiki.figuramc.org/index.php?title=Tutorials/ActionWheel-Advanced&amp;diff=112&amp;oldid=prev</id>
		<title>Manuel: Automated upload of converted .txt file.</title>
		<link rel="alternate" type="text/html" href="https://wiki.figuramc.org/index.php?title=Tutorials/ActionWheel-Advanced&amp;diff=112&amp;oldid=prev"/>
		<updated>2024-09-26T20:44:59Z</updated>

		<summary type="html">&lt;p&gt;Automated upload of converted .txt file.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Advanced action wheel tutorial&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you haven’t read and understood the beginner action wheel tutorial, start [[../tutorials/ActionWheel.md|there]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;multi-page-setup&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Multi Page Setup ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Creating a network of Pages can be overwhelming. Lets try to rectify that.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method for creating a Page Network divides the Pages into seperate, isolated files. These files return an Action that can be added to a different page. This Action will set the cuurrent page to the page in the file, but it first stores a reference to the Page it came from. That way when you want to go back to the previous page, its as simple as setting the current page to the stored Page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This allows Pages to be modular and easily reorganized if needed. More importantly, it can help make multiple pages less overwhelming.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;--ActionWheel.lua&lt;br /&gt;
&lt;br /&gt;
-- This file controls the root Page. All Pages are &amp;#039;children&amp;#039; of this Page.&lt;br /&gt;
&lt;br /&gt;
local mainpage = action_wheel:newPage()&lt;br /&gt;
&lt;br /&gt;
-- setAction is used to add an Action that already exists to this Page&lt;br /&gt;
&lt;br /&gt;
-- You need to specify the slot the Action wil go into, but -1 can be used to put it in the next available slot.&lt;br /&gt;
&lt;br /&gt;
mainpage:setAction(-1, require(&amp;quot;Page1&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
mainpage:setAction(-1, require(&amp;quot;Page2&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
action_wheel:setPage(mainpage)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- prettier-ignore --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;--Page1.lua&lt;br /&gt;
&lt;br /&gt;
-- Create the Page&lt;br /&gt;
&lt;br /&gt;
local page = action_wheel:newPage()&lt;br /&gt;
&lt;br /&gt;
-- Define the Actions within the Page (These are dummy example Actions)&lt;br /&gt;
&lt;br /&gt;
page:newAction():title():color():onLeftClick()&lt;br /&gt;
&lt;br /&gt;
page:newAction():title():color():onLeftClick()&lt;br /&gt;
&lt;br /&gt;
page:newAction():title():color():onLeftClick()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- This variable stores the Page to go back to when done with this Page&lt;br /&gt;
&lt;br /&gt;
local prevPage&lt;br /&gt;
&lt;br /&gt;
-- This Action just sets the stored page as active&lt;br /&gt;
&lt;br /&gt;
page:newAction()&lt;br /&gt;
&lt;br /&gt;
    :title(&amp;quot;GoBack&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    :item(&amp;quot;minecraft:barrier&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    :onLeftClick(function()&lt;br /&gt;
&lt;br /&gt;
        action_wheel:setPage(prevPage)&lt;br /&gt;
&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Page:newAction automatically adds the Action to the Page.&lt;br /&gt;
&lt;br /&gt;
-- This is unwanted, so action_wheel:newAction() is used so just make an Action.&lt;br /&gt;
&lt;br /&gt;
-- This is the Action that will be returned by require and will be used to navigate to this file&amp;#039;s Page&lt;br /&gt;
&lt;br /&gt;
return action_wheel:newAction()&lt;br /&gt;
&lt;br /&gt;
    :title(&amp;quot;Page1&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    :onLeftClick(function()&lt;br /&gt;
&lt;br /&gt;
        -- store the current active page so that we can set it back as active later&lt;br /&gt;
&lt;br /&gt;
        prevPage = action_wheel:getCurrentPage()&lt;br /&gt;
&lt;br /&gt;
        -- set this file&amp;#039;s page as active&lt;br /&gt;
&lt;br /&gt;
        action_wheel:setPage(page)&lt;br /&gt;
&lt;br /&gt;
    end)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- prettier-ignore --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;--Page2.lua&lt;br /&gt;
&lt;br /&gt;
-- Page2 is just to show that the entire process can be repeated verbatum, so long as the variables are local.&lt;br /&gt;
&lt;br /&gt;
local page = action_wheel:newPage()&lt;br /&gt;
&lt;br /&gt;
page:newAction():title():color():onLeftClick()&lt;br /&gt;
&lt;br /&gt;
page:newAction():title():color():onLeftClick()&lt;br /&gt;
&lt;br /&gt;
page:newAction():title():color():onLeftClick()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local prevPage&lt;br /&gt;
&lt;br /&gt;
page:newAction()&lt;br /&gt;
&lt;br /&gt;
    :title(&amp;quot;GoBack&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    :item(&amp;quot;minecraft:barrier&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    :onLeftClick(function()&lt;br /&gt;
&lt;br /&gt;
        action_wheel:setPage(prevPage)&lt;br /&gt;
&lt;br /&gt;
    end)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
return action_wheel:newAction()&lt;br /&gt;
&lt;br /&gt;
    :title(&amp;quot;Page2&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    :onLeftClick(function()&lt;br /&gt;
&lt;br /&gt;
        prevPage = action_wheel:getCurrentPage()&lt;br /&gt;
&lt;br /&gt;
        action_wheel:setPage(page)&lt;br /&gt;
&lt;br /&gt;
    end)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;setting-default-state-of-toggle-action&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting Default State of Toggle Action ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This primarily utilizes calling a ping function without the network code, which is explained [[./Pings#ping-on-init|here]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This example will correctly set the default visibility of a theoretical jetpack model&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- prettier-ignore --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;-- This variable&amp;#039;s initial value will control the default state of the togglable thing.&lt;br /&gt;
&lt;br /&gt;
local jetpackEnabled = true&lt;br /&gt;
&lt;br /&gt;
local jetpackModel = models.model.Body.Jetpack -- reference a ModelPart for convinience&lt;br /&gt;
&lt;br /&gt;
local function setJetpack(bool)&lt;br /&gt;
&lt;br /&gt;
    jetpackEnabled = bool -- this will be a ping function, so we still need to set the client&amp;#039;s variable for when it is used in the toggle.&lt;br /&gt;
&lt;br /&gt;
    jetpackModel:setVisible(bool)&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
pings.setJetpack = setJetpack -- we now have a normal function and a ping function that calls the normal function after network stuff&lt;br /&gt;
&lt;br /&gt;
-- This event controls the particle effect of the jetpack&lt;br /&gt;
&lt;br /&gt;
function events.tick()&lt;br /&gt;
&lt;br /&gt;
    -- once every 4 ticks while the jetpack is visible&lt;br /&gt;
&lt;br /&gt;
    if jetpackEnabled and world.getTime() % 4 == 0 then&lt;br /&gt;
&lt;br /&gt;
        -- spawn particles relative to the model itself in the world&lt;br /&gt;
&lt;br /&gt;
        local partMatrix = jetpackModel:partToWorldMatrix()&lt;br /&gt;
&lt;br /&gt;
        particles:newParticle(&amp;quot;minecraft:flame&amp;quot;, partMatrix:apply(3, -6, 0))&lt;br /&gt;
&lt;br /&gt;
        particles:newParticle(&amp;quot;minecraft:flame&amp;quot;, partMatrix:apply(-3, -6, 0))&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Page boilerplate&lt;br /&gt;
&lt;br /&gt;
local mainpage = action_wheel:newAction()&lt;br /&gt;
&lt;br /&gt;
action_wheel:setPage(mainpage)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- calling a ping in the script initialization is a bad idea, hence why the reference to the normal function is needed&lt;br /&gt;
&lt;br /&gt;
setJetpack(jetpackEnabled)&lt;br /&gt;
&lt;br /&gt;
mainpage:newAction()&lt;br /&gt;
&lt;br /&gt;
    :title(&amp;quot;Enable Jetpack&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    :toggleTitle(&amp;quot;Disable Jetpack&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    :onToggle(pings.setJetpack) -- use the ping for the action toggle, as that is still needs to be pinged&lt;br /&gt;
&lt;br /&gt;
    :toggled(jetpackEnabled) -- the toggled function sets the internal state of the Toggle Action. It *does not* call toggle or untoggle.&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Manuel</name></author>
	</entry>
</feed>