scripts that only appear once

Started by CaptainJabby, January 03, 2022, 01:31:11 AM

Previous topic - Next topic

CaptainJabby

i have not used these forums in like 100 years Anyway
i recently have started getting back into making levels, but, even after all these years, i still have yet to really figure out how to make scripts that can only be activated once. does anyone have the answer to this century-old mystery?

thats it I May Be Stupid :victoria: ,

allison

sure, i can try to explain this! i'm assuming you have a basic understanding of how normal vvvvvv scripting works.

the flag commands are what we need here. you can make a script non-repeating by putting this simple code at the top:

ifflag(1,stop)
flag(1,on)
#your script goes here


the use of 1 and stop here is just for example. in practice, flags are global and persistent throughout your level, so you'll want to use different flag numbers in different scripts. and stop just needs to be any script name that doesn't exist. if you enter a script that really does exist, that'll be run the second time instead of doing nothing.

the big caveat here is, if you use this code with a script with dialogue boxes in it, you'll run into an issue! the game creates "cutscene bars" (the letterbox effect) at the start of any (simplified) script with dialogue commands in it. this is fine in most cases, but it'll cause a bug in our script: when the player returns to the script after having already triggered it, even though no dialogue shows up, the cutscene bars will appear and they won't go away. this can get very annoying, since the player has to keep navigating the level while these black bars are covering up part of the screen.

to work around this, if our script contains say or reply commands, we use a different method. create TWO scripts: script1, which is the one your script box is running, and script2, which isn't connected to any script box or terminal. then, we can do this:

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


script2:
#your script goes here

as before, script names and flag numbers are examples. troubleshooting tip: i think if script2 starts with a 'say' or 'reply' command right at the very beginning that can cause glitches? it's been a minute since i worked on a vvvvvv level but if doing that causes issues you can try adding a filler line at the start.

let me know if anything's unclear or confusing! i'm writing this at some ungodly hour lol, but i tried my best to make it make sense

CaptainJabby

i tried this out and it actually worked perfectly! thank the you very much !  :viridian:

CaptainJabby

another thing actually
whenever i add that text in a script where only viridian is talking, it works
but when i add it to a script with multiple characters speaking, it makes every line viridian's color. is there a way to fix this?

i may be stupid again :victoria:

SHARKIE

say(1,yellow)
hi im vitellary
reply(1)
hi vitellary
say(1,pink)
guys, i think vitellary is a scammer
reply(1)
what are you talking about
say(2,yellow)
GET FREE ROBUX
GET FREE ROBUX
reply(1)
oh
say(1,red)
vermillion!
say(1,pink)
the pokemon in the house
reply(1)
XD
say(1,yellow)
FREE ROBUX AT SCAM.EXAMPLE.COM/FREE-ROBUX
try that