Post new topic    
Metal Slime
Send private message
Need to have a menu item run a script and display text 
 PostFri Nov 16, 2018 7:33 pm
Send private message Reply with quote
I'm making a bestiary menu for my game with enemy info, here's a quick mockup I did to test the script.



However in order to have the text box show immediately instead of after the main menu closes, I had to enable the "Allow gameplay & scripts" bitset which allows for NPCs and other scripts to continue running. Thing is, this isn't normal menu behavior and I'd really like to not have to do that. And what I need to do is run a script based off of the selected menu item's extra data to put some string sprintf stuff together, before then displaying a text box. So I can't just display a text box and still have the data ready to show.

Any suggestions on how to get around this? Also, ideally I'd like to have a two part menu where one menu is where the player selects a monster's name, and a separate box instantly updates with the enemy info when another enemy is selected. Is there any way to do this with menus, or would it need to be built from scratch?
Liquid Metal King Slime
Send private message
 
 PostSat Nov 17, 2018 2:29 pm
Send private message Reply with quote
You definitely need to enable "Allow Gameplay And Scripts". You can get the behavior you want by calling "suspend player" and "suspend NPCs" when you open the menu, and then "resume player" and "resume NPCs" when the menu closes
Metal King Slime
Send private message
 
 PostSat Nov 17, 2018 2:46 pm
Send private message Reply with quote
It's unavoidable that you need to use a script to update the display, so you need the "Allow gameplay & scripts" bitset. Then suspend everything else: the player, NPCs, timers.
Unfortunately there's no command to stop NPCs/heroes in midstep. Tihis certainly isn't the first time I've seen the need for a "suspend walkabouts" (or "suspend movement"?) command. Hmm, a "suspend tile animation" command would be good too.

If you want the info to update immediately, then you should use a text slice instead of a textbox, because the textbox rolls in a line at a time, and the embed codes are expanded when the textbox is opened, not every tick after that. Actually, both are things I really want to change... Oh great. Now I've started working on it.

Anyway, to make the textbox/text slice update continuously is straightforward:
Code:
plotscript, bestiary, begin
  variable(extra)
  while (top menu) do (  # While a menu is open
    extra := get menu item extra(selected menu item, 0)
    # Update the display...
    wait(1)
  )
end
Display posts from previous: