Calling a ZScript menu from an actor
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!)
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!)
- Rip and Tear
- Posts: 186
- Joined: Tue May 02, 2017 3:54 pm
Calling a ZScript menu from an actor
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?
- Rip and Tear
- Posts: 186
- Joined: Tue May 02, 2017 3:54 pm
Re: Calling a ZScript menu from an actor
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
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
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49225
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Calling a ZScript menu from an actor
I think using a custom event to pass the info between play and ui would have been a more reliable solution.
- Rip and Tear
- Posts: 186
- Joined: Tue May 02, 2017 3:54 pm
Re: Calling a ZScript menu from an actor
Could you please point me in the direction of any relevant documentation/examples?Graf Zahl wrote:I think using a custom event to pass the info between play and ui would have been a more reliable solution.