add values to an objekt

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

add values to an objekt

Postby Username? » Thu Mar 24, 2011 3:25 pm

I tryed to add a new value to an objekt.
I typed "X = 1" in the lowermost box of the script menu.
The new value appeared, and the script was able to use the value.
But if I reload the scene, X = 1 disappeared.
Then I tryed to type "X := 1". Exactly the same problem.

I remember a post, which was about the same problem, but I wasn't able to find it. If you know where that post is, pls link to it.
Check my most scripted scene
Code: Select all
       /^°>#
____.<=/`°`    #<°^==>._____
     ``         ´´  ´´
User avatar
Username?
 
Posts: 65
Joined: Sun Sep 20, 2009 8:06 pm

Re: add values to an objekt

Postby hiltropper » Thu Mar 24, 2011 10:58 pm

viewtopic.php?f=13&t=411

step 2

no problem to ask but little searching ... ;)
yup yup
yuuuuuuup
yupyupyupyupyupyupyupyupyyyuuuup
hm... signatures...
hiltropper
 
Posts: 85
Joined: Mon Dec 20, 2010 12:02 pm
Location: Germany

Re: add values to an objekt

Postby electronicboy » Fri Mar 25, 2011 12:33 am

@hilt, if you read the post, he wants to store a variable on a geometry. NOT in the scene.my section

From my experience, best advice would be create a collider that has 1 small collision with the object as sometimes these new custom variables are saved, and sometimes there not.

if you are using an object such as a laser, my method would be similar to this

Code: Select all
e.geom/other.X := 1,
E.laser/this.oncollide/onlaserhit = <default info in thyme exe section or custom code for collider>


If you need an example, i will create one tomorrow when im not supposed to be asleep...
When asking for help, READ THE STICKIES!
electronicboy
 
Posts: 1694
Joined: Mon Aug 31, 2009 6:18 pm

Re: add values to an objekt

Postby Username? » Fri Mar 25, 2011 8:17 am

The same problem, that I can't save it, but now I can use the script to add the values.
Thanks! :thumbup:
Check my most scripted scene
Code: Select all
       /^°>#
____.<=/`°`    #<°^==>._____
     ``         ´´  ´´
User avatar
Username?
 
Posts: 65
Joined: Sun Sep 20, 2009 8:06 pm

Re: add values to an objekt

Postby mold999 » Mon Mar 28, 2011 2:41 am

Uh...WHAT DOES ADDING A VALUE TO AN OBJECT EVEN DO?!

Is it different from scene.my.?
Phundementalism?

Ain't nobody got
thyme fo dat.
User avatar
mold999
 
Posts: 225
Joined: Sun Jan 02, 2011 1:35 am
Location: [176436, 3763234]

Re: add values to an objekt

Postby Username? » Mon Mar 28, 2011 7:11 am

When I add a value, save the scene, close algodoo, and reload the scene, the value seems to be away.
Or is the value just not listed in the scrip menü like the IDs?
Check my most scripted scene
Code: Select all
       /^°>#
____.<=/`°`    #<°^==>._____
     ``         ´´  ´´
User avatar
Username?
 
Posts: 65
Joined: Sun Sep 20, 2009 8:06 pm

Re: add values to an objekt

Postby Kilinich » Mon Mar 28, 2011 8:46 am

Username? wrote:When I add a value, save the scene, close algodoo, and reload the scene, the value seems to be away.
Or is the value just not listed in the scrip menü like the IDs?


Custom variables not saving with scene so they can be only run-time.
Workaround is to use "free" variables like controllerAcc, textureMatrix (if there is no texture on geom) etc.
or create scene.my. variables.
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: add values to an objekt

Postby electronicboy » Mon Mar 28, 2011 12:29 pm

as you might have found out, that collider must run the script everytime the scene is reloaded.

if you want, I will look into improving the collider-script later as i already know the method i will use to do it...

or as kilinich says, you could use unused variables such as controllerAcc or scene.my to save the variables.
When asking for help, READ THE STICKIES!
electronicboy
 
Posts: 1694
Joined: Mon Aug 31, 2009 6:18 pm

Re: add values to an objekt

Postby Username? » Mon Mar 28, 2011 2:02 pm

That'll I do :thumbup:
Check my most scripted scene
Code: Select all
       /^°>#
____.<=/`°`    #<°^==>._____
     ``         ´´  ´´
User avatar
Username?
 
Posts: 65
Joined: Sun Sep 20, 2009 8:06 pm

Re: add values to an objekt

Postby electronicboy » Mon Mar 28, 2011 5:27 pm

bad news, my method failed...
the plan was to check if a custom geom.var equaled 1234, and i was hoping that algodoo would see it as false when the scene was loaded, and would run the false IF script which would create all custom variables and would make the IF script true

the only backup method i can think of is time based,

Code: Select all
sim.time < 2 ? {<thyme to create variables>} : {code to run}


That will create the variables you need if the sim-running time is less that 2 and run the script if the sim-running time is over 2, That code would be for the object doing the "thinking".
When asking for help, READ THE STICKIES!
electronicboy
 
Posts: 1694
Joined: Mon Aug 31, 2009 6:18 pm


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 1 guest