Community Forum

Scanning the "world" for other nodes with attributes?

Forum Overview >> Farming Simulator 2009

CategoryFarming Simulator 2009
Created16.07.2010 10:34


Christer F (unknown) 16.07.2010 10:46
Problem:
I want to find a specific node with a user attribute in the map while ingame. In the script code.
In this case is the strawelevator that I'm interested in. As it is not a item that goes into the saving process (it's constantly in the map) I can't scan the g_currentMission.itemsToSave table. So which table is it?
The scanning will be done with the getUserAttribute function, but I don't want to be wasteful and go through ALL items of the world. The conveyor belt of the straw elevator has this onCreate attribute with value: "BarnMoverTrigger.onCreate", thus one can be pretty sure that it is actually the straw elevator that I find.

I want to find this because I like to know the world coordinates of an adjacent spot to the straw elevator (i.e. where to drop bales to). Going with this conveyor belt vector + custom offset vector would give me this.

Is there any other solution than

Thanks in advance


Stefan Geiger - GIANTS Software 20.07.2010 10:35
The BarnMoverTrigger registers it selfs in the g_currentMission.updateables table.

However it might be a better to overwrite the BarnMoverTrigger.onCreate function and do your own logic there.

So you might write something like this:

myBarnMoverTriggerTable = {};

local oldBarnMoverTriggeronCreate = BarnMoverTrigger.onCreate;

BarnMoverTrigger.onCreate = function(self, id)
oldBarnMoverTriggeronCreate(self, id);

myBarnMoverTriggerTable[id] = id;
end;


Then you can use myBarnMoverTriggerTable to loop over all triggers.


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