Page 1 of 2

About symbols...

PostPosted: Sat Mar 08, 2008 8:42 pm
by Wayra Condor
Something I don't understand is what means if on scripting I put some symbols than turns green (sometimes even text), like =, !, * and I don't know how many but... can somoene tell me whats their funcion?, because is very wreid sometimes:

Ej: If I put this: = is equal, but is I put this == is another thing!

Please someone put a tutorial of those funcions. :mrgreen:

Re: About symbols...

PostPosted: Sat Mar 08, 2008 9:39 pm
by edh
Here is the meaning of some of the symbols,
= this is assignment
== this is test for equality
!= this is test for inequality
>= this is test for greater or equal
<= this is test for lesser or equal



some examples:
assignment

Code: Select all
int a;
a = 1;


equality
Code: Select all
int a;
int b;
a = 1;
b = a;

if (a == b)
{
   // they are equal!
}
else
{
   // they are not equal!
}



:!: Note: you can get a logical error by writing code like this:
Code: Select all
int a;
int b;

a = 1;
b = 2;

if (a = b)
{
  // oops, now a == b
  // a = 1 and b = 1, too
  // because we performed assignment, not test for equality
  // this is probably not what we wanted to happen
}


test for inequality
Code: Select all
int a;
int b;
a = 1;
b = 2;

if (a != b)
{
   // they are not equal!
}
else
{
   // they are equal!
}


:?: (BTW, Wayra, did you get your text effect to work?)

Re: About symbols...

PostPosted: Sun Mar 09, 2008 12:32 am
by edh
You may also want to know about these...

&& means logical "and"
|| means logical "or "

For example
Code: Select all
int a;
int b;

a = 1;
b = a;

if (a == 1 && b == 1)
{
  // then a and be are both equal to 1
}
else if (a == 1 || b == 1)
{
  // either a or b is equal to 1, not sure which one
}


Re: About symbols...

PostPosted: Tue Mar 11, 2008 11:00 pm
by Wayra Condor
Well, thanks for the explanation, but... What means "int"?
The reason I make this post is bacause I got a problem with my text, the effect is perfect, execpt in one detail, what I tried to do is that onece I press some button the second text poped up, with the same button again, appear a third text, and if it was pressed again it returned to the first text.
The effect is perfect, thanks for asking, but to make the complete effect I tried to use variables and I got screwed up with that, so what should I do?

Code: Select all
if (varaible1==1)
{ strcpy(sing1.text, "first text");//change text effect
strcpy(sing2, "first text");
variable1=2;//the variable that I try to make change in order to alternate texts
}

if (varaible1==2)
{ strcpy(sing1, "second text");
strcpy(sing2, "second text");
varaible1=1;
}

yvelocity=-10;//draw actor effect


The funny about all these is that if I change the numbers, I can make the text alternate once or twice, no more; thats why I think that the symbols are wrong.
Well, anyway thanks for help. :mrgreen:

Re: About symbols...

PostPosted: Wed Mar 12, 2008 1:09 am
by pyrometal
The reason this is happening is because you are using two distinct "if" structures in your code. When your code executes, the first if is executed, but shifts the value of varaible1 to 2. Your Second piece of code can then be executed because the condition is true, so it switches your text right away to the "second text". You must use "else if" for your second block in order to avoid this problem, which will only execute if no other conditions preceding it have been fulfilled.

Code: Select all
if (varaible1==1)
{ strcpy(sing1.text, "first text");//change text effect
strcpy(sing2, "first text");
variable1=2;//the variable that I try to make change in order to alternate texts
}

else if (varaible1==2)
{ strcpy(sing1, "second text");
strcpy(sing2, "second text");
varaible1=1;
}

yvelocity=-10;//draw actor effect

Re: About symbols...

PostPosted: Wed Mar 12, 2008 7:16 am
by Bee-Ant
I think this is the correct structure to change text of text actor :
Code: Select all
strcpy(MyActor.text,"your text here");

Re: About symbols...

PostPosted: Wed Mar 12, 2008 9:22 pm
by Wayra Condor
And what about making a larger secuence? i tried to make a 5 secuence (again with the texts...) but the last "else if" in certain way "ate" the ones "else if" before it, maybe it could be better if someone makes a complete tutorial about function that don't apear on the function bar (those that appear in green or blue)

Re: About symbols...

PostPosted: Thu Mar 13, 2008 12:15 am
by edh
I found that the Out of Vision event occurs more than once while the text actor is offscreen.

I created an out of vision flag (oov) and added a switch statement to show more than one text value.

I also use modulo (%) to make the count variables value between 0 and 5 only.

edh-changetext2.zip
multiple off screen text changes
(80.73 KiB) Downloaded 105 times

Re: About symbols...

PostPosted: Thu Mar 13, 2008 3:21 am
by Wayra Condor
Yea!! it works!!!
But the bad thing is that there is a glitch... if you press the action button before the text change it disapear! (On the tutorial happens the same, why?)

Re: About symbols...

PostPosted: Thu Mar 13, 2008 10:46 am
by edh
I don't know what you mean. I can't do anything to the changetext demo to make it behave the way you describe. Does the changetext demo work? It is only in your program that it is not correct?

Could you post a small example program for us to see?

Re: About symbols...

PostPosted: Thu Mar 13, 2008 10:16 pm
by Wayra Condor
Well, this is your tutorial with another text that explains the glitch:
change text glitch.zip.zip
(83.29 KiB) Downloaded 98 times


What I don't understand is if there is another way for do this, with the variables I make it easly, the problem is that the limit is this:

if(variable=0)
{-code here-}

else if(variable=1)
{-another code here-}

and nothing else (I think), so if you now how to continue this, please put a list.
BTW, sorry for make so much problem with this simple thing edh :mrgreen:

Re: About symbols...

PostPosted: Fri Mar 14, 2008 3:03 am
by edh
OK, I see.

What I did was create a new global integer called "canclick"

In the actor create, I initialize it to 1 (we can click the text).
In the out of vision event, I set canclick = 0 (we can not click the text).
in the draw actor, when the y position = 0, I reset canclick to 1 again (we can click the text).

Here is the working script:
edh-changetext-fixed.zip
fixed click/disappear glitch
(80.81 KiB) Downloaded 102 times


Sorry about that; I didn't notice it before.

Re: About symbols...

PostPosted: Fri Mar 14, 2008 9:11 pm
by Wayra Condor
Yup, now it works propetly! but anyone knows the secuense that I listed?
if (-something-)
else if (-other thing-)
and... :?:

Re: About symbols...

PostPosted: Sat Mar 15, 2008 9:36 am
by edh
Are you trying to do this without using events? Like in one Draw Actor script?

Re: About symbols...

PostPosted: Sat Mar 15, 2008 4:49 pm
by Wayra Condor
Maybe I'll need to explain the complete proyect... I'm making a figthing game based on the mortal kombat system (with martial arts), so the text is for this, the text is only an indicator of the martial art that is being used, so it changes by pressing a key, but at the same time the text changes the character with you are playing changes its sprites an functions; if I do this with a "count" system, the character won't change, only the text, thats why I'm trying to use a global variable.