setting string vars in Create Actor evet not working

Non-platform specific questions.

setting string vars in Create Actor evet not working

Postby fauldran » Wed Jan 04, 2006 7:48 am

I have several string variables defined as actor variables. I am trying to use the Create Actor event to give these vars default values for an actor. The vars are then used in the Draw Actor event.

The problem is that the variables are empty when the Draw Actor code executes.

Using the same method with integers works fine though. Is this a bug with strings or am I missing something?
fauldran
 
Posts: 43
Joined: Tue Dec 20, 2005 10:52 am
Score: 0 Give a positive score

Postby makslane » Wed Jan 04, 2006 12:16 pm

Can you post the code used to initialize the strings?
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

The Details...

Postby fauldran » Wed Jan 04, 2006 7:42 pm

I have several string variables (anim_move_N, ..E, ...W, etc...) that were created through the Variables dialogue as actor variables.

The intent is to use these to store the names of animations to be used when the actor is moving in a given direction.

on our character AI_ghost:
--Create Actor--
//the first two are integers and are working fine
moving = 0;
dir = 0;

//then we have the strings that are not working
anim_move_N = "ghost_move_N";
anim_move_NE = "ghost_move_NE";
anim_move_E = "ghost_move_E";
anim_move_SE = "ghost_move_SE";
anim_move_S = "ghost_move_S";
anim_move_SW = "ghost_move_SW";
anim_move_W = "ghost_move_W";
anim_move_NW = "ghost_move_NW";

--Draw Actor--
//I have a switch on dir that determines an animation to use. In each case is the following:

if(animindex != getAnimIndex(anim_move_N))
{
ChangeAnimation("Event Actor", anim_move_N, FORWARD);
}

The problem is that when Draw Actor executes anim_move_N (or whichever relative animation var) is empty.

---------------Work Around------------------
I am able to get around this by placing the strings in the Draw Actor script. However as I understand it this will slow execution because it would be reassigning these values every frame right?

--Draw Actor--
anim_move_N = "ghost_move_N";
anim_move_NE = "ghost_move_NE";
anim_move_E = "ghost_move_E";
anim_move_SE = "ghost_move_SE";
anim_move_S = "ghost_move_S";
anim_move_SW = "ghost_move_SW";
anim_move_W = "ghost_move_W";
anim_move_NW = "ghost_move_NW";

//with the switch following.


I would be happy to send you the game files if you would like. Thanks for the help.
fauldran
 
Posts: 43
Joined: Tue Dec 20, 2005 10:52 am
Score: 0 Give a positive score

Postby makslane » Thu Jan 05, 2006 12:23 pm

With strings you need to use the strcpy function:

strcpy(anim_move_N, "ghost_move_N");
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

Postby fauldran » Thu Jan 05, 2006 5:52 pm

Ahhh, I have to get used to using the strcpy. Did not even think to try that in this case. Works great now. Thanks!
fauldran
 
Posts: 43
Joined: Tue Dec 20, 2005 10:52 am
Score: 0 Give a positive score

Postby plinydogg » Fri Jan 06, 2006 6:13 pm

I was accidentally using textNumber instead of strcpy and so am just learning about strcpy. My question is: when I use strcpy I get a warning saying "suspicious pointer conversion." Do I need to be worried about this?

Thanks.
plinydogg
 
Posts: 104
Joined: Thu Aug 25, 2005 8:34 pm
Score: 0 Give a positive score

Postby plinydogg » Fri Jan 06, 2006 6:33 pm

I guess I do need to worry about it since I get access violations whenever that code executes.

To make a long story short, here's what I'm trying to do:

(1) When game starts, load global high score variables (name, level, and score) using LoadVars (this part works fine);
(2) If the player has a score greater than the lowest high score, the view moves to a screen that allows the person to input his/her name (this part also works fine);
(3) When the person clicks on the word "Enter," scores are reassigned (e.g., if player's score > 5th high score but < than 4th high score, player's score is assigned to the global highScoreFive variable, etc.);
(4) Finally, the altered high scores should be assigned to the actors that display them. I initially tried using something like

highScore01Name.textNumber = Score01Name;

That didn't work.

Then I tried

strcpy(highScore01Name.text, Score01Name);

which created the access violations.

Does anyone have any advice?

Thanks again!
plinydogg
 
Posts: 104
Joined: Thu Aug 25, 2005 8:34 pm
Score: 0 Give a positive score

Postby makslane » Fri Jan 06, 2006 7:25 pm

Score01Name must be a string, not a integer
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

Postby plinydogg » Fri Jan 06, 2006 8:01 pm

I'm an idiot :( Thanks for your patience!
plinydogg
 
Posts: 104
Joined: Thu Aug 25, 2005 8:34 pm
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron