Page 3 of 5

Re: Common Serialization (Saving) Pitfalls

Posted: Sat Oct 03, 2015 7:21 am
by Azel
Drakkan wrote:Hi guys. when trying to load the game from certain point (unfortunately I didnt noticed where it started went wrong) I get:

=== Software Failure ===

[string "Component.lua"]:0: invalid trigger action
stack traceback:
[C]: in function 'assert'
[string "Component.lua"]: in function 'addConnector'
[string "GameObject.lua"]: in function 'loadState'
[string "Map.lua"]: in function 'loadState'
[string "GameMode.lua"]: in function 'loadGame'
[string "GameMode.lua"]: in function 'update'
[string "Grimrock.lua"]: in function 'display'
[string "Grimrock.lua"]: in main chunk

any clues from a first look ?
Hey so today I got this error while testing the final version of my Mod. It was an easy thing to fix, but figured I would post the solution here in case anyone else encounters this issue.

The scenario:

1) The player traveled to a new location and stepped on a trigger
2) The trigger had a connector to a Script Entity that no longer existed
3) An on-screen error message appeared in the game, "warning! invalid connector action: script_entity_76.ConfirmMechAge"
4) Any time the player saves the game after this message occurs, the game will crash during the next attempt to load the game

How I caused this problem in the first place:

1) I originally had a script_entity_76 and it did have a method called, "ConfirmMechAge"
2) I then tied a floor_trigger to this Method.
3) Later (weeks later), I was making a change and decided to delete script_entity_76 and start something new
4) I thought I had removed all connectors to this Script, but I was wrong
5) I assumed that while playing the game, I would get a warning that a trigger was still connected to a non-existent entity (I was wrong)
6) During my Editor Testing, I never actually stepped on all my floor triggers, so I never encountered this error
7) During a full exported dungeon play-test, I caught this error

The lesson?

1) Be sure to document all dependencies in the game (Google, "Regression Testing")
2) Always fully play-test the exported version of your Dungeon before releasing it to the public

Fin :mrgreen:

Re: Common Serialization (Saving) Pitfalls

Posted: Mon Nov 09, 2015 12:46 pm
by FeMaiden
not sure this helps or not...but if you ever have a situation where you have like 100 floor triggers in your mod and can't figure out which one is causing the problem, you can hit ctrl-f or whatever hotkey you may have bound in your preferences to look at a list of all the entities you placed.
I mention this because I only just discovered it today...after almost a month of this

Re: Common Serialization (Saving) Pitfalls

Posted: Mon Nov 09, 2015 1:01 pm
by minmay
Here's a script to detect invalid connector targets/actions in your dungeon.

Code: Select all

function connectorCheck()
	for l=1,Dungeon.getMaxLevels() do
		for e in Dungeon.getMap(l):allEntities() do
			for _,c in e:componentIterator() do
				if c.getConnectorCount then
					for i=1,c:getConnectorCount() do
						local event,target,action = c:getConnector(i)
						local tEntity = findEntity(target)
						if not tEntity then
							print("Nonexistent connector target: "..target.." (from "..e.id..")")
						else
							if not
							((tEntity.controller and tEntity.controller[action])
							or (tEntity.script and tEntity.script[action])) then
								print("Nonexistent connector action: "..action.." (from "..e.id.." to "..target..")")
							end
						end
					end
				end
			end
		end
	end
end
edit: note, this won't detect cases where:
- you have a ScriptComponent named "script" that has the action, but it's missing a ScriptController to go with it
- you have components named "controller" or "script" that aren't actually (Script)ControllerComponents or ScriptComponents
- a connector specifies an invalid event
I didn't bother including these because you would pretty much have to introduce them on purpose.

Re: Common Serialization (Saving) Pitfalls

Posted: Mon Nov 09, 2015 11:33 pm
by FeMaiden
ha...whenever I think I've got this stuff figured out, someone comes in with a script proving just how little I really know.

Re: Common Serialization (Saving) Pitfalls

Posted: Tue Nov 10, 2015 2:32 am
by Isaac
That's a nice script [reading through it].

Re: Common Serialization (Saving) Pitfalls

Posted: Thu Mar 03, 2016 11:15 pm
by Lord_Foul
holy fark
awesome thread!

Re: Common Serialization (Saving) Pitfalls

Posted: Wed Mar 23, 2016 3:17 pm
by akroma222
FeMaiden wrote:ha...whenever I think I've got this stuff figured out, someone comes in with a script proving just how little I really know.
Totally :lol:
Thanks minmay, that code is super useful!

Re: Common Serialization (Saving) Pitfalls

Posted: Sun Mar 27, 2016 11:36 pm
by vieuxchat
Oh my. I just understood the minimalSaveState problem...
I've carefully placed some objects just to discover that they are like reseted on load.
Is there a way to tell the game that those particuliar objects should be totally saved ? (I mean apart creating copy object definition with minimalSaveState = false)
I now understand why we can't offset the models directly in the editor -___-

Re: Common Serialization (Saving) Pitfalls

Posted: Mon Mar 28, 2016 12:22 am
by minmay
vieuxchat wrote:Is there a way to tell the game that those particuliar objects should be totally saved ? (I mean apart creating copy object definition with minimalSaveState = false)
No.

Re: Common Serialization (Saving) Pitfalls

Posted: Mon Mar 28, 2016 9:14 am
by vieuxchat
So sad.
Thank you anyway.

I hope the devs will add such a "check" in the editor of their future titles. It adds a lot to the mood to be able to place objects at exact location.
A must would be to be able to offset the models with the mouse (so we can visually place them) instead of groping with +dx +dy +dz.