Script commands index and hints

Started by FIQ, June 24, 2012, 10:16:04 PM

Previous topic - Next topic

blue626

#45
OK, I think a glitch that was discovered long ago and that is mentioned in the middle of the internal scripts thread needs to be mentioned here.
The glitch is that if you load a script from iftrinkets or ifflag, the last line of the script is copied to the top, and is executed as an internal command the first time. The last line is actually the second last line, as it doesn't see the last line (that's also why you need a blank line at the end of every script).
That causes problems with the commands ifflag or iftrinkets, like mentioned there.

However, there are other cases in which that's a problem. Consider this set of scripts:

Code (script1) Select
ifflag(2,script2)
flag(2,on)

Code (script2) Select
ifflag(3,script3)
flag(3,on)

Code (script3) Select
ifflag(4,script4)
flag(4,on)

Code (script4) Select
destroy(gravitylines)

All of them have one empty line in the end.
Consider that flags 2-4 are off every time you trigger it.
As you see, what it does is destroy gravity lines as soon as script1 is executed the 4th time.
However, it destroys them at the 2nd time. It's related to the glitch mentioned before.

What happens the first time it's triggered:
Checks for flag 2, sees that it's off and doesn't go to the other script and turn it on.
What happens the 2nd time:
Checks for flag 2, sees that it's on and goes to script2.
In there, because of the glitch, turns flag 3 on first and then check for flag 3. [edit]Oh, and that's because flag(x,on/off) works the same in internal scripting.[/edit] Sees it's on and goes to script3.
In there, the same thing happens (except it's flag 4).
In script4, gravity lines are destroyed.

How to fix it? It's simple:
Just add a second empty line in scripts script2 and script3. That way, the first empty line is considered the last line.

I think this should be added to the tips...

weee50

#46
Quote from: blue626 on June 30, 2012, 05:08:30 PM
If someone, using 2.1 beta, plays a level made in 2.0, does that person see the map? If the answer is yes, I must ask this: does the command map(on/off) create any glitches in 2.0?

EDIT: In the "some scripting commands" thread (see my 1st post above) someone mentioned a way to make scripts execute only once:

Quote from: TheoX on August 07, 2011, 11:48:56 PM
Quote from: Arkatox on August 07, 2011, 08:09:29 PM
What is the command to destroy a script box after it's used?
There isn't one.  You have to use what I call "trigger scripts", or secondary scripts, that use ifflags to make sure a script doesn't run twice.  It's kind of a pain, and one of the reasons my level is taking so long to make.  Example of what I do:

Example script: "talking1trigger"
ifflag(1,talking1)
end()


Example script: "talking1"
say(2)
this script will
only run once!
flag(1,off)
end()


This assumes the flag used was turned "on" previously.

This method uses 2 scripts and 1 flag per terminal/script box and an "init" script. The method I suggested uses 2 scripts and 1 flag per terminal/script box and a "stop" script. The method on this quote is as good as the other one. Note: I think that the "end" commands aren't necessary.
You can also use:
script1:
...
ifflag(1,stop)
...
flag(1,on)

stop:
say(-1)
text(1,0,0,4)
say(4)
endtext
endcutscene()
untilbars()
loadscript(stop)

to do it if the flag is still off.

(replace ... with the script code that you want)

blue626

Quote from: weee50 on August 04, 2013, 10:06:00 PM
You can also use:
script1:
...
ifflag(1,stop)
...
flag(1,on)

to do it if the flag is still off.

(replace ... with the script code that you want)

That would only work if the first "..." contains say/reply commands. Otherwise, cutscene bars would stay after triggering the 2nd time.
Thus, that's different from the script you quoted and the one in the OP. That one executes both "..."s the 1st time and only the 1st "..." in the next times. The other 2 scripts execute the script itself the first time and then nothing the following times.
And now that we're speaking about this, there's another way to execute scripts only once that was mentioned sometime ago:

Code (script1) Select
ifflag(1,stop)
flag(1,on)
iftrinkets(0,script2)


script2 being the script itself without adding anything.
This is actually the same as in the OP, except that the flag is activated before the script itself is executed.
Notice that in this case, replacing iftrinkets with ifflag(1,script2) wouldn't change anything, making it equal to a method that was mentioned long time ago.... turns out iftrinkets(0,script) isn't necessary here after all.

SteveGamer68

Can you make a internal scripting version

i don't use this site anymore, please don't look at my posts

You've been making meaningless bumps since your registration, so I'm banning you for a day.

Dav999

I'm not really sure if this bump was so meaningless...

moth ✨


Dav999

#52
I still tend to disagree. Granted, an internal scripting topic already exists, but the post still isn't too unrelated to the topic. Maybe this is a bit of a gray area, but I would've simply linked him to that and be done with it instead of calling the post meaningless and banning him.

Edit: Lifted the ban, it has been in place for 14 hours.

SomeRandomCreator

How much corruption does your level get if you use a colon (:) ?
I used one and saved with realizing.

Viridan

#54
it just creates a new script that you need to merge with the old one. for example, your script should be stored like this:

Quoteexamplescript:
say(1)
this dialogue contains an: unexpected character!

but due to the colon, a new script is created:

Quoteexamplescript:
say(1)

this dialogue contains an:
unexpected character!

in this case, you just need to delete the script called "this dialogue contains an" and rewrite the dialogue to not contain any colons.

SomeRandomCreator

Oh, THAT explains the problem I had before, and whew! I thought it was a huge problem.

lol...ipops2

Quote from: StillSpelledViridan on July 26, 2016, 11:41:13 PM
it just creates a new script that you need to merge with the old one. for example, your script should be stored like this:

Quoteexamplescript:
say(1)
this dialogue contains an: unexpected character!

but due to the colon, a new script is created:

Quoteexamplescript:
say(1)

this dialogue contains an:
unexpected character!

in this case, you just need to delete the script called "this dialogue contains an" and rewrite the dialogue to not contain any colons.
Terry should fix this.

Dav999

Not possible without changing the level format and breaking every level, unless the script editor adds a space after colons at ends of lines automatically, which I'm going to do in Ved

Xdroid19

I tried using a command where :viridian: said something one time. I used this command.
Quote
ifflag(1,speechb)
end()

and "speechb" was
Quote
reply(1)
Yet another dimension to be explored.
sad
reply(1)
*sigh*
reply(1)
And more spikes!
flag(1,off)


When I run this script  :viridian: does nothing.
How do I fix this?

uugr

Do you have a separate script where flag 1 turns on? For that script to run, you'd need a separate script with
Quoteflag(1,on)
in it for the script to load.

(Also, putting 'end()' at the end of a script is unnecessary; the script will end on its own regardless.)