|
Re: some confusion with handle()
[Re: Melvin]
#309567
02/10/10 01:26
02/10/10 01:26
|
Joined: Feb 2009
Posts: 2,154
Damocles_
Expert
|
Expert
Joined: Feb 2009
Posts: 2,154
|
C_script first: temp_ptr =ptr_for_handle(minerals[number]) is missing an " ; "
What this actually does is storing a handle of the mineral or whatever is running the action to an array.
Later in the moveG function, a pointer is restored from the array, given an indexnumber.
So the first thing you need to check, is weater the action gets called (meaning, if an entity is beeing "stored" in the array. So watch the minera_index counter, or some other indicator that this part works.
Then check if the move_g function is beeing called, AFTER the array was filled with pointers.
If you dont have a nullpointer error, then some entity is beeing moved (maybe not the mineral you where looking at)
Also the first entry is 0 and not 1 (for 1 you need to have at least two minerals referenced)
Also include some savety features, (like:
if(number>=mineral_index) return; )
Especially when working with dynamically used arrays and pointers.
|
|
|
Re: some confusion with handle()
[Re: Damocles_]
#309572
02/10/10 01:42
02/10/10 01:42
|
Joined: Jan 2007
Posts: 6 Sweden
Melvin
OP
Newbie
|
OP
Newbie
Joined: Jan 2007
Posts: 6
Sweden
|
Okey, in the code i'm not missing the ; - just missed it when I wrote this and I checked the index value and it adds one every time a new green mineral is created. But what I didn't perhaps mention is that i want this to work in C-lite and not C-script as i'm using A7. I tried calling a few of them after I had 9 minerals (index = 9) with moveG(3) and moveG(5) but no dice. But what is a nullpoint error? and how do I know if I got me one of those? thanks for the help
Last edited by Melvin; 02/10/10 01:42.
|
|
|
Re: some confusion with handle()
[Re: Damocles_]
#309574
02/10/10 02:07
02/10/10 02:07
|
Joined: Jan 2007
Posts: 6 Sweden
Melvin
OP
Newbie
|
OP
Newbie
Joined: Jan 2007
Posts: 6
Sweden
|
Okey, well I don't get any trouble from the engine. This is all the code that's involved: (I changed some of the names) //////////////// ENTITY*temp_ptr;
var index = 0; var entitis[100]; ///////////////
action green_crystal_settings () { entitis[index] = handle(me); index += 1;
var temp_rotation = random(2)-1; my.skill32 = 1; // identify as mineral my.skill29 = 1; set(my, POLYGON); my.ambient = 100; my.pan += random(2)-1; my.tilt += random(2)-1; my.scale_x = 0.2; my.scale_y = 0.2; my.scale_z = 0.2; my.emask |= (ENABLE_IMPACT | ENABLE_ENTITY | POLYGON | ENABLE_SCAN); my.event = mineral_hit; while (me) { my.pan += temp_rotation; my.tilt += temp_rotation; wait(1); effect(mineral_green_glow,2,my.x,nullvector); } }
function move_entity(numb) { temp_ptr = ptr_for_handle(entitis[numb]); ent_remove (temp_ptr); }
/////////////////////
After I start it up I wait until I have some minerals and then I press tab and type: move_entity(3) but none of the little buggers get removed.
|
|
|
Re: some confusion with handle()
[Re: Damocles_]
#309576
02/10/10 02:34
02/10/10 02:34
|
Joined: Jan 2007
Posts: 6 Sweden
Melvin
OP
Newbie
|
OP
Newbie
Joined: Jan 2007
Posts: 6
Sweden
|
Capital! It works when I assign it to a key, so I know it works, but still no go when I try to type it in :S any guesses why? Anyhow from now on ill make sure to only try to call my functions from keys when testing I tip my hat at you sir!
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|