is there a workaround for showmenu?

So from what I gathered reading the section on how 'on ready' works, and from my experiments, it seems that you cannot make the game wait for the player's choice for showmenu and it's nested showmenus. Am I misunderstanding something here? Is there an alternative that works like showmenu that can be 'on ready' or has a built in 'on ready' like behavior?


What do you want it to do?

If you want something to happen after a menu selection is made, it would be normal to put it inside the menu's script.

In the past, I've suggested putting code in a turnscript as an alternative to wait for a menu being gone:

if (not HasScript (game, "menucallback")) {
  // do stuff and then set a flag or something to make sure it isn't done more than once
}

(a while back I posted an alternative version of the ShowMenu function which would do this if it was called when a menu was already on the screen, so that each menu appears after the last one has been resolved. But that's quite a complex task)

To find the best approach for this situation, we'd probably need more information about what you're actually trying to do.


well the game I am making is a somewhat tactical turn based rpg. I do like the idea of having the option to perform actions after the monsters make their turns so I did exploit the showmenu limitations (wait for the wolf, zombie, orc to use their action t approach you THEN push them off the cliff. However, when the player wishes to push a monster off a cliff before the monster attacks, because it has already reached them, then I need a neat menu that displays all possible exits that can be used. Unfortunately the menu causes the monsters to attack before the player selects the location they wish to push the monster.

I will definitely come across this issue again with multi target spells so figuring out a solution would be fantastic and save me a lot of headache.


I'm assuming the monster's turn is a turnscript?

In that case, you can call SuppressTurnscripts() before displaying a menu. Or have your turnscript check HasScript (game, "menucallback"), which is true only if a menu is currently displayed.


That seems to work. I used SuppressTurnscripts() in the command push #object# and RunTurnScripts at the end of the if (result = ...) block. Thanks so much for such a simple, yet elegant, solution! It even leaves my turnscript uncluttered.


Is there a way to call a turnscript to run immediately?

edit: nevermind fixed it. Also sorry I accidently deleted the message as I edited it. I reposted what you responded to.


Is there a way to call a turnscript to run immediately?

You could do:

do (some_turnscript, "script")

A turnscript is an object-like element whose script is stored in its script attribute.

If you want to run more than one turnscript at this point, it might be worth looking into how the disambiguation system works; I suspect there's an approach that's closer to how Quest does it internally. I'll try to remember to add a proper answer when I'm not on my phone.


If you want to push an object in a direction, I would make two commands. One would be the single command version; with a pattern like push #object# to #exit#. That way, you get both variables and you can handle the action itself. I'd name the command something like pushto so it's easy to refer to. And then have a second command, push #object#, which would have a script like:

// If there are objects that don't need a direction, like "push button" or "push door", handle them first
// and put the rest of this in an else clause
// maybe check that the object can be pushed, as well

// Then work out what directions the player is choosing from (change this line if it's not so simple)
candidates = ScopeExits()

// And put the command through as if it's an object disambiguation:
game.disambiguating = true
ShowMenu ("Which way would you like to push it?", candidates, true) {
  if (TypeOf (result) = "string") {
    game.pov.currentcommandpattern = pushto
    AddToResolvedNames ("exit", GetObject (result))
  }
}

Not 100% sure about this; the changes in 5.8 with runturnscripts and suppressturnscripts seem to be a bit weird, but I think it should make the turnscripts behave rationally.


Log in to post a reply.

Support

Forums