|
reset function
#423589
06/01/13 14:46
06/01/13 14:46
|
Joined: Jul 2001
Posts: 4,801 netherlands
Realspawn
OP

Expert
|
OP

Expert
Joined: Jul 2001
Posts: 4,801
netherlands
|
How could I make this function reset. So the picture get's placed at it's original start point ?
PANEL* looptxt_pan =
{
bmap = "nextstage.tga";
pos_x = 1054;
pos_y = 350;
layer = 50;
}
function looptxt()
{
wait(3);
set(looptxt_pan,SHOW | OVERLAY);
while(1)
{
looptxt_pan->pos_x = cycle(looptxt_pan->pos_x -30 * time_step,-bmap_width(looptxt_pan->bmap),screen_size.x);
wait(1);
}
}
It works for now but i need to be able to reset this complete function so it can be used all over when needed. Thx for your time 
|
|
|
Re: reset function
[Re: Realspawn]
#423590
06/01/13 15:19
06/01/13 15:19
|
Joined: May 2013
Posts: 23 Somewhere
Wiseguy
Newbie
|
Newbie
Joined: May 2013
Posts: 23
Somewhere
|
Not to sound rude, but you've got to be kidding, right? I mean, you've over 4k posts and are apparently a long time user and even a moderator.
His words are wise, his face is beard.
|
|
|
Re: reset function
[Re: krial057]
#423595
06/01/13 16:12
06/01/13 16:12
|
Joined: Jul 2001
Posts: 4,801 netherlands
Realspawn
OP

Expert
|
OP

Expert
Joined: Jul 2001
Posts: 4,801
netherlands
|
thank you As i always mention i am a non coder  have a fulltime job and do this in my free time for fun  so nope i am not kidding the number of posts and the fact that i moderate has nothing to do with me not beeing a coder  Although i understand why people think that. I like to toy with 3DGS and enjoy seeing enough people out here still willing to help out. All i do know and learn is on my noob site  so people like me can still try to create fun things  I will always envy those fast coders 
Last edited by Realspawn; 06/01/13 16:13.
|
|
|
Re: reset function
[Re: Realspawn]
#423596
06/01/13 16:19
06/01/13 16:19
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
User
|
User
Joined: Mar 2012
Posts: 927
cyberspace
|
You could do it in another way aswell.. (dont be so modest , everyone can code and everyone who can code needs help one time or another)
If you used a variable of integer instead of while(1) like while(not_reached_border) then when your x position reaches your req x position set not_reached_border to 1..
This will help to exit the while loop if you dont want it to loop all the time..
Last edited by Wjbender; 06/01/13 16:20.
Compulsive compiler
|
|
|
Re: reset function
[Re: Wjbender]
#423615
06/02/13 00:55
06/02/13 00:55
|
Malice
Unregistered
|
Malice
Unregistered
|
If you used a variable of integer instead of while(1) like while(not_reached_border) then when your x position reaches your req x position set not_reached_border to 1..
Why would you do this? 'while' is a comparison.
while(pan->pos_x < screen_size.x- bmap_width(pan->bmap)){ ...code...
wait(1);}
.. then restore pan->pos_x to your save starting points...
Why create variable?
Last edited by Malice; 06/02/13 00:59.
|
|
|
Re: reset function
[Re: ]
#423618
06/02/13 08:53
06/02/13 08:53
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
User
|
User
Joined: Mar 2012
Posts: 927
cyberspace
|
Because you could globaly reset that variable and your code comes dow. To the same thing an evaluation ..(malis)
By the way if your going to respond to someone asking help be fucking friendly not a dickhead(wiseguy)
Last edited by Wjbender; 06/02/13 08:55.
Compulsive compiler
|
|
|
Re: reset function
[Re: krial057]
#423627
06/02/13 12:40
06/02/13 12:40
|
Joined: Sep 2007
Posts: 101 Luxembourg
krial057
Member
|
Member
Joined: Sep 2007
Posts: 101
Luxembourg
|
Oh, my bad. Didn't know about this: Within the struct initialization, any numbers, variables, character strings, or pointers to other structs can be used, but internal engine variables (such as "camera"), and #defines (such as a previously defined "NUMBER_OF_ARRAY_ELEMENTS") can not be used. I tried using variables instead of defines, but that doesn't work either  (However, as I understand the manual, it should... I tested using variables in custem defined structs and there it works...) If you are only using looptxt to show the panel, you could emit the position initialisation in the panel definition:
#define LOOPTXT_PAN_ORIGINAL_X 1054
#define LOOPTXT_PAN_ORIGINAL_Y 350
PANEL* looptxt_pan =
{
bmap = "nextstage.tga";
layer = 50;
}
function looptxt()
{
wait(3);
looptxt_pan->pos_x = LOOPTXT_PAN_ORIGINAL_X ;
looptxt_pan->pos_y = LOOPTXT_PAN_ORIGINAL_Y ;
set(looptxt_pan,SHOW | OVERLAY);
while(1)
{
looptxt_pan->pos_x = cycle(looptxt_pan->pos_x -30 * time_step,-bmap_width(looptxt_pan->bmap),screen_size.x);
wait(1);
}
}
Ohterwise, you have to put the numbers manually in the struct as you did at the start.
|
|
|
Re: reset function
[Re: krial057]
#423646
06/02/13 16:31
06/02/13 16:31
|
Joined: Jul 2001
Posts: 4,801 netherlands
Realspawn
OP

Expert
|
OP

Expert
Joined: Jul 2001
Posts: 4,801
netherlands
|
Since i am no coder i want to ask (have to ask) to learn from it. My original code works. But is there no easy way to reset/kill a function so it can be recalled ? i looked into proc_kill2 that works but does not reset the pictures position:) It should be possible that this function plays once every time it is called ? Am i thinking to simple 
Last edited by Realspawn; 06/02/13 17:01.
|
|
|
|