textNumber toggling text function ????

Questions, comments and discussion about the Game Editor development.

textNumber toggling text function ????

Postby tinkergnome » Tue May 26, 2015 8:32 pm

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 ?????
User avatar
tinkergnome
 
Posts: 16
Joined: Wed Oct 12, 2011 5:11 pm
Score: 1 Give a positive score

Re: textNumber toggling text function ????

Postby koala » Wed May 27, 2015 1:24 am

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.
Phascolarctos cinereus
YouTube: Marko Radivojevic
Google+: Marko Radivojevic
User avatar
koala
 
Posts: 301
Joined: Thu Mar 26, 2015 7:03 pm
Location: Serbia
Score: 30 Give a positive score

Re: textNumber toggling text function ????

Postby tinkergnome » Thu May 28, 2015 2:42 pm

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 !
User avatar
tinkergnome
 
Posts: 16
Joined: Wed Oct 12, 2011 5:11 pm
Score: 1 Give a positive score

Re: textNumber toggling text function ????

Postby koala » Thu May 28, 2015 3:04 pm

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
Phascolarctos cinereus
YouTube: Marko Radivojevic
Google+: Marko Radivojevic
User avatar
koala
 
Posts: 301
Joined: Thu Mar 26, 2015 7:03 pm
Location: Serbia
Score: 30 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron