IllegalStateException when running a script
engineer-in-a-box opened this issue ยท 1 comments
Minecraft Version
1.21.1
Version
1.116.0
Details
when I run this script:
local function sine(freq, length)
local audio = {}
for i = 1, length * 48000 do
audio[i] = math.sin(i / 48000 * freq)
end
end
local speaker = peripheral.find("speaker")
speaker.playAudio(sine(1, 1))I get the following error:
[19Jul2025 13:20:56.072] [ComputerCraft-Computer-Worker-1/ERROR] [dan200.computercraft.core.lua.ResultInterpreterFunction/COMPUTER_ERROR.JAVA]: Error calling call on dan200.computercraft.core.apis.PeripheralAPI@2c829306
java.lang.IllegalStateException: Cannot use getTableUnsafe after IArguments has been closed.
at TRANSFORMER/[email protected]/dan200.computercraft.core.lua.VarargArguments.getTableUnsafe(VarargArguments.java:181) ~[cc-tweaked-1.21.1-forge-1.116.0.jar%23193!/:1.116.0]
at TRANSFORMER/[email protected]/dan200.computercraft.core.asm.PeripheralMethodSupplier.lambda$static$0(PeripheralMethodSupplier.java:28) ~[cc-tweaked-1.21.1-forge-1.116.0.jar%23193!/:1.116.0]
at TRANSFORMER/[email protected]/dan200.computercraft.core.apis.PeripheralAPI$PeripheralWrapper.call(PeripheralAPI.java:105) ~[cc-tweaked-1.21.1-forge-1.116.0.jar%23193!/:1.116.0]
at TRANSFORMER/[email protected]/dan200.computercraft.core.apis.PeripheralAPI.call(PeripheralAPI.java:323) ~[cc-tweaked-1.21.1-forge-1.116.0.jar%23193!/:1.116.0]
at TRANSFORMER/[email protected]/dan200.computercraft.core.asm.LuaMethodSupplier.lambda$static$0(LuaMethodSupplier.java:27) ~[cc-tweaked-1.21.1-forge-1.116.0.jar%23193!/:1.116.0]
at TRANSFORMER/[email protected]/dan200.computercraft.core.lua.ResultInterpreterFunction.invoke(ResultInterpreterFunction.java:56) ~[cc-tweaked-1.21.1-forge-1.116.0.jar%23193!/:1.116.0]
at LAYER PLUGIN/cc.tweaked.cobalt/org.squiddev.cobalt.function.ResumableVarArgFunction.invoke(ResumableVarArgFunction.java:34) ~[cobalt-0.9.6.jar%23205!/:?]
at LAYER PLUGIN/cc.tweaked.cobalt/org.squiddev.cobalt.function.Dispatch.invokeImpl(Dispatch.java:175) ~[cobalt-0.9.6.jar%23205!/:?]
at LAYER PLUGIN/cc.tweaked.cobalt/org.squiddev.cobalt.function.Dispatch.invoke(Dispatch.java:63) ~[cobalt-0.9.6.jar%23205!/:?]
at LAYER PLUGIN/cc.tweaked.cobalt/org.squiddev.cobalt.function.Dispatch.invoke(Dispatch.java:58) ~[cobalt-0.9.6.jar%23205!/:?]
at LAYER PLUGIN/cc.tweaked.cobalt/org.squiddev.cobalt.function.LuaInterpreter.execute(LuaInterpreter.java:454) ~[cobalt-0.9.6.jar%23205!/:?]
at LAYER PLUGIN/cc.tweaked.cobalt/org.squiddev.cobalt.function.Dispatch.invokeImpl(Dispatch.java:166) ~[cobalt-0.9.6.jar%23205!/:?]
at LAYER PLUGIN/cc.tweaked.cobalt/org.squiddev.cobalt.function.Dispatch.invoke(Dispatch.java:63) ~[cobalt-0.9.6.jar%23205!/:?]
at LAYER PLUGIN/cc.tweaked.cobalt/org.squiddev.cobalt.function.Dispatch.invoke(Dispatch.java:58) ~[cobalt-0.9.6.jar%23205!/:?]
at LAYER PLUGIN/cc.tweaked.cobalt/org.squiddev.cobalt.LuaThread.loop(LuaThread.java:320) ~[cobalt-0.9.6.jar%23205!/:?]
at LAYER PLUGIN/cc.tweaked.cobalt/org.squiddev.cobalt.LuaThread.run(LuaThread.java:301) ~[cobalt-0.9.6.jar%23205!/:?]
at LAYER PLUGIN/cc.tweaked.cobalt/org.squiddev.cobalt.LuaThread.run(LuaThread.java:297) ~[cobalt-0.9.6.jar%23205!/:?]
at TRANSFORMER/[email protected]/dan200.computercraft.core.lua.CobaltLuaMachine.handleEvent(CobaltLuaMachine.java:131) ~[cc-tweaked-1.21.1-forge-1.116.0.jar%23193!/:1.116.0]
at TRANSFORMER/[email protected]/dan200.computercraft.core.computer.ComputerExecutor.resumeMachine(ComputerExecutor.java:556) ~[cc-tweaked-1.21.1-forge-1.116.0.jar%23193!/:1.116.0]
at TRANSFORMER/[email protected]/dan200.computercraft.core.computer.ComputerExecutor.workImpl(ComputerExecutor.java:520) ~[cc-tweaked-1.21.1-forge-1.116.0.jar%23193!/:1.116.0]
at TRANSFORMER/[email protected]/dan200.computercraft.core.computer.ComputerExecutor.work(ComputerExecutor.java:460) ~[cc-tweaked-1.21.1-forge-1.116.0.jar%23193!/:1.116.0]
at TRANSFORMER/[email protected]/dan200.computercraft.core.computer.computerthread.ComputerThread$WorkerThread.runImpl(ComputerThread.java:639) ~[cc-tweaked-1.21.1-forge-1.116.0.jar%23193!/:1.116.0]
at TRANSFORMER/[email protected]/dan200.computercraft.core.computer.computerthread.ComputerThread$WorkerThread.run(ComputerThread.java:593) ~[cc-tweaked-1.21.1-forge-1.116.0.jar%23193!/:1.116.0]
at java.base/java.lang.Thread.run(Thread.java:1575) [?:?]
and here's the log, the error is on line 461
latest.log
Thanks for the report! Oh, this was a very daft bug, but very specific conditions to trigger it (call playAudio with no arguments), so somehow we've managed to avoid hitting it until now!
In case you hadn't fixed this already, your sine function is missing a return audio at the end, which causes playAudio to be called with no arguments, rather than the audio samples!