#lua cutscene help

81 messages · Page 1 of 1 (latest)

quasi slate
#

i just want a simple lua cutscene that causes an on screen dash block to break, how would i accomplish this?

main obsidian
#

call its Break() method

quasi slate
#

i've never worked with lua before but what specifically would i write to do that

main obsidian
#

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

quasi slate
#

i'll just open ilspy and see if that works

main obsidian
#

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

quasi slate
#
local celeste = require("#celeste")
function onBegin()
        getEntity("DashBlock"):break()
end
#

this is what i have

main obsidian
#

you don't even need the celeste import anymore

quasi slate
#

doesn't seem to be responsive

main obsidian
#

oh it probably has to be Break, whoops

quasi slate
#
(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)
main obsidian
#

oh whoops Break needs arguments yeah

#

signature is public void Break(Vector2 from, Vector2 direction, bool playSound = true, bool playDebrisSound = true)

quasi slate
#

(07/22/2022 17:47:27) [Everest] [Error] [Lua Cutscenes] Failed to load cutscene in Lua: attempt to call a nil value

main obsidian
#

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?

quasi slate
#

nothing happens

#

it just gives an error

main obsidian
#

I mean what is the new code

quasi slate
#
local celeste = require("#celeste")
function onBegin()
    public void Break(Vector2 from, Vector2 direction, bool playSound = true, bool playDebrisSound = true)
end
main obsidian
#

oh maddyS 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

quasi slate
#
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

main obsidian
#

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

quasi slate
#

it worked, thank you very much lol

main obsidian
#

note that if there's multiple dash blocks in the room, finding the right one is more complicated

quasi slate
#

im noticing that but im gonna try and just make it one if i can

main obsidian
#

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

quasi slate
#

what would i add for that

#

it appears this room has a lot of dash blocks

main obsidian
#
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
upper jetty
#

does just accessing private fields work like that in lua cutscenes thinkeline

main obsidian
#

idk, it looked like one of the helper functions does so

quasi slate
#

some more nil value stuff

main obsidian
#

can you post the exact error?

quasi slate
#

(07/22/2022 18:20:15) [Everest] [Error] [Lua Cutscenes] Failed to load cutscene in Lua: attempt to call a nil value

main obsidian
#

no detailed exception log?

quasi slate
#

nop

#

tried requiring celeste, nothing

main obsidian
#

requiring celeste doesn't do anything unless you need to use it

quasi slate
#

ah

#

gonna go eat but if you figure it out lmk

quasi slate
#
        if block:id:ID == 1234 then
#

is there anything wrong with this line

#

it mentioning id twice is 🤨

quasi slate
#

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

main obsidian
quasi slate
#

could checking another entity property work?

#

if it being an id check is causing the problem

main obsidian
#

you could check X and Y I guess

quasi slate
#

hmm that gives the exact same error

quasi slate
#
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

main obsidian
#

block:Y, not blockY

#

oh block.Y actually

#

speaking of, try block.id.ID instead of the colons

quasi slate
#

nothing happened

#

no error either

#

i found a way to do something similar with a rumble trigger and rumble block