Getglobal and setglobal

Game Editor comments and discussion.

Getglobal and setglobal

Postby catacomber » Mon May 12, 2008 3:30 am

Can you use getglobal()

--item in parenthesis would be name of global --

and setglobal() in GE to query the status of a global variable?
User avatar
catacomber
 
Posts: 195
Joined: Fri Sep 28, 2007 5:36 pm
Score: 10 Give a positive score

Re: Getglobal and setglobal

Postby makslane » Mon May 12, 2008 12:38 pm

Just set the value by using the = operator:

Code: Select all
yourvariable = newvalue;
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Re: Getglobal and setglobal

Postby catacomber » Mon May 12, 2008 2:20 pm

Thank you, Makslane. Unless you or someone else tells me otherwise, I'll assume it's the same for

getstate()

and

setstate()

state=1;


?

Or it doesn't work in the same way in GE?
Global variables are enough for me--can do a lot with them but am interested to know about states as well.
Thanks for your help.

: )
User avatar
catacomber
 
Posts: 195
Joined: Fri Sep 28, 2007 5:36 pm
Score: 10 Give a positive score

Re: Getglobal and setglobal

Postby makslane » Mon May 12, 2008 3:33 pm

You don't need create a function to change a variable value.
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Re: Getglobal and setglobal

Postby catacomber » Mon May 12, 2008 8:48 pm

Thank you! One more question and I will leave people in peace for awhile. : )

To display a message in the world, do you have to use a text actor or is there a function that will display a text, f.e.
dislplay a string constant, like Hello World.

printf?

That's my question------how many ways are there

to say

"Hello World" in G.E. ? :D Only one? Using a text actor and colliding or something?

Am making a small 2d rpg game--I've looked at the "rpg style talk" demo but am hoping for a simpler way to "talk".
User avatar
catacomber
 
Posts: 195
Joined: Fri Sep 28, 2007 5:36 pm
Score: 10 Give a positive score

Re: Getglobal and setglobal

Postby makslane » Tue May 13, 2008 12:11 am

You need to use a text actor, and put some code like:

Code: Select all
strcpy(text, "Hello World");
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Re: Getglobal and setglobal

Postby catacomber » Tue May 13, 2008 3:29 am

Thanks, Makslane. :D
User avatar
catacomber
 
Posts: 195
Joined: Fri Sep 28, 2007 5:36 pm
Score: 10 Give a positive score

Re: Getglobal and setglobal

Postby catacomber » Thu May 15, 2008 2:02 am

I'm so excited! Figured out how to make strcopy work!!!!

I made a text actor that said "Silence". The color of Silence is a bright orange so you can really see it.

Then on Collision of my player actor with a pillar, changed "Silence" to say "You need to touch a different pillar"!

Collision Player with Pillar
Script Editor

strcpy(Txt.text,"You need to touch a different pillar");

Txt is the name of the text actor that said "Silence" before.

Well, it's very exciting to me. : ) Now to figure out other things to do with it.

I needed something like this to do a pillar puzzle. : ) ) Of course you don't need text to do a pillar puzzle but it is sometimes nice.
User avatar
catacomber
 
Posts: 195
Joined: Fri Sep 28, 2007 5:36 pm
Score: 10 Give a positive score

Re: Getglobal and setglobal

Postby catacomber » Fri May 16, 2008 3:41 am

I'm further excited---found out that sprintf works the same way as strcpy---just substitute sprintf for strcpy with similar setup as above--on collision with object using same code except substitute sprintf for strcpy----magically my new text appears instead of the old:

sprintf(Txt.text,"You need to touch a different pillar");

So---is there any different use for sprintf as opposed to what strcpy does? Or is the result the same? Is using one more efficient than using the other?
User avatar
catacomber
 
Posts: 195
Joined: Fri Sep 28, 2007 5:36 pm
Score: 10 Give a positive score

Re: Getglobal and setglobal

Postby Fuzzy » Fri May 16, 2008 12:06 pm

sprintf is more versatile.
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Re: Getglobal and setglobal

Postby makslane » Fri May 16, 2008 12:11 pm

sprintf is a C function for make formatted strings.

Read more here:
http://www.elook.org/programming/c/sprintf.html
http://www.elook.org/programming/c/printf.html
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Re: Getglobal and setglobal

Postby catacomber » Fri May 16, 2008 2:50 pm

Thanks, Fuzzy, thanks, Makslane - those were very helpful. Using that code I made my archer collide with a tombstone to test it out--code on collision with tombstone:

char a[20] = "Player";
int age = 21;
sprintf(Display.text,"Hello %s, you are %d years old\n", a, age);

Before the archer collided, my text actor said: "Display".

After Archer collided with the tombstone, my text actor (which was Display before) said: Hello, Player you are 21 years old, as in pic.

Thanks also to Pyrometal for helping me understand this clearly. :D

Now to think of ways to manipulate this. :D You all and GE and this forum are great!
Attachments
Step2.JPG
User avatar
catacomber
 
Posts: 195
Joined: Fri Sep 28, 2007 5:36 pm
Score: 10 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron