Page 1 of 1

textNumber toggling text function ????

PostPosted: Tue May 26, 2015 8:32 pm
by tinkergnome
hello i realize its been a long time since i've been in here ....
i've had a few lifechanging events unfold upon me since late 2013.

i was wondering about how could a textobj.textNumber affect another textobj.text in changing
it to a different word or phrase.

example:
i have this project where i have this 1st text actor that produces a number....
and when a certain number generates this 2nd text actor would produce a specific word.

i realize this example is/should be something really easy to figure out based on as much time i've put into
messing with as much as i have in this program, however, it has seriously aggravated me to being stumped.
can anyone possibly help me with this ?????

Re: textNumber toggling text function ????

PostPosted: Wed May 27, 2015 1:24 am
by koala
Let's say you have two objects, "object1" and "object2".

In "object1" you have a script that executes when [SPACE] key is pressed:
object1 -> Key Down: space -> Script Editor
Code: Select all
textNumber = (int) rand(10) + 1;
This code will write some number between 1 and 10.

In "object2" you want to write word "odd", or "even" depending on a number in "object1". You could do that this way:
object2 -> Draw Actor -> Script Editor
Code: Select all
if ((int) fmod(obect1.textNumber, 2) == 0) sprintf(text, "even");
else sprintf(text, "odd);


I hope this helps.

Re: textNumber toggling text function ????

PostPosted: Thu May 28, 2015 2:42 pm
by tinkergnome
thanks for your help koala it works just fine ... i was hoping i could hear from someone on this.
and again i realized this was something that should have been easy for me to figure out. i thought at one point i almost had a solution, but it kept telling me something about a conversion error.... thanks again koala its much appreciated !

Re: textNumber toggling text function ????

PostPosted: Thu May 28, 2015 3:04 pm
by koala
tinkergnome wrote:thanks for your help koala it works just fine ... i was hoping i could hear from someone on this.
and again i realized this was something that should have been easy for me to figure out. i thought at one point i almost had a solution, but it kept telling me something about a conversion error.... thanks again koala its much appreciated !
No problem! :D I am glad I could help. :D