Calling a ZScript menu from an actor

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
Rip and Tear
Posts: 186
Joined: Tue May 02, 2017 3:54 pm

Calling a ZScript menu from an actor

Post by Rip and Tear »

I have created a ZScript menu which displays text from a lump. The menu works fine, but now I need to do two things. First, I need to open the menu from an Actor; and second, I need to pass a string to the menu so it will know which lump to display. How can I accomplish this?
User avatar
Rip and Tear
Posts: 186
Joined: Tue May 02, 2017 3:54 pm

Re: Calling a ZScript menu from an actor

Post by Rip and Tear »

For future reference, this is how I solved this issue. It may not be the cleanest solution, but it works well enough.

1. Give the player an item with a String as a member variable
2. Immediately after giving the player the item and setting the value, open the menu with `Menu.SetMenu`
3. In the menu's init, use `FindInventory` to get a reference to the item and read the value from it
4. Call `Destroy()` from the item's `PostBeginPlay` so it immediately deletes itself
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49225
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Calling a ZScript menu from an actor

Post by Graf Zahl »

I think using a custom event to pass the info between play and ui would have been a more reliable solution.
User avatar
Rip and Tear
Posts: 186
Joined: Tue May 02, 2017 3:54 pm

Re: Calling a ZScript menu from an actor

Post by Rip and Tear »

Graf Zahl wrote:I think using a custom event to pass the info between play and ui would have been a more reliable solution.
Could you please point me in the direction of any relevant documentation/examples?
Post Reply

Return to “Scripting”