Jump to content

"assertion failed!" in stategraph.lua


Recommended Posts

I'm trying to make a mod that adds a shock wave (same as Bearger's ground pound) to Glommer's idle animation when he slams the ground. When I launch it it causes the game to crash. This is the log output:

[00:00:18]: ModIndex: Beginning normal load sequence.
	
[00:00:19]: SUCCESS: Loaded modoverrides.lua	
[00:00:19]: modoverrides.lua enabling glommer_shockwave	
[00:00:19]: ModIndex:GetModsToLoad inserting moddir, 	glommer_shockwave	
[00:00:19]: Could not load mod_config_data/modconfiguration_glommer_shockwave_staging	
[00:00:19]: ModIndex:SetTempModConfigData	
[00:00:19]: Could not load mod_config_data/modconfiguration_glommer_shockwave_staging_CLIENT	
[00:00:19]: Loading mod: glommer_shockwave (Glommer Shockwave) Version:0.0.1	
[00:00:19]: applying configuration_options from modoverrides.lua to mod glommer_shockwave	
[00:00:19]: Mod: glommer_shockwave (Glommer Shockwave)	Loading modworldgenmain.lua	
[00:00:19]: Mod: glommer_shockwave (Glommer Shockwave)	  Mod had no modworldgenmain.lua. Skipping.	
[00:00:19]: Mod: glommer_shockwave (Glommer Shockwave)	Loading modmain.lua	
[00:00:19]: MOD ERROR: glommer_shockwave (Glommer Shockwave): Mod: glommer_shockwave (Glommer Shockwave)	
[00:00:19]: Event data unavailable: lavaarena_event_server/lavaarena_achievement_quest_defs
[00:00:19]: [string "scripts/stategraph.lua"]:184: assertion failed!
LUA ERROR stack traceback:
        =[C] in function 'assert'
        scripts/stategraph.lua(184,1) in function '_ctor'
        scripts/class.lua(181,1) in function 'TimeEvent'
        ../mods/glommer_shockwave/modmain.lua(37,1) in main chunk
        =[C] in function 'xpcall'
        scripts/util.lua(754,1) in function 'RunInEnvironment'
        scripts/mods.lua(558,1) in function 'InitializeModMain'
        scripts/mods.lua(532,1) in function 'LoadMods'
        scripts/main.lua(340,1) in function 'ModSafeStartup'
        scripts/main.lua(446,1)
        =[C] in function 'SetPersistentString'
        scripts/mainfunctions.lua(26,1) in function 'SavePersistentString'
        scripts/modindex.lua(119,1)
        =[C] in function 'GetPersistentString'
        scripts/modindex.lua(106,1) in function 'BeginStartupSequence'
        scripts/main.lua(445,1) in function 'callback'
        scripts/modindex.lua(735,1)
        =[C] in function 'GetPersistentString'
        scripts/modindex.lua(709,1) in function 'Load'
        scripts/main.lua(444,1) in main chunk
[00:00:19]: [string "scripts/mainfunctions.lua"]:1338: variable 'global_error_widget' is not declared
LUA ERROR stack traceback:
        =[C] in function 'error'
        scripts/strict.lua(23,1)
        scripts/mainfunctions.lua(1338,1)
        =[C] in function 'GetPersistentString'
        scripts/quagmire_recipebook.lua(54,1) in function 'Load'
        scripts/main.lua(358,1) in function 'ModSafeStartup'
        scripts/main.lua(446,1)
        =[C] in function 'SetPersistentString'
        scripts/mainfunctions.lua(26,1) in function 'SavePersistentString'
        scripts/modindex.lua(119,1)
        =[C] in function 'GetPersistentString'
        scripts/modindex.lua(106,1) in function 'BeginStartupSequence'
        scripts/main.lua(445,1) in function 'callback'
        scripts/modindex.lua(735,1)
        =[C] in function 'GetPersistentString'
        scripts/modindex.lua(709,1) in function 'Load'
        scripts/main.lua(444,1) in main chunk
[00:00:19]: Faild to load the cookbook!	false	[string "scripts/json.lua"]:450: Failed to load string [ return "filters"] in JSON4Lua.decode_scanString at position 2 : 11	
[00:00:19]: Failed to load the plantregistry!	function: 0000000013592330	
[00:00:19]: DoLuaFile Error: (null)
[00:00:19]: LuaError but no error string
[00:00:19]: Error loading main.lua
[00:00:19]: Failed mSimulation->Reset()
[00:00:19]: ModWorkshop::CancelDownloads clearing all unfinished downloads
[00:00:19]: Collecting garbage...
[00:00:19]: lua_gc took 0.04 seconds
[00:00:19]: ~ShardLuaProxy()
[00:00:19]: ~cEventLeaderboardProxy()
[00:00:19]: ~ItemServerLuaProxy()
[00:00:19]: ~InventoryLuaProxy()
[00:00:19]: ~NetworkLuaProxy()
[00:00:19]: ~SimLuaProxy()
[00:00:19]: ModWorkshop::CancelDownloads clearing all unfinished downloads
[00:00:19]: lua_close took 0.02 seconds
[00:00:20]: ModWorkshop::CancelDownloads clearing all unfinished downloads
[00:00:20]: [Steam] Auth ticket cancelled
[00:00:20]: Orphaned unnamed resource. This resource must have used Add( resource ) to insert itself into the manager. 
[00:00:20]: CurlRequestManager::ClientThread::Main() complete
[00:00:20]: HttpClient2 discarded 0 callbacks.
[00:00:20]: Shutting down

I've truncated it to only the output that I think is relevant, but I can provide the whole log file if desired.

This is what my modmain.lua looks like:

local require = GLOBAL.require
local State = GLOBAL.State
local Action = GLOBAL.Action
local ActionHandler = GLOBAL.ActionHandler
local TimeEvent = GLOBAL.TimeEvent
local EventHandler = GLOBAL.EventHandler
local ACTIONS = GLOBAL.ACTIONS
local FRAMES = GLOBAL.FRAMES 
all_clients_require_mod = true 

local function StartFlap(inst)
	if inst.FlapTask then return end
	inst.FlapTask = inst:DoPeriodicTask(4*FRAMES, function(inst) inst.SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/flap") end)
end

local function StopFlap(inst)
	if inst.FlapTask then
		inst.FlapTask:Cancel()
		inst.FlapTask = nil
	end
end

local edit = State({
		name = "bored",
		tags = {"busy"},

		onenter = function(inst)
			inst.Physics:Stop()
			inst.AnimState:PlayAnimation("bored")
			StartFlap(inst)
			print("Hello World!")
		end,

		timeline = 
		{
			TimeEvent(6*FRAMES, function(inst) inst.SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/bounce_voice") end),
            TimeEvent(11*FRAMES, LandFlyingCreature),
			TimeEvent(12*FRAMES, function(inst) inst.SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/bounce_ground") end),
            TimeEvent(18*FRAMES, RaiseFlyingCreature),
			TimeEvent(25*FRAMES, function(inst) inst.SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/bounce_voice") end),
            TimeEvent(33*FRAMES, LandFlyingCreature),
			TimeEvent(34*FRAMES, function(inst) inst.SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/bounce_ground") end),
            TimeEvent(38*FRAMES, RaiseFlyingCreature),
			TimeEvent(45*FRAMES, function(inst) inst.SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/bounce_voice") end),
            TimeEvent(54*FRAMES, LandFlyingCreature),
			TimeEvent(55*FRAMES, function(inst) inst.SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/bounce_ground") end),
            TimeEvent(60*FRAMES, RaiseFlyingCreature),
		},

		events =
		{
			EventHandler("animover", function(inst) inst.sg:GoToState("idle") end)
		},

        onexit = RaiseFlyingCreature,
	}
)

AddStategraphState("glommer", edit)

I know that some of the globals I've included aren't necessary, but I'm just worried about being able to access his idle animation for now, so I'll clean that up later. To that end, as a first step, I've pretty much just copied the code from his stategraph and added a simple Hello World to make sure that I'm actually overriding it, which is most of what you see in my modmain.lua. I looked at stategraph.lua to pinpoint the line where the error happens, and it says "assert (type(time) == "number")", however I have no idea why that assert might be failing. Any help would be much appreciated.

Link to comment
Share on other sites

assert (type(fn) == "function")
--from this code block:
TimeEvent = Class(
    function(self, time, fn)
        local info = debug.getinfo(3, "Sl")
        self.defline = string.format("%s:%d", info.short_src, info.currentline)
        assert (type(time) == "number")
        assert (type(fn) == "function")
        self.time = time
        self.fn = fn
    end)

This is line 184 in stategraph.lua. As you can see, the assertion fails when checking the TimeEvent parts of your state.

Where are the functions RaiseFlyingCreature and LandFlyingCreature? In the snippet you posted, they are not defined. This is probably the cause as then the fn of TimeEvent is nil, which is not a function.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...