Bug or bad script.
3 posts • Page 1 of 1
Bug or bad script.
Been experimenting lately with something i call "Object Lifespan"
if controlleracc is
There are two problems with this
1. only works with a single object at one time (any more and it deletes the script from the object spawned first)
2. leaves an error report in the console.
Any ideas what's wrong honestly i'm stumped.
- Code: Select all
density := {2 - ({sim.time >= controlleracc} ? {2} : {0})}
if controlleracc is
- Code: Select all
sim.time + 1
There are two problems with this
1. only works with a single object at one time (any more and it deletes the script from the object spawned first)
2. leaves an error report in the console.
- Code: Select all
14:36:11: -- Warning: Exception thrown: Cannot find identifier "math" in "" from C:\emilk\phun\trunk\Source\script\Expressions.cpp:56: class util::SharedPtr<class script::Object> __thiscall script::Identifier::GetValue(class util::SharedPtr<class script::Reflected>,const class script::Settings &)
14:36:11: -- Warning: Caught exception: Cannot find identifier "math" in "", C:\emilk\phun\trunk\Source\script\Expressions.cpp:132: class util::SharedPtr<class script::Object> __thiscall script::CodeBlock::Evaluate(class util::SharedPtr<class script::Reflected>,const class script::Settings &)
14:36:11: -- Warning: Failed to evaluate: 2 - ({sim.time >= controlleracc} ? {2} : {0}), Cannot find identifier "math" in ""
14:36:11: -- Warning: Exception thrown: Not a real from C:\emilk\phun\trunk\Source\script\ValueConversions.cpp:32: long double __cdecl script::ObjectToValue<long double>(class util::SharedPtr<class script::Object>)
14:36:11: -- Warning: Caught Exception: Not a real, c:\emilk\phun\trunk\source\script\Attributes.hpp:152: void __thiscall script::TAttrib<float>::CalcValueFromObject(void)
14:36:11: -- Warning: density was bound to bad type
Any ideas what's wrong honestly i'm stumped.
-

Mystery - Posts: 2802
- Joined: Thu Sep 03, 2009 1:16 pm
- Location: Southern Australia
Re: Bug or bad script.
Very helpful link
Another interesting link
You have to do it this way:
(scene.add*()).density = { }
For example when spawning a circle (can be done with everything else, too):
And btw. you can't mix integer or float values with boolean values. That's why the "math" error in the console appears. So only make the math in if statements in the THEN or ELSE part. But for your example you don't need to substract anything.
Another interesting link
You have to do it this way:
(scene.add*()).density = { }
For example when spawning a circle (can be done with everything else, too):
- Code: Select all
( scene.addcircle({ pos := [0, 0]; radius := 0.5}) ).density = { sim.time >= controlleracc ? {0} : {2} }
And btw. you can't mix integer or float values with boolean values. That's why the "math" error in the console appears. So only make the math in if statements in the THEN or ELSE part. But for your example you don't need to substract anything.

-

KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: Bug or bad script.
The other thing is that the controllerAcc value will not be from the spwned object, but from the spawner itself. i made something like this but it didn't work because of that, as you can see in the links.
-

Versieon - Posts: 375
- Joined: Tue Sep 01, 2009 4:45 pm
3 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest



