

When writing the book I made a magic menu but it was cut when the book was getting too long. That's the selector working as we'd like! Next we need to open the magic menu itself.

mPartyMenu : JumpToFirstItem () end end end mId ~= " mage" ) then print ( " Couldn't find mage!" ) self.

mPartyMenu : SelectedItem () end if ( member. mDataSource - Start at the top and scroll down - until you hit a mage character while member. mPartyMenu : SelectedItem () local memberCount = # self. mTopBarText = " Choose a party member" if item.
The magicmenu code#
You can see the code below.įunction FrontMenuState : OnMenuClick ( index, item ) - code omitted self. When we select an item like magic or status, OnMenuClick gets called. (If we had more than one spell caster I'd just let you move through all the party members but you'd only be able to click on on spell casters). We need to ensure that the mage character is the one selected no matter the party order. but it only works by chance! The first character selected happens to be the mage. (If you select the mage, it will crash - but don't worry about that, we'll get to it soon!) You'll only be able to perform the selection task. If you run the code now and choose Magic you'll enter the party selector but won't be able to move because we've taken over the controls. mInPartyMenu then self : HandlePartyMenuInput ()
The magicmenu update#
mPartyMenu : HandleInput () end function FrontMenuState : Update ( dt ) if self. mPartyMenu : OnClick () end return end self. The next change ensures that when the player selects a party member, they get redirected to the magic menu.įunction FrontMenuState : HandlePartyMenuInput () local item = self. We'll keep the character selection but only allow the mage to be selected, this might be more complicated to write but I think it flows better. Therefore there's an argument to skip the character selection and jump straight to the magic menu but then it's not quite clear whose spells we're browsing. In our game, there's only one character that can use magic. The prompt to choose a party member is more interesting. It crashes because we haven't written the MagicMenuState yet. You'll be prompted to choose a party member.Now if you click on the Magic option two things will happen: Here's the updated version that looks better: Let's reduce the spacing, which is defined above, from 32 to 28. We've successfully added the menu option but the alignment is a bit off. With those changes the menu now looks like this: Function FrontMenuState : Create ( parent ) - code omitted local this this = ,
