var = <geomid> and var = entitybygeomid(<geomid>)

About advanced scenes, and the Thyme scripting language used in Algodoo.

var = <geomid> and var = entitybygeomid(<geomid>)

Postby FRA32 » Thu Dec 10, 2015 3:48 pm

I am trying to recode some AI drones that another user once made and that I modded which broke during an update ,and thought of the following:

When I safe the geomID of an object in a variable and use this variable to create a local var using entitybygeomid to adress that object, the code works pretty well, but recreates that reference everytime.

But when I safe the entityByGeomId()-reference of said object in a var and directly use that var for my code, it wont work anymore. I can only guess that this is because of the fact that entityByGeomId wont update anymore if its set at the beginning and then left unupdated, but the objects wont work anymore at all, they dont even move to the position of this reference, no matter if its updated or not.

My question now is: How can I store a reference of some entity in my AI-Drone without restoring this reference in every single code block every single time the code blocks execute? I need these references both for movement, for laser aiming, for bullet firing, for priority checks etc. , so all these parallel codes all use seperate instances of the entity which kinda takes up some memory. I need a way of making them share the same instance without breaking the code or similar.

I know it could work if I put all code snippets into 1 single function inside postStep ,but this would make the coding quite messy and I would need to use a textbox in order to edit the code...
FRA32
 
Posts: 229
Joined: Wed Dec 03, 2014 9:51 pm

Re: var = <geomid> and var = entitybygeomid(<geomid>)

Postby T'wind_ » Thu Dec 10, 2015 7:49 pm

You should write scene. in front of entitybygeomid.
scene.entitybygeomid(<geomid>)
User avatar
T'wind_
 
Posts: 86
Joined: Wed Jul 08, 2015 5:33 pm
Location: Western Europe


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 6 guests

cron