A problem with ptr_for_handle

Posted By: oldschoolj

A problem with ptr_for_handle - 09/20/07 23:23

Hi folks,

I'm wondering why this doesnt work, any help would be much appreciated.

First, I've made a panel entity, and created where I need it:

Code:
PANEL* item_icon_0000;
item_icon_0000 = pan_create ("bmap = ui_itembmap_0000; flags = VISIBLE;", 2);
item_icon_0000.pos_x = ui_inv_panel.pos_x + ui_inv_posx_array[0];
item_icon_0000.pos_y = ui_inv_panel.pos_y + ui_inv_posy_array[0];



Next, I've defined a handle for the panel, and store it in an array:

Code:
ui_inv_slot_array[0] = handle(item_icon_0000);



Now I make a pointer to call it up like this:
Code:
if (mouse_item_location == 0) 
{
you = ptr_for_handle (ui_inv_slot_array[0]);
while (mouse_left == 1)
{
you.pos_x = mouse_pos.x;
you.pos_y = mouse_pos.y;
wait (1);
}
you.pos_x = ui_inv_panel.pos_x + ui_inv_posx_array[0];
you.pos_y = ui_inv_panel.pos_y + ui_inv_posy_array[0];
ui_inv_slot_array[0] = handle (you);
mouse_item=0;
}



Now, I get an error "pos_x is not a member of entity".
This is what I have noticed, the code is almost right, because If I remove pos_x, and pos_y, and replace it with just x, and y, the panel moves around fine, and is stored fine afterwards, because I can do as much moving around as I need.

But the problem is, that with just x, and y (instead of pos_x, and pos_y) it doesnt move properly, things are all out of order...

Why does it work with .x, and .y, and not work with pos_x and pos_y?
Does anyone know what I am doing wrong?

Thanks for the help,


Posted By: oldschoolj

Re: A problem with ptr_for_handle - 09/21/07 02:17

I actually solved the problem, heh. Apparently I needed to make a PANEL* entity, like PANEL* temp_panel, and assign that instead of you. So if there is anyone else who has had this problem, I guess the reason why I was getting the "not a member of entity" is because pos_x, or pos_y had to be a member of a panel entity. cool
© 2023 lite-C Forums