#lua cutscenes - a couple questions

1 messages · Page 1 of 1 (latest)

formal stump
#
  1. is there a way to randomize a flag activated/deactivated or wait time?
  2. i assume to change colorgrade you need to do it via a flag?
#

oh also can it loop?

copper jay
#
  1. This would be better explained with an example:
function onBegin()
  math.randomseed(os.time()) -- This gives us a unique seed for the random number generator
  flags = {"flag_a", "flag_b"} -- Declare our flags
  index = math.random(1, #flags) -- Choose a random number between 1, and the number of flags.
  flag = flags[index] -- use that number to get the flag
  setFlag(flag, true) -- set that flag
end
formal stump
#

ah okay

copper jay
#
  1. You would do this via calling C# code.
formal stump
#

i assume for wait time id do the same but replace setflag with wait and flags/variables/etc. with associated things

wispy edge
#

math.random is lua randomness, so not consistent

#

for purely visual stuff that's fine, but generally you should use celeste's own random system

formal stump
#

consistency isnt required

#

purely visual

copper jay
formal stump
#

tas

copper jay
#

oh

copper jay
formal stump
#

ah okay

#

do i have to set up a file for the c# stuff

wispy edge
#

no

copper jay
#

no

formal stump
#

oh okay

wispy edge
fossil stratus
formal stump
#

do i have to put room name anywhere

#

also, how do i make it loop?

wispy edge
formal stump
#

ah okay

wispy edge
#

oops enter

#
while true do
  --stuff you want to check
  wait()
end
formal stump
#

ty!

wispy edge
#

wait() pauses the execution until the next frame (running an infinite loop in a single frame is a bad idea)

formal stump
#

how would i stop the loop on room exit? ik i need to replace the true but not sure what with

wispy edge
#

it does automatically. the cutscene is part of a cutscene entity in the room, so it will stop when you leave the room

formal stump
#

ah okay

#

ty!

wispy edge
#

also make sure to call

makeUnskippable()
enableRetry()

at the start of onBegin (assuming this isn't an actual cutscene)

formal stump
#

ah okay

#

adding that

wispy edge
#

actually you can just tick unskippable on the cutscene trigger I think

formal stump
#

so rn i have

`function onBegin()

makeUnskippable()
enableRetry()

while true do

math.randomseed(os.time())
index = math.random(8, 30)
wait(index)

getRoom():SnapColorGrade(“whoYellow”)
wait(.35)
getRoom():SnapColorGrade(“whograde”)

end

end`

#

is that good?

wispy edge
#

you don't want to seed the rng every loop, just do that once at the start

formal stump
#

ah okay

#

moved that out of the loop

wispy edge
#

otherwise that seems sensible

formal stump
#

okay epic!

wispy edge
#

btw you can do ``` for code blocks instead of using single backticks for each line individually

formal stump
#

oh okay

wispy edge
#

you can even start the code block with ```lua to get syntax highlighting

wispy edge
formal stump
#

oh it doesnt appear like that on mobile

wispy edge
#

if you want a minuscule performance boost, you can do local level = getRoom() before the loop and then replace the getRoom() calls after that with level

#

it doesn't matter at all, I'm just a code style pedant yinyan5Laugh

formal stump
#

do i include the Assets part of the filename in the filename field in lonn?

wispy edge
#

uh I think so?

formal stump
#

okay

#

ty!

wispy edge
#

(I have never actually written a lua cutscene so I'm not 100% sure pausefrogeline )

#

the wiki says so yeah

formal stump
#

oh yea just saw