|
|
Problem with parameters when calling a function
#257975
03/26/09 22:43
03/26/09 22:43
|
Joined: Jan 2005
Posts: 605 Deutschland, NRW
garv3
OP
User
|
OP
User
Joined: Jan 2005
Posts: 605
Deutschland, NRW
|
Hi all! I have got some code including something like this: #define boden 1
function gegner_anvisieren(var luft_oder_boden){
...
}
gegner_anvisieren(boden);When this code is run, I get an error saying "Call function gegner_anvisieren ERROR". So what's wrong? Thx!!! derGarv
GameStudio Version: A7 Pro v7.86
|
|
|
Re: Problem with parameters when calling a function
[Re: garv3]
#257977
03/26/09 23:04
03/26/09 23:04
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Nothing wrong there. Maybe post the whole of gegner_anvisieren?
Or check other lines in code where gegner_anvisieren is called from(if any).
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Problem with parameters when calling a function
[Re: EvilSOB]
#257979
03/26/09 23:09
03/26/09 23:09
|
Joined: Jan 2005
Posts: 605 Deutschland, NRW
garv3
OP
User
|
OP
User
Joined: Jan 2005
Posts: 605
Deutschland, NRW
|
Well, the compiler gives me the line and I checked all later lines where the function is called. Here it is: function gegner_anvisieren(var luft_oder_boden){
VECTOR temp;
ENTITY* mein_anvisier_ziel_ptr;
var mein_anvisier_ziel[3];
while(me){
if(my.einheiten_anvisierter_gegner != NULL){
if (ptr_for_handle(my.einheiten_anvisierter_gegner) != NULL && mein_anvisier_ziel_ptr != ptr_for_handle(my.einheiten_anvisierter_gegner)){
mein_anvisier_ziel_ptr = ptr_for_handle(my.einheiten_anvisierter_gegner);
if(mein_anvisier_ziel_ptr.gegner_luft_oder_boden != luft_oder_boden)
mein_anvisier_ziel_ptr = NULL;
}
if(mein_anvisier_ziel_ptr != NULL){
vec_set(temp, vector(mein_anvisier_ziel_ptr.x,mein_anvisier_ziel_ptr.y,mein_anvisier_ziel_ptr.z+mein_anvisier_ziel_ptr.gegner_hoehe/2));
vec_sub(temp, vector(my.x,my.y,my.z+my.einheiten_hoehe));
effect_local(anvisier_effekt, 1, vector(my.einheiten_anvisierlaser_start_x,my.einheiten_anvisierlaser_start_y,my.einheiten_anvisierlaser_start_z), temp);
}
if (ptr_for_handle(my.einheiten_anvisierter_gegner) == NULL){
my.einheiten_anvisierter_gegner = NULL;
mein_anvisier_ziel_ptr = NULL;
}
}else{
mein_anvisier_ziel_ptr = NULL;
}
wait(1);
}
}If I just remove the "boden" var and replace it by a static value, everything works fine!
GameStudio Version: A7 Pro v7.86
|
|
|
Re: Problem with parameters when calling a function
[Re: Espér]
#257986
03/26/09 23:30
03/26/09 23:30
|
Joined: Jan 2005
Posts: 605 Deutschland, NRW
garv3
OP
User
|
OP
User
Joined: Jan 2005
Posts: 605
Deutschland, NRW
|
Bringt leider nichts. Selbst, wenn ich die variable in "myvar" umbenenne, ändert sich nichts!
GameStudio Version: A7 Pro v7.86
|
|
|
Re: Problem with parameters when calling a function
[Re: garv3]
#257987
03/26/09 23:37
03/26/09 23:37
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Compiles and runs fine (once I had created the entity.skill defines).
What is the ACTUAL "#define boden ..." line you are using? (copy and paste into post by preference)
And can you also post all the real #define's that are used by this function? einheiten_anvisierter_gegner gegner_luft_oder_boden gegner_hoehe einheiten_hoehe einheiten_anvisierlaser_start_x einheiten_anvisierlaser_start_y einheiten_anvisierlaser_start_z
Thanks
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Problem with parameters when calling a function
[Re: EvilSOB]
#257988
03/26/09 23:44
03/26/09 23:44
|
Joined: Jan 2005
Posts: 605 Deutschland, NRW
garv3
OP
User
|
OP
User
Joined: Jan 2005
Posts: 605
Deutschland, NRW
|
Here you go:
#define boden 1 #define einheiten_anvisierter_gegner skill22 #define gegner_luft_oder_boden skill10 #define gegner_hoehe skill4 #define einheiten_hoehe skill5 #define einheiten_anvisierlaser_start_x skill23 #define einheiten_anvisierlaser_start_y skill24 #define einheiten_anvisierlaser_start_z skill25
If I remove "boden" from the function call, and "var luft_oder_boden" from its definition and replace "luft_oder_boden" in the function by a static value, it runs fine!
GameStudio Version: A7 Pro v7.86
|
|
|
Re: Problem with parameters when calling a function
[Re: garv3]
#257993
03/27/09 01:09
03/27/09 01:09
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Compiles and runs no problem.
Whether is WORKS I dont know, because of the german-english language barrier I have with your define names, and that my anvisier_effekt function does nothing.
But if I give it an entity to chew on, and get the entity's action to call gegner_anvisieren(boden); (so it has a MY pointer to play with), it executes without errors.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Problem with parameters when calling a function
[Re: EvilSOB]
#258001
03/27/09 04:26
03/27/09 04:26
|
Joined: Mar 2009
Posts: 112 Germany
KDuke
Member
|
Member
Joined: Mar 2009
Posts: 112
Germany
|
Hi garv3,
did you already try to locate where the error is thrown out? Theorethically you should be able to narrow it down to a single line of code.
Furthermore you have a function there and yet you use "me" and "my" which is supposed to be used in actions. Maybe this is the problem? Though could be i'm totally wrong on that, haven't worked with "me" and "my" yet.
greetings K-Duke
Using A7 Free Click and join the 3dgs irc community! Room: #3dgs
|
|
|
Re: Problem with parameters when calling a function
[Re: KDuke]
#258009
03/27/09 06:27
03/27/09 06:27
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
You're almost right KDuke. This function doesnt have it own ME/MY pointer, which is naughty, but not critical. It will inherit ME/MY from its parent (ie calling function). So long as the function calling this has a valid ME/MY, then the ME/MY of this function will be the same(valid) too.
NOTE: I tested this function with both ME/MY being valid and NULL. Neither gave a compile or runtime error.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
|