WatchNon-threaded

Forums » Advanced Editor Forum » Read Message

Talk about it. Ask for help on it. Compliment it.

Rerunning a script

one year ago

I am again trying to create a simpler version of a naming generator. This time I am not only using Variables but also scripts.

So I have created a single page with all the 26 letters as links. Now my idea to go with was to set a rather simple script at each link looking like this.

IF %DIGIT01 = 0 AND THEN %DIGIT01 := 1
IF %DIGIT01 > 0 AND THEN %DIGIT02 := 1
IF %DIGIT02 > 0 AND THEN %DIGIT03 := 1
IF %DIGIT03 > 0 THEN
 $DEST := @P10

The DIGIT variables are the letters of the alphabeth so in this case the 1 gives an output of A. After the link is clicked you get sent to that same page again where you can again make a choice for a letter. How i thought this would work is that the script checks if DIGIT01 has a value of  0 and if that is the case replace that value with a 1 standing for A. That should normally always be the case at the beginning of the game therefore DIGIT1 gets set to 1. The problem I experienced was that the first line of the script sets the value of DIGIT1 above 0 so automatically the next line sends a 1 to DIGIT2 and the line after sends a 1 to DIGIT3.

So far so good so I thought I need to make clear that only the first time you click the button that first script part should work so I changed the script to:

IF %DIGIT01 = 0 AND %CLICKC = 1 THEN %DIGIT01 := 1
IF %DIGIT01 > 0 AND %CLICKC = 2 THEN %DIGIT02 := 1
IF %DIGIT02 > 0 AND %CLICKC = 3 THEN %DIGIT03 := 1
IF %DIGIT03 > 0 THEN
 $DEST := @P10

The variable CLICKC standing for "Click Count" gets higher the more often you click the Link and it can be increased repeadedly. So now it only adds a 1 to that first letter when i click one time. The problem now however is that no matter how often i click the link to add another Letter it only increases the CLICKC variable while my letters stay at 0.

So to come to the real question. If i use a link script, does that link only run that script 1 time or is there someting else wrong?

Rerunning a script

one year ago

Actually figured out a Way it works all i did have to do is change the script to:

IF %DIGIT01 = 0 AND %CLICKC = 1 THEN %DIGIT01 := 1
IF %DIGIT01 != 0 AND %CLICKC = 2 THEN %DIGIT02 := 1
IF %DIGIT02 != 0 AND %CLICKC = 3 THEN %DIGIT03 := 1
IF %DIGIT03 != 0 THEN
 $DEST := @P10

Rerunning a script

one year ago
Logically all you had to do was reverse the order:

IF %DIGIT03 > 0 THEN $DEST := @P10
IF %DIGIT02 > 0 THEN %DIGIT03 := 1
IF %DIGIT01 > 0 THEN %DIGIT02 := 1
IF %DIGIT01 = 0 THEN %DIGIT01 := 1

And it would have worked fine, since code is executed top to bottom. Also not sure why you had the "AND"s up top. This isn't Dude Where's My Car, so saying "And Then" alone does nothing.

Rerunning a script

one year ago

I did try it with the script you posted and without the "AND"s the letter i click on just overwrites the previous letters with the same one. Meaning if i click A then B and then C the click on A creates A the second click on B creates Bb and the third click on C creates Ccc.

Rerunning a script

one year ago
Can you post the entire script? Or maybe tell me where it is in your story if it's long (I'm an admin so I can view it).