#lua cutscene help
81 messages · Page 1 of 1 (latest)
call its Break() method
i've never worked with lua before but what specifically would i write to do that
are you familiar with the C# side of celeste modding? you can do local celeste = require("#celeste") in your cutscene and then you can call any c# methods in there. in this case you probably want to use the Tracker to get the dash block (unless there's multiple dash blocks in the room, in which case you'll need some more fuckery) and call its Break method
although I'm actually not sure how to call generic methods from lua
i'll just open ilspy and see if that works
from a C# side, what you want to do is player.Scene.Tracker.GetEntity<DashBlock>().Break()
I'm just not sure how to do the GetEntity call in lua rn
oh there's a helper function for this
getEntity("DashBlock"):break() should work I think
local celeste = require("#celeste")
function onBegin()
getEntity("DashBlock"):break()
end
this is what i have
you don't even need the celeste import anymore
doesn't seem to be responsive
oh it probably has to be Break, whoops
(07/22/2022 17:45:29) [Everest] [Error] [Lua Cutscenes] Failed to resume coroutine
--------------------------------
Detailed exception log:
--------------------------------
NLua.Exceptions.LuaScriptException: Invalid arguments to method: DashBlock.Break
stack traceback:
[C]: in function 'coroutine.resume'
[string "Mods/LuaCutscenes.zip/Assets/LuaCutscenes/cut..."]:6: in function <[string "Mods/LuaCutscenes.zip/Assets/LuaCutscenes/cut..."]:5>
at Celeste.Mod.LuaCoroutine.MoveNext() in /home/vsts/work/1/s/Celeste.Mod.mm/Mod/Helpers/LuaCoroutine.cs:line 21
at Celeste.Mod.LuaCutscenes.LuaHelper.SafeMoveNext(LuaCoroutine enumerator)
(07/22/2022 17:45:31) [Everest] [Error] [Lua Cutscenes] Failed to resume coroutine
--------------------------------
Detailed exception log:
--------------------------------
NLua.Exceptions.LuaScriptException: Invalid arguments to method: DashBlock.Break
stack traceback:
[C]: in function 'coroutine.resume'
[string "Mods/LuaCutscenes.zip/Assets/LuaCutscenes/cut..."]:6: in function <[string "Mods/LuaCutscenes.zip/Assets/LuaCutscenes/cut..."]:5>
at Celeste.Mod.LuaCoroutine.MoveNext() in /home/vsts/work/1/s/Celeste.Mod.mm/Mod/Helpers/LuaCoroutine.cs:line 21
at Celeste.Mod.LuaCutscenes.LuaHelper.SafeMoveNext(LuaCoroutine enumerator)
oh whoops Break needs arguments yeah
signature is public void Break(Vector2 from, Vector2 direction, bool playSound = true, bool playDebrisSound = true)
(07/22/2022 17:47:27) [Everest] [Error] [Lua Cutscenes] Failed to load cutscene in Lua: attempt to call a nil value
when a dash block is broken normally, from is the player's position and direction is the dash direction
what does your cutscene look like now?
I mean what is the new code
local celeste = require("#celeste")
function onBegin()
public void Break(Vector2 from, Vector2 direction, bool playSound = true, bool playDebrisSound = true)
end
oh
I just copied the c# signature to show you what parameters it takes
you need to give it the right arguments
specifically you need to give it vectors for from and direction
the others you can leave out
local Vector2 = require("#microsoft.xna.framework.vector2")
function onBegin()
public void Break(Vector2(0, 0), Vector2(0, 0))
end
trie this, but with a sensible position for the first vector
the second is ignored I think
local Vector2 = require("#microsoft.xna.framework.vector2")
function onBegin()
public void Break(Vector2(-52, 1430), Vector2(0, 0))
end
still getting the nil value error
oh I copied too much of your cutscene
local Vector2 = require("#microsoft.xna.framework.vector2")
function onBegin()
getEntity("DashBlock"):Break(Vector2(-52, 1430), Vector2(0, 0))
end
it worked, thank you very much lol

note that if there's multiple dash blocks in the room, finding the right one is more complicated
im noticing that but im gonna try and just make it one if i can
you could use fancy dash blocks for the others or smth
nvm that, they're tracked as dash blocks
yeah you'd probably have to check for entity ID or something like that
local Vector2 = require("#microsoft.xna.framework.vector2")
function onBegin()
for i, block in getEntities("DashBlock") do
if block:id:ID == 1234 then
block:Break(Vector2(-52, 1430), Vector2(0, 0))
end
end
end
try something like this?
with the correct ID obv
nvm hold on, this is python syntax
local Vector2 = require("#microsoft.xna.framework.vector2")
function onBegin()
for i, block in pairs(getEntities("DashBlock")) do
if block:id:ID == 1234 then
block:Break(Vector2(-52, 1430), Vector2(0, 0))
end
end
end
does just accessing private fields work like that in lua cutscenes 
idk, it looked like one of the helper functions does so
some more nil value stuff
can you post the exact error?
(07/22/2022 18:20:15) [Everest] [Error] [Lua Cutscenes] Failed to load cutscene in Lua: attempt to call a nil value
no detailed exception log?
requiring celeste doesn't do anything unless you need to use it
if block:id:ID == 1234 then
is there anything wrong with this line
it mentioning id twice is 🤨
i tried replacing the id with the entity's index and that didnt work either
local Vector2 = require("#microsoft.xna.framework.vector2")
function onBegin()
setFlag("brokenBlock", true)
for i, block in pairs(getEntities("DashBlock")) do
if block:id:ID == 916 then
block:Break(Vector2(155, 1385), Vector2(0, 0))
end
end
end
just gonna drop the code im working with here
it's bc it has a field called id, which is a struct with a field called ID
could checking another entity property work?
if it being an id check is causing the problem
you could check X and Y I guess
hmm that gives the exact same error
local Vector2 = require("#microsoft.xna.framework.vector2")
function onBegin()
setFlag("brokenBlock", true)
for i, block in pairs(getEntities("DashBlock")) do
if blockY == 2008 then
block:Break(Vector2(155, 1385), Vector2(0, 0))
end
end
end
this gives no nil value error
but nothing happens either