1 registered members (AndrewAMD),
1,248
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
pan_create covering screen with numbers
#211717
06/17/08 22:22
06/17/08 22:22
|
Joined: May 2006
Posts: 90 England
TigerTao
OP
Junior Member
|
OP
Junior Member
Joined: May 2006
Posts: 90
England
|
Im trying to make panels for my enemies to show their pan yet my panel code in the enemy action script works but then makes hundreds of panels as the enemys move.
This is the condensed code in my enemy script:
PANEL* panel //define panel
action enemy_dummy { WHILE(1) { panel = pan_create("digits (0, -80, 2, standard_font, 1, my.enemy_pan);flags=visible | overlay;",1); my.enemy_pan = ang(my.pan); digits_set(panel,1,my.enemy_pan); vec_set(temp,my.x); vec_to_screen(temp,camera); panel.pos_x = temp.x; panel.pos_y = temp.y;
if (you != NULL) { //blah blah blah } wait(1) } }
I put ptr_remove(panel) just below wait(1). This stops the constant spawning of panels yet only one panel will work on one enemy and not the others. All the other panels will either be in the centre of screen or to the very top left of screen.
How do I stop this?
Is there a better way of creating panels for each entity and to follow them ?
Many thanks for any hints.
|
|
|
Re: pan_create covering screen with numbers
[Re: TigerTao]
#211719
06/17/08 22:36
06/17/08 22:36
|
Joined: Nov 2007
Posts: 1,143 United Kingdom
DJBMASTER
Serious User
|
Serious User
Joined: Nov 2007
Posts: 1,143
United Kingdom
|
you have placed the pan_create code inside a while loop. This means you will be creating panels constantly and this is one hell of a memory hog.
Place...
panel = pan_create("digits (0, -80, 2, standard_font, 1, my.enemy_pan);flags=visible | overlay;",1); my.enemy_pan = ang(my.pan); digits_set(panel,1,my.enemy_pan);
...just before the while loop instead of inside it.
Last edited by DJBMASTER; 06/17/08 22:38.
|
|
|
Re: pan_create covering screen with numbers
[Re: TigerTao]
#211850
06/18/08 19:07
06/18/08 19:07
|
Joined: Oct 2004
Posts: 4,134 Netherlands
Joozey
Expert
|
Expert
Joined: Oct 2004
Posts: 4,134
Netherlands
|
now you removed the while for pan_create you probably forgot to place vec_to_screen(temp.x, camera.x) and panel.pos_x = temp.x inside a while?
Last edited by Joozey; 06/18/08 19:09.
Click and join the 3dgs irc community! Room: #3dgs
|
|
|
Re: pan_create covering screen with numbers
[Re: Joozey]
#211869
06/18/08 20:16
06/18/08 20:16
|
Joined: May 2006
Posts: 90 England
TigerTao
OP
Junior Member
|
OP
Junior Member
Joined: May 2006
Posts: 90
England
|
I played around with the placing of the code and found even with only the pan_create outside the while loop, the panel was created only above one of the enemy. No luck there Joozey. I think I figured it out I define a panel globally PANEL* panel; Then each entity creates the same panel overwriting the other entity before it so only the last one has the panel following them. So what I need is a way to create a panel for each enemy so the others do not steal his panel. I think perhaps I will convert my script to lite-C and use structures before things get messy
|
|
|
Re: pan_create covering screen with numbers
[Re: Joozey]
#211930
06/19/08 07:07
06/19/08 07:07
|
Joined: Oct 2004
Posts: 1,655
testDummy
Serious User
|
Serious User
Joined: Oct 2004
Posts: 1,655
|
Old files and useless examples: _0c.wdl.txt
// functions
drawStr0(_str, &_pos, _lineNumber);
drawStr2(_str0, _str1, &_pos, _lineNumber);
drawVar0(_str, _var, &_pos, _lineNumber);
drawVec0(_str &_vec, &_pos, _lineNumber);
// usage
action enemy_dummy { // 'YOU' are the enemy!!!
while(me) {
drawVec0("my.x: ", my.x, my.x, 0);
drawVec0("my.pan: ", my.pan, my.x, 1);
wait(1);
}
}
// quick 5 min example; example only
PANEL* p1;
PANEL* p2;
ENTITY* e1;
define _p1, skill70;
function pf_new1(_e) {
if (_e == 0) { return(0); }
e1 = _e;
if (e1._p1 != 0) { return(0); }
//p1= pan_create("digits (0, -80, 2, standard_font, 1, my.enemy_pan);flags=visible | overlay;",1);
//draw_text might better suited for that; panel.digits not recommended
if (p1 == NULL) { return(0); }
e1._p1 = handle(p1);
return(1);
}
function pf_get1(_e) {
p1 = NULL;
if (_e == 0) { return(0); }
e1 = _e;
if(e1._p1 == 0) { return(0); }
p1 = ptr_for_handle(e1_p1);
if (p1 == NULL) { return(0); }
return(1);
}
//...
pf_new1(me);
while(me) {
pf_get1(me);
// manipulate p1 if not null or pf_get1 returns 1
wait(1);
}
//...
|
|
|
Re: pan_create covering screen with numbers
[Re: testDummy]
#212163
06/20/08 18:45
06/20/08 18:45
|
Joined: May 2006
Posts: 90 England
TigerTao
OP
Junior Member
|
OP
Junior Member
Joined: May 2006
Posts: 90
England
|
Thanks TestDummy I will look over this code yet, its a little beyond me at the moment.
Ive got over the panel stealing by enemies by manually defining panels globally
PANEl* panel1.....10
and then in my enemy action I use an enemy ID to create a panel for them
entity_handle[entity_count] = handle(me); entity_count += 1;
if(ptr_for_handle(entity_handle[0])==me) {panel1 = pan_create("blah blah blah");} if(ptr_for_handle(entity_handle[1])==me) {panel2 = pan_create("blah blah blah");}
and so on....
What would be really cool is if I can just create a string defined as "panel" and add entity_count to the end so creating "panel1" if the count is at 1, "panel2" if the count is at 2, etc.
With this string is it possible to then convert the string to actual compiled code?
So I could then go
my_panel_string(compiled as panel1..10)= pan_create("blah blah blah");}
Thus creating one panel locked to each enemy?
Last edited by TigerTao; 06/20/08 18:50.
|
|
|
Re: pan_create covering screen with numbers
[Re: TigerTao]
#212240
06/20/08 23:50
06/20/08 23:50
|
Joined: May 2006
Posts: 90 England
TigerTao
OP
Junior Member
|
OP
Junior Member
Joined: May 2006
Posts: 90
England
|
Ok I know this works:
entity_handle[entity_count] = handle(me); entity_count += 1;
my_panel = str_create("panel"); my_panel = str_cat_num(my_panel,"%.0f",entity_count);
This creates a string called panel3 as entity_count ends at 3. Now I need to figure out how to make an array for these strings, then call at every entity_count+ and turn the string into compilable code. Phew.
Last edited by TigerTao; 06/20/08 23:51.
|
|
|
|