Author Topic: Script commands index and hints  (Read 28707 times)

blue626

  • Captain
  • *****
  • Posts: 672
  • I changed my avatar!
    • View Profile
Re: Script commands index and tips
« Reply #45 on: August 02, 2013, 06:13:11 AM »
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...
« Last Edit: August 02, 2013, 06:18:01 AM by blue626 »

weee50

  • Professor
  • ****
  • Posts: 106
  • Creator of VVVVVV: The New Adventure
    • View Profile
Re: Script commands index and tips
« Reply #46 on: August 04, 2013, 03:06:00 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:

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"
Code: [Select]
ifflag(1,talking1)
end()

Example script: "talking1"
Code: [Select]
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:
Code: [Select]
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)
« Last Edit: August 10, 2013, 11:11:13 AM by weee50 »

blue626

  • Captain
  • *****
  • Posts: 672
  • I changed my avatar!
    • View Profile
Re: Script commands index and tips
« Reply #47 on: August 07, 2013, 05:03:19 AM »
You can also use:
Code: [Select]
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

  • Professor
  • ****
  • Posts: 182
  • Locked and Loaded.
    • View Profile
    • The open level project 2 forum
Re: Script commands index and hints
« Reply #48 on: July 01, 2016, 10:31:10 PM »
Can you make a internal scripting version

Starspire

  • Developer of Deprimerie: STORM of the Future
  • Global Moderator
  • Captain
  • *****
  • Posts: 685
  • Play Persona 3
    • View Profile
Re: Script commands index and hints
« Reply #49 on: July 01, 2016, 10:50:35 PM »
You've been making meaningless bumps since your registration, so I'm banning you for a day.

Dav999

  • Global Moderator
  • Captain
  • *****
  • Posts: 2169
    • View Profile
    • The Open Level Project
Re: Script commands index and hints
« Reply #50 on: July 02, 2016, 04:00:41 AM »
I'm not really sure if this bump was so meaningless...

shiny k

  • Captain
  • *****
  • Posts: 1552
  • Welcome to the MOTHER3 world
    • View Profile
    • my msuic
Re: Script commands index and hints
« Reply #51 on: July 02, 2016, 09:03:24 AM »
no it was

Dav999

  • Global Moderator
  • Captain
  • *****
  • Posts: 2169
    • View Profile
    • The Open Level Project
Re: Script commands index and hints
« Reply #52 on: July 02, 2016, 09:55:48 AM »
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.
« Last Edit: July 02, 2016, 12:52:29 PM by Dav999 »

SomeRandomCreator

  • Doctor
  • ***
  • Posts: 64
  • Internal scripting and flags are my mortal enemies
    • View Profile
Re: Script commands index and hints
« Reply #53 on: July 26, 2016, 04:17:36 PM »
How much corruption does your level get if you use a colon (:) ?
I used one and saved with realizing.

Viridan

  • Guest
Re: Script commands index and hints
« Reply #54 on: July 26, 2016, 04: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:

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

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

Quote
examplescript:
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.
« Last Edit: July 26, 2016, 04:55:32 PM by StillSpelledViridan »

SomeRandomCreator

  • Doctor
  • ***
  • Posts: 64
  • Internal scripting and flags are my mortal enemies
    • View Profile
Re: Script commands index and hints
« Reply #55 on: July 27, 2016, 07:48:35 AM »
Oh, THAT explains the problem I had before, and whew! I thought it was a huge problem.

lol...ipops2

  • Guest
Re: Script commands index and hints
« Reply #56 on: July 27, 2016, 09:31:30 AM »
it just creates a new script that you need to merge with the old one. for example, your script should be stored like this:

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

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

Quote
examplescript:
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

  • Global Moderator
  • Captain
  • *****
  • Posts: 2169
    • View Profile
    • The Open Level Project
Re: Script commands index and hints
« Reply #57 on: July 27, 2016, 11:26:02 AM »
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

  • Crewmate
  • *
  • Posts: 14
  • I am a gumball in the jaws of death
    • View Profile
Re: Script commands index and tips
« Reply #58 on: June 17, 2017, 05:04:40 PM »
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

  • Professor
  • ****
  • Posts: 128
  • Captain of the Gravy Train
    • View Profile
Re: Script commands index and hints
« Reply #59 on: June 17, 2017, 07:12:36 PM »
Do you have a separate script where flag 1 turns on? For that script to run, you'd need a separate script with
Quote
flag(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.)