Community Forum

Vehicle tiptrigger lua error

Forum Overview >> Farming Simulator 2009

CategoryFarming Simulator 2009
Created05.07.2009 13:03


Heady Planet-ls (Headshot XXL) 05.07.2009 13:11
Hallo,

with the following script i add a tiptrigger form a vehicle:

self.trigger = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.trigger#index"));
table.insert(g_currentMission.tipTriggers, TipTrigger:new(self.trigger));


but if i sell the vehicle then is there a lua error:

Lua: Unknown entity id: 24432 method name: getTranslation
Callstack:
dataS/scripts/triggers/TipTrigger.lua@77 (getTranslation)
dataS/scripts/BaseMission.lua@760 (update)
dataS/missions/mission00.lua@280 (update)
dataS/scripts/main.lua@314 (update)
Error running lua function: update
[string "dataS/scripts/triggers/TipTrigger.lua"]:78: attempt to perform arithmetic on local 'y' (a nil value)



Michael Pillkahn (Unknown) 06.07.2009 07:08
do you check that self.trigger is no nil?

Stefan Geiger - GIANTS Software 06.07.2009 08:59
You have to make sure, you remove your trigger from the g_currentMission.tipTriggers array (search for it an delete) in the delete method of your vehicle.

If you sell your vehicle, the root node of the vehicle as well as all its children are deleted, including the trigger node, thats why it says "Unknown entity id".

Heady Planet-ls (Headshot XXL) 06.07.2009 18:47
Yes i know after sell the vehicle that the trigger(object) no longer exist.

table.remove(g_currentMission.tipTriggers, self.trigger);
or
table.remove(g_currentMission.tipTriggers, TipTrigger:new(self.trigger));
does not work.

Can you write the Code for delete the trigger-entry of the table g_currentMission.tipTriggers?



Stefan Geiger - GIANTS Software 06.07.2009 22:20
for i=1, table.getn(g_currentMission.tipTriggers) do
if g_currentMission.tipTriggers[i] == self.trigger then
table.remove(g_currentMission.tipTriggers, i);
end;
end;

Heady Planet-ls (Headshot XXL) 07.07.2009 20:13
I wrote this in the delete function of my script but it does not work.
I get the same lua error

Stefan Geiger - GIANTS Software 08.07.2009 08:34
The problem is, your insert code looks like this:
table.insert(g_currentMission.tipTriggers, TipTrigger:new(self.trigger));

Then you can't search for self.trigger in this map.

You should do something like this:
self.triggerObject = TipTrigger:new(self.trigger);
table.insert(g_currentMission.tipTriggers, TipTrigger:new(self.triggerObject));

And adjust the "if" in the delete code:
if g_currentMission.tipTriggers[i] == self.triggerObject then

Heady Planet-ls (Headshot XXL) 08.07.2009 17:47
I changed this but i have always the lua error

The Trigger is in a Mod Vehicle, not in a Map.

Heady Planet-ls (Headshot XXL) 09.07.2009 21:51
I have uploaded the Mod, you can yourself try to fix the bug.

http://team-flash.eu/heugeblaese.zip

Heady Planet-ls (Headshot XXL) 19.07.2009 20:37
Does anyone know an answer?

Stefan Geiger - GIANTS Software 20.07.2009 09:20
Unfortunately a cant reproduce the error.

I bought and sold the tool. All works without an error. Do you have any other mods installed which might change any functions of the game?

Heady Planet-ls (Headshot XXL) 20.07.2009 17:19
0.0 you have right. I have only the Mod at the mods folder and it works.

Thank you for the Support.


Note: Log in to post. Create a new account here.