Spawn variable box text Question!
10 posts • Page 1 of 1
Spawn variable box text Question!
I'm trying to spawn a box that comes with an auto-updating box text. (using the {} brackets)
The problem is that when I use the following code:
The boxes come out with the static value of scene.my.num1 at the time of creation instead of the desired
Because Algodoo evaluates {math.toString(scene.my.num1)} before spawning the object.
Is there any way to fix this?
The problem is that when I use the following code:
- Code: Select all
Scene.addBox({text := {math.toString(scene.my.num1)}});
The boxes come out with the static value of scene.my.num1 at the time of creation instead of the desired
- Code: Select all
{math.toString(scene.my.num1)}
Because Algodoo evaluates {math.toString(scene.my.num1)} before spawning the object.
Is there any way to fix this?
Human horse pasture expansion OpenGL Book Hall
Kwon owned Version (C) 2002-2008
-
guyboy - Posts: 80
- Joined: Mon Aug 31, 2009 6:19 pm
- Location: Ḻ̘̬͕͍͚̥͈͚͖̝̜̲͕̭̩ͅ
Re: Spawn variable box text Question!
Create scene.my.num1 (scene.my.num := whatever)after or at the same time the box is spawned.
-
Mystery - Posts: 2802
- Joined: Thu Sep 03, 2009 1:16 pm
- Location: Southern Australia
Re: Spawn variable box text Question!
guyboy wrote:I'm trying to spawn a box that comes with an auto-updating box text. (using the {} brackets)
The problem is that when I use the following code:
- Code: Select all
Scene.addBox({text := {math.toString(scene.my.num1)}});
The boxes come out with the static value of scene.my.num1 at the time of creation instead of the desired
- Code: Select all
{math.toString(scene.my.num1)}
Because Algodoo evaluates {math.toString(scene.my.num1)} before spawning the object.
Is there any way to fix this?
Search "dynamic" in thyme topic
(scene.addbox({})).text = {""+scent.my.text}
Dream of Algodoo as game development engine...
-
Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Spawn variable box text Question!
That's awesome Kilinich, thanks!
But there still is something wrong
This works:
But this doesn't:
whaa??
But there still is something wrong
This works:
- Code: Select all
(e)=>{ (Scene.addBox({})).text = {math.toString(scene.my.num1)} }
But this doesn't:
- Code: Select all
(e)=>{ (scene.my.generate1 > 0) ? { (Scene.addBox({})).text = {math.toString(scene.my.num1)}; scene.my.generate1 = scene.my.generate1 - 1 } : {} }
whaa??
Last edited by guyboy on Sun Feb 07, 2010 3:25 pm, edited 1 time in total.
Human horse pasture expansion OpenGL Book Hall
Kwon owned Version (C) 2002-2008
-
guyboy - Posts: 80
- Joined: Mon Aug 31, 2009 6:19 pm
- Location: Ḻ̘̬͕͍͚̥͈͚͖̝̜̲͕̭̩ͅ
Re: Spawn variable box text Question!
guyboy wrote:That's awesome Kilinich, thanks!
But there still is something wrong
Like what?
Dream of Algodoo as game development engine...
-
Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Spawn variable box text Question!
Kilinich wrote:guyboy wrote:That's awesome Kilinich, thanks!
But there still is something wrong
Like what?
Like what I edited above.
Human horse pasture expansion OpenGL Book Hall
Kwon owned Version (C) 2002-2008
-
guyboy - Posts: 80
- Joined: Mon Aug 31, 2009 6:19 pm
- Location: Ḻ̘̬͕͍͚̥͈͚͖̝̜̲͕̭̩ͅ
Re: Spawn variable box text Question!
guyboy wrote:Like what I edited above.
What errors/warnings you got in console?
Dream of Algodoo as game development engine...
-
Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Spawn variable box text Question!
Kilinich wrote:guyboy wrote:Like what I edited above.
What errors/warnings you got in console?
With the first code, nothing, with the second code:
console wrote:
- Code: Select all
19:33:42: -- Warning: Exception thrown: Cannot find identifier "math" in "" from /home/linde/work/phun32/Source/script/Expressions.cpp:56: script::ObjectPtr script::Identifier::GetValue(script::ReflectedPtr, const script::Settings&)
19:33:42: -- Warning: Caught exception: Cannot find identifier "math" in "", /home/linde/work/phun32/Source/script/Expressions.cpp:132: virtual script::ObjectPtr script::CodeBlock::Evaluate(script::ReflectedPtr, const script::Settings&)
19:33:42: -- Warning: Failed to evaluate: math.toString(scene.my.num1), Cannot find identifier "math" in ""
19:33:42: -- Warning: Exception thrown: Not a string from /home/linde/work/phun32/Source/script/ValueConversions.cpp:77: T script::ObjectToValue(script::ObjectPtr) [with T = util::String]
19:33:42: -- Warning: Caught Exception: Not a string, /home/linde/work/phun32/Source/script/Attributes.hpp:152: void script::TAttrib<T>::CalcValueFromObject() [with T = std::basic_string<char, std::char_traits<char>, std::allocator<char> >]
19:33:42: -- Warning: text was bound to bad type
Human horse pasture expansion OpenGL Book Hall
Kwon owned Version (C) 2002-2008
-
guyboy - Posts: 80
- Joined: Mon Aug 31, 2009 6:19 pm
- Location: Ḻ̘̬͕͍͚̥͈͚͖̝̜̲͕̭̩ͅ
Re: Spawn variable box text Question!
guyboy wrote:That's awesome Kilinich, thanks!
But there still is something wrong
This works:
- Code: Select all
(e)=>{ (Scene.addBox({})).text = {math.toString(scene.my.num1)} }
But this doesn't:
- Code: Select all
(e)=>{ (scene.my.generate1 > 0) ? { (Scene.addBox({})).text = {math.toString(scene.my.num1)}; scene.my.generate1 = scene.my.generate1 - 1 } : {} }
whaa??
I've got it - you need to move code into scene.my. procedure for use it in if-then-else.
Dream of Algodoo as game development engine...
-
Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Spawn variable box text Question!
Kilinich wrote:guyboy wrote:That's awesome Kilinich, thanks!
But there still is something wrong
This works:
- Code: Select all
(e)=>{ (Scene.addBox({})).text = {math.toString(scene.my.num1)} }
But this doesn't:
- Code: Select all
(e)=>{ (scene.my.generate1 > 0) ? { (Scene.addBox({})).text = {math.toString(scene.my.num1)}; scene.my.generate1 = scene.my.generate1 - 1 } : {} }
whaa??
I've got it - you need to move code into scene.my. procedure for use it in if-then-else.
Could you please enlighten me on how this is done?
Thank you.
Human horse pasture expansion OpenGL Book Hall
Kwon owned Version (C) 2002-2008
-
guyboy - Posts: 80
- Joined: Mon Aug 31, 2009 6:19 pm
- Location: Ḻ̘̬͕͍͚̥͈͚͖̝̜̲͕̭̩ͅ
10 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 8 guests