Author Topic: scripts that only appear once  (Read 796 times)

CaptainJabby

  • Crewmate
  • *
  • Posts: 7
    • View Profile
scripts that only appear once
« on: January 03, 2022, 01:31:11 am »
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

  • Captain
  • *****
  • Posts: 935
  • monolithic since 2012??
    • View Profile
    • Allison Fleischer
Re: scripts that only appear once
« Reply #1 on: January 03, 2022, 11:45:35 am »
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:

Code: [Select]
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:
Code: [Select]
ifflag(1,stop)
flag(1,on)
iftrinkets(0,script2)

script2:
Code: [Select]
#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

  • Crewmate
  • *
  • Posts: 7
    • View Profile
Re: Re: scripts that only appear once
« Reply #2 on: January 04, 2022, 09:24:51 pm »
i tried this out and it actually worked perfectly! thank the you very much !  :viridian:

CaptainJabby

  • Crewmate
  • *
  • Posts: 7
    • View Profile
Re: scripts that only appear once
« Reply #3 on: January 09, 2022, 09:51:52 pm »
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: