Turn Script Question ^_^ [SOLVED]

Anonynn
21 Aug 2016, 01:55

I'm not sure why this turn-script isn't working. I'm thinking maybe I have the syntax off or something but after double checking it three or four times now, I can't find anything that would be preventing it from working.

So I have a ripped up t-shirt item that will randomly become disheveled. I set up a flag.boolean (False). Changedflag.script

if (tattered_tshirt.flag="False") {
  if (player.gender="female") {
    EnableTurnScript (disheveled)
  }
}

Then I have a Verb "Adjust"

if (tattered_tshirt.worn="True") {
  if (player.gender="female") {
    if (tattered_tshirt.flag="True") {
      msg ("<br/>You realize your shirt is disheveled")
      tattered_tshirt.flag = False
    }
    else {
      msg ("<br/>There's nothing to adjust at the moment. The tattered t-shirt is fitting just fine.<br/>")
      EnableTurnScript (disheveled)
    }
  }
  else {
    msg ("<br/>You don't really need to worry about adjusting this given that you're a guy.")
  }
}
else {
  msg ("<br/>There's no need to adjust this t-shirt right now given that you aren't wearing it. <br/>")
}

And the turn-script connected on the t-shirt object.

if (RandomChance(80)) {
  msg ("<br/>You suddenly feel a draft and realize your clothes are disheveled.<br/>")
  tattered_tshirt.flag = True
}

But for some reason the turn-script isn't activating even if I enable it in the beginning of the game. It's basically supposed to activate, be deactivated then randomly activated again with a 3% chance. At the moment it's set to 80% for testing.

Anyone see what I'm doing wrong?


hegemonkhan
21 Aug 2016, 03:40

if you put/added/created your Turnscript within an Object (a local Turnscript), then it doesn't fire/run its scripts unless/until you're in that Object too (even with it being enabled).

if you have the Turnscript outside of Objects as a standalone Element within the game code, then it's a global Turnscript, and will fire/run its scripts(when its enabled of course), regardless of where you are.


also... do you have a 'disable turnscript' anywhere?

also... your Turnscript will continue to do 'RandomChance(80)' forever (always and continually setting/re-setting this over and over forever: 'tattered_tshirt.flag = true'), from what you provided me anyways as there's nothing that prevents the Turnscripts scripts from running nor any 'disable Turnscript' either. The 'RandomChance(80)' is a total waste of operation with how you got it all set up with what you provided me.


Anonynn
21 Aug 2016, 05:03

Thanks HK :) I'll figure something else out then!


The Pixie
21 Aug 2016, 07:43

A couple of general points abiout this:

if (tattered_tshirt.flag="False") {

You are checking if flag is equal to a certain string, and yet you say flag is a Boolean. I would expect Quest to complain about that so there is probably somewhere else that flag is getting set to a string too. Also, it would be better to give the flag a proper name, say "disheveled". And I would have the change script on the "worn" attribute, so it goes off when the player puts it on or off.

So delete the current shancescript, and add a new one "changedworn" that looks like this:

if (player.gender="female")
  tattered_tshirt.disheveled = false
  if (tattered_tshirt.worn) {
    EnableTurnScript (disheveled)
  }
  else {
    DisableTurnScript (disheveled)
  }
}

The verb script needs slight changes at the top:

if (tattered_tshirt.worn) {
  if (player.gender="female") {
    if (tattered_tshirt.disheveled) {
...

The turnscript should be fine, but as HK says should be global. Might be worth hecking if you have false or true in quotes anywhere else in your game, or set as string attributes.


Anonynn
21 Aug 2016, 16:51

Well, I'm avoiding adding unnecessary global turn-scripts that don't have anything to do with the main function of the game because eventually there are going to be a lot of important turn-scripts so I'd rather the game not be struggling at that point. What I ended up doing was leaving the flag and inserting a small 30% chance script at certain areas of the game where the clothing can become disheveled. ^_^ Less for Quest to keep track of!


hegemonkhan
21 Aug 2016, 23:31

Note:

  1. all activation usually needs a corresponding de-activation too

  2. also, actually all of the below activation methods, can have conditions applied/added to their scripting, to control whether they run/fire their condition-controlled scripts or not, as well as the activation-handling methods themselves

activation by any/every/all actions by user, while being ANYWHERE IN THE GAME (it doesn't matter where you are):

global Turnscripts-(though you should just have a single global Turnscript), (if enabled, of course, and also if optional conditions are met/un-met), run/fire their scripts after every/any/all actions/internal-turns (click on a button or hyperlink with mouse, or type in an input and hit enter). So, if you need this to happen, then you use a global Turnscript

activation by any/every/all actions by user, BUT ONLY IF you're in the same room as the (local) Turnscript:

use local Turnscripts (if you're in the same room as the local Turnscript, and if it is enalbed, of course), run/fire their scripts after every/any/all actions/internal-turns (click on a button or hyperlink with mouse, or type in an input and hit enter). So, if you need this to happen, then you use a local Turnscript

activation, when-ever/every-time, a specific Attribute's Value changes:

the special 'changed' Script Attribute will run/fire its scripts

activation by user, via the user's input (and optionally be condition-based too), would be achieved through:

  1. Verb usage (the action doesn't occur until the user clicks on a Verb's button or hyperlink)
  2. typed-in input (Commands and/or 'get input' Script/Function) usage (the action doesn't occur until you typed-in somthing and hit enter)

activation via changing the room you're in:

  1. use the, GUI~Editor's / built-in Code, of the local or global, 'onenterroom or whatever it is called', Script
  2. using the special 'changed' Script Attribute and/or Turnscripts, with the 'parent' Attribute of the Player Object(s). Optional conditions are available to include via scripting design

and probably many more methods of activation that I can't think of, and/or don't want to list/describe, as they can be infinite in number, lol.