Value vs. Reference problem

Yossarian

First time out of the vault
I'm trying to get a critter to move in two parts, so I made a list of
anims, but Im having a problem. The second part will use the last hex of the first part as its starting point, so I did this (I know its missing the "/", I took them out to make the post nicer).
Code:
#define nice_move(obj)   if(tile_num(obj)<Dest1) then begin                     
THSteps:=(Dest1-tile_num(obj))/200;                     reg_anim_begin();  reg_anim_obj_run_to_tile(obj,tile_num_in_direction(tile_num(obj),2,THSteps),-1);                                   
reg_anim_obj_run_to_tile(obj,tile_num(obj)+400,-1);                         
reg_anim_end();   
end
The script compiles and runs fine, but I think "obj" is being passed by value, so the tile_num(obj) in the second anim is returning where the obj was standing when it was passed, not where its standing now. If that's the problem, how can I pass "obj" by reference or a pointer? If not, can someone tell me what the problem is?
Thanks a lot for your help.
 
Err... Yossarian, I couldn't actually understand what your problem is...
Are you asking for scripting theory clarification, or actually you have a problem with your script? If so, please also post the other procedures involved in the moving process.
See you.
 
Well I made some changes and got the script to work, but my problem was that I wanted the critter to move to a hex (say hex1) and then move to hex1+400. However, in the second anim (reg_anim_obj_run_to_tile(obj,tile_num(obj)+400,-1);
the tile_num(obj) was not returning hex1, it was returning where the critter was standing when obj was passed to the macro (before the first anim).
Now what I think is going on is that since no anim start before reg_anim_end is called, when I call the second anim the critter is still standing at the same place he was standing when the macro was called. So I had to send in extra variables to the macro to record where I wanted him to go first, and then add 400 to that in the second anim.
Thanks for your help.
 
Now what I think is going on is that since no anim start before reg_anim_end is called, when I call the second anim the critter is still standing at the same place he was standing when the macro was called. So I had to send in extra variables to the macro to record where I wanted him to go first, and then add 400 to that in the second anim.

Yup that's right from all animations in reg_anim block are fired in same time when reg_anim_end is reached.



The script compiles and runs fine, but I think "obj" is being passed by value, so the tile_num(obj) in the second anim is returning where the obj was standing when it was passed, not where its standing now.

Nope obj is a pointer to an internal object, in fallout scripts you don't have to worry about such things ;).
 
jargo said:
Yup that's right from all animations in reg_anim block are fired in same time when reg_anim_end is reached.
Yeah that's what I thought. The mapper document should probably have mentioned it. :x
Nope obj is a pointer to an internal object, in fallout scripts you don't have to worry about such things Wink.
Well that's good to know.

Thanks a lot for your help.
 
Back
Top