Making a Turnscript debuger

For my games I tend to use alot of turnscripts, and as tends to happen they like to clobber each other. I'd like to make a simple script to let a player manually turn them off one by one.. the code i have so far is

SetObjectFlagOn (player, "DEBUG")
foreach (x, AllTurnScripts()) {
  if (x.enabled=True) {
    msg (x.name)
    Ask ("Would you like to disable this Turnscript") {
      if (result) {
        x.enabled = False
      }
    }
  }
}

Is there a way to let the script pause for input from the player then go on? Was thinking setting it up to have the script end after the players choice but if a script didn't want to be disabled that would pretty much ruin it, any sugjestions?


Is there a way to let the script pause for input from the player then go on? Was thinking setting it up to have the script end after the players choice but if a script didn't want to be disabled that would pretty much ruin it, any sugjestions?

Not easily. I'd suggest something like this (assuming this is a command):

if (not HasAttribute (this, "turnscripts_to_check")) {
  this.turnscripts_to_check = FilterByAttribute (AllTurnScripts(), "enabled", true)
}
if (ListCount (this.turnscripts_to_check) > 0) {
  x = ListItem (this.turnscripts_to_check, 0)
  msg (x.name)
  Ask ("Would you like to disable this Turnscript") {
    x = ListItem (this.turnscripts_to_check, 0)
    list remove (this.turnscripts_to_check, x)
    if (result) {
      x.enabled = false
    }
    // run this script again to handle the next one
    do (this, "script")
  }
}
else {
  msg ("No more scripts to disable")
}

Will give that a try, currently just using it as a verb attached to a debug item(Just easier for me when futzing around with things that i don't want the players to get till i have mostly functional) The logic should work there as well if Im reading your code correctly

---Edit
Hmm it comes back with a compiling error(My eternal Nemisi, "this" )
"Error running script: Error compiling expression 'ListItem (this.turnscripts_to_check, 0)': Unknown object or variable 'this'"


Sorry, wasn't thinking clearly there. Within an Ask, there is no this. So it would have to be the name of the object.

(And if it's a verb, you'd have to change do (this, "script") to do (name_of_object, "name_of_verb"))


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums