Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by M_D. 04/26/24 20:22
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 839 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
pointer to a panel not working.... #450678
04/20/15 15:46
04/20/15 15:46
Joined: Aug 2005
Posts: 199
houston
S
seneca Offline OP
Member
seneca  Offline OP
Member
S

Joined: Aug 2005
Posts: 199
houston
I have searched, but what I found doesn't seem to work.
all i'm trying to do is access a pointer to a non moving panel created in a for loop.

*******************************************
for(i=0;i<buffercount;i++)
{
if(mytile[i].ktype == 1)
{
//w = i;
water_pan[i] = pan_create("bmap = water.png;", mytile[i].levela);

water_pan[i].pos_x = mytile[i].posxa;
water_pan[i].pos_y = mytile[i].posya;
set(water_pan[i], SHOW);
//w_collisions(water_pan[i],i);
panel_me(i);
//test_show(*myVar);
}
/*
else
{
//w = i;
stone_pan[i] = pan_create("bmap = stone.png;", mytile[i].levela);
stone_pan[i].pos_x = mytile[i].posxa;
stone_pan[i].pos_y = mytile[i].posya;
set(stone_pan[i], SHOW);
}
*/
}
***************************************************
sorry, I can't find the code tags. and I am using a struct, because I thought that the pointer is having a hard time being placed in the while loop.

the error I get is the E1513, everytime, no matter how I phrase it.

below is only 1 of 30 different ways I've tried to access the pointer.

********************************************************
function get_pan(p)
{
var g = p+1;
PANEL* temp_pan_new[100];
temp_pan_new[g] = p;


/*
while (1)
{

if(!play_pan){beep();}
temp_nopposx = g;
if(temp_pan_new[g].pos_x <= player_pan.pos_x)
{
temp_var += .001;
}

wait (1);
}// end while 1
*/
}
****************************************************

I've got other projects where it works fine, but this one...?
I just don't get it.

thanks.


a8 commercial
Re: pointer to a panel not working.... [Re: seneca] #450681
04/20/15 16:47
04/20/15 16:47

M
Malice
Unregistered
Malice
Unregistered
M



I got a little lost but two ideas, WAIT(1) after the creation before accessing the panel. Also remember the 0 math so 99 is the last element in the array and 0 the first, do not exceed 99(in your example)

Last edited by Malice; 04/20/15 16:47.
Re: pointer to a panel not working.... [Re: seneca] #450683
04/20/15 17:53
04/20/15 17:53
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Originally Posted By: seneca

for(i=0;i<buffercount;i++)
{
if(mytile[i].ktype == 1)
{
//w = i;
water_pan[i] = pan_create("bmap = water.png;", mytile[i].levela);

water_pan[i].pos_x = mytile[i].posxa;
water_pan[i].pos_y = mytile[i].posya;
set(water_pan[i], SHOW);
//w_collisions(water_pan[i],i);
panel_me(i);
//test_show(*myVar);
}
/*
else
{
//w = i;
stone_pan[i] = pan_create("bmap = stone.png;", mytile[i].levela);
stone_pan[i].pos_x = mytile[i].posxa;
stone_pan[i].pos_y = mytile[i].posya;
set(stone_pan[i], SHOW);
}
*/
}
Here pointer is 'water_pan[i]'. You have somewhere in your code PANEL* water_pan[999]; with probably different numbers in those brackets. To access the pointer use 'i', I would call it ID to make easier for you to understand. So in PANEL* water_pan[999]; you have list of 999 EMPTY panel pointers. In that 'for' loop you create panels from 0 to the amount of buffercount, so you ID range will be from 0 to buffercount (let's say it's 10). So in order to access panel with ID 5 within a list of 10 panels, you have to 'save' it's ID and then check for it, to return the pointer. Let's say you save ID in the 'skill_x', right after you created your panel 'water_pan[i]'.

The following code is not tested, and was made just to give you an idea of how it should work.
Code:
water_pan[i] = pan_create(blahblah);
water_pan[i].skill_x = i;

After this, each of your panel will have it's ID saved, so you can create function like this, to find the panel:
Code:
PANEL* returnWaterPan(id){
     for(i = 0; i < buffercount, i++){
           if(water_pan[i].skill_x == id){
               return(water_pan[i]);
           }
}

Or you can use it directly, if you know the id:
Code:
water_pan[5];



Originally Posted By: seneca

sorry, I can't find the code tags.
Next time when you write your message, press 'Switch To Full Reply Screen' next to 'Submit' and 'Preview Reply', there you'll see '#', press on it and select 'code'. It will create [code*][/code*] (without *), you should write your code between those tags.

Originally Posted By: seneca
the error I get is the E1513, everytime, no matter how I phrase it.

below is only 1 of 30 different ways I've tried to access the pointer.

********************************************************
function get_pan(p)
{
var g = p+1;
PANEL* temp_pan_new[100];
temp_pan_new[g] = p;


/*
while (1)
{

if(!play_pan){beep();}
temp_nopposx = g;
if(temp_pan_new[g].pos_x <= player_pan.pos_x)
{
temp_var += .001;
}

wait (1);
}// end while 1
*/
}
****************************************************

I've got other projects where it works fine, but this one...?
I just don't get it.

thanks.
First of all, what is that '(p)' in the function parameters?? Is that suppose to be a panel name when using that function? Next thing probably causing the empty pointer error is here:
Code:
PANEL* temp_pan_new[100];
temp_pan_new[g] = p;

I'm not sure of what you are trying to do here, but just don't do this. grin It gives me a headache when I try to understand it. Just go with the idea I've wrote above, and you'll be able to access your panels without any problems.


Greets


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: pointer to a panel not working.... [Re: 3run] #450724
04/21/15 13:01
04/21/15 13:01
Joined: Aug 2005
Posts: 199
houston
S
seneca Offline OP
Member
seneca  Offline OP
Member
S

Joined: Aug 2005
Posts: 199
houston
Thanks for your help to the both of you. turn's out it was a timing issue. After I clean up the code to make it less confusing. Thanks again for the great advice.


a8 commercial

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1