#lua cutscenes - a couple questions
1 messages · Page 1 of 1 (latest)
- 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
ah okay
- You would do this via calling C# code.
i assume for wait time id do the same but replace setflag with wait and flags/variables/etc. with associated things
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
why would you want something random to be consistent?
tas
oh
something like getRoom():SnapColorGrade("nameofcolorgrade")
no
no
oh okay
or getRoom():NextColorGrade("name", fadespeed) if you want to fade smoothly
so that you don't annoy people who need the behaviour to be consistent 
no, getRoom() just gets the current room
ah okay
use a while loop with a wait() call in it. so like
oops enter
while true do
--stuff you want to check
wait()
end
ty!
wait() pauses the execution until the next frame (running an infinite loop in a single frame is a bad idea)
how would i stop the loop on room exit? ik i need to replace the true but not sure what with
it does automatically. the cutscene is part of a cutscene entity in the room, so it will stop when you leave the room
also make sure to call
makeUnskippable()
enableRetry()
at the start of onBegin (assuming this isn't an actual cutscene)
actually you can just tick unskippable on the cutscene trigger I think
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?
you don't want to seed the rng every loop, just do that once at the start
otherwise that seems sensible
okay epic!
btw you can do ``` for code blocks instead of using single backticks for each line individually
oh okay
you can even start the code block with ```lua to get syntax highlighting
that's why stuff is colored here
oh it doesnt appear like that on mobile

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 
do i include the Assets part of the filename in the filename field in lonn?
uh I think so?
(I have never actually written a lua cutscene so I'm not 100% sure
)
the wiki says so yeah
oh yea just saw