Page 1 of 1

string loses value between create actor and draw actor

PostPosted: Thu Jan 24, 2008 6:01 pm
by yttermayn
Is this a bug with the version I'm using, or am I doing something wrong?

When the game is run, an actor is created when a certain event happens.

1) I make a string variable with the scope of actor instead of global. Lets call it "boogers". I've made two text actors to show text for debugging purposes, named "debugtext" and "debugtext2". The default text for these actors is "| ".
2) In create actor script, I initialize it with the string "lalalalala":
boogers = "lalalalala";
3) To double check things, I go ahead and display the contents of "boogers" in a text actor, still in create actor script:
strcpy(debugtext.text, boogers);
4) Now in the draw actor script, I have the same line as in 3), with the exception that boogers is now going to a second text actor:
strcpy(debugtext2.text, boogers);
When the game is run, both text actors show the default "| ". When the actor is created, "lalalalala" shows up on the text actor "debugtext", so I know that "boogers" does in fact contain the correct string. However on the text actor "debugtext2", the output is null, or spaces, or something else that dosn't show up at all - the default message has dissapeared.
I should note that there is no other code that touches these variables in my scripts.

What is going on?

Re: string loses value between create actor and draw actor

PostPosted: Thu Jan 24, 2008 6:59 pm
by makslane
This behavior works in the 1.3.9 version.
Please, post a little game with the codes, so I will can see whats happen.

Re: string loses value between create actor and draw actor

PostPosted: Thu Jan 24, 2008 10:21 pm
by yttermayn
I slapped this together using 1.3.9 demo to see if it was a bug that's been fixed since 1.3.5. It still exhibits the same behavior.

Re: string loses value between create actor and draw actor

PostPosted: Thu Jan 24, 2008 10:34 pm
by Freddy
Ive noticed before a bug similar to yours.
In the create actor event I went to script editor and typed:
(somevariable) = 1;
Then I made some events and actions for when the variable equaled one. I pressed game mode and noticed that nothing happened that should of happened when the variable was equal to one. I then made a text actor that showed the value of the variable, and when I pressed game mode it was a completely random number somewhere in the thousands. I tried it again, and it was another random number. It was pretty annoying, but I got around it. :D

P.S. You might want to post that demo as a ged file.

Re: string loses value between create actor and draw actor

PostPosted: Thu Jan 24, 2008 11:11 pm
by makslane
In the foo -> Create Actor event:

Use:
Code: Select all
strcpy(booger, "lalalalala");


To copy the text (not boogers = "lalalalala")

And you must create the foo actor in some place or change the option "Create at startup" to yes

Re: string loses value between create actor and draw actor

PostPosted: Fri Jan 25, 2008 3:49 am
by yttermayn
Ok, that works! Also, the foo actor does get created when you press the spacebar. It's a keydown event in the view actor.