Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, degenerate_762, ozgur), 1,311 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
see if a text is still valid #441715
05/31/14 20:43
05/31/14 20:43
Joined: Jun 2004
Posts: 2,234
Wisconsin USA
FoxHound Offline OP
Expert
FoxHound  Offline OP
Expert

Joined: Jun 2004
Posts: 2,234
Wisconsin USA
In a while loop I want to see if a text is still valid. So far the only way I have found to see if this is true is with this

while(ptr_for_handle(handle(my_text)) != NULL)

ptr_for_handle is a medium speed function and if I can help it I do not want to use it in a while loop, handle says it is fast but that still seems like a lot of waster resources here.

(my_text) (my_text != NULL) do not work.

The text is removed with ptr_remove()

Any faster ideas then what I have tried?


---------------------
There is no signature here.


QUIT LOOKING FOR ONE!
Re: see if a text is still valid [Re: FoxHound] #441717
05/31/14 20:52
05/31/14 20:52
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
you could still check for it in a while loop but not every frame, take a look at 'total_frames' f.e.
in older aums (ai tutorials) this idea was used to shoot bullets at player.


greets


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: see if a text is still valid [Re: 3run] #441718
05/31/14 20:57
05/31/14 20:57
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
ptr_for_handle(handle(my_text)) is pointless. It will crash if my_text is a vagabonding pointer.

The clean way is to set all pointers to a specific element to null. Then you can check in the other code if its valid (non-null) or removed (null).


Always learn from history, to be sure you make the same mistakes again...
Re: see if a text is still valid [Re: Uhrwerk] #441722
05/31/14 21:47
05/31/14 21:47
Joined: Jun 2004
Posts: 2,234
Wisconsin USA
FoxHound Offline OP
Expert
FoxHound  Offline OP
Expert

Joined: Jun 2004
Posts: 2,234
Wisconsin USA
When I set the my_text to NULL and in the other function check to see that it isn't null, the function doesn't end. I know this as I have sys_exit set after the function so it can't be missed.


---------------------
There is no signature here.


QUIT LOOKING FOR ONE!
Re: see if a text is still valid [Re: FoxHound] #441724
05/31/14 21:56
05/31/14 21:56
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Then you did something wrong in your code. Here is a working example for you:
Code:
#include <acknex.h>

TEXT* myText = NULL;

void waitForMyTextToBecomeNull()
{
	while (myText)
		wait(1);
		
	sys_exit("e voila...");
}


void main()
{
	myText = txt_create(1,1);
	waitForMyTextToBecomeNull();

	wait(-2);

	ptr_remove(myText);
	myText = NULL;
}



Always learn from history, to be sure you make the same mistakes again...
Re: see if a text is still valid [Re: Uhrwerk] #441747
06/01/14 16:19
06/01/14 16:19
Joined: Jun 2004
Posts: 2,234
Wisconsin USA
FoxHound Offline OP
Expert
FoxHound  Offline OP
Expert

Joined: Jun 2004
Posts: 2,234
Wisconsin USA
You're code does work, even when I pass the text pointer through the function. Prehaps my storing the text with handle has something to do with it. Here is the code that concerns this.

Click to reveal..

//////////////////////////////
// this function checks to see if the var has changed, and if it has we alter the string in the text to match it
//////////////////////////////
void monitor_for_var_change(TEXT* loc_text)
{
while(loc_text)
wait(1);

sys_exit("");
}

Yes I Have made sure that skill_y holds the text. when the function runs the panel and the text both disappear. I simply need the function itself that checks for the text to end so I do not have pointer errors (I removed code that had nothing to do with the problem and I removed that from my own code to see if it might be the issue.

void destory_foxpan(PANEL* fox_pan)
{

TEXT* mytext = ptr_for_handle(fox_pan.skill_y);


//////////////////////////////
// we remove the text
//////////////////////////////
ptr_remove(mytext);
mytext = NULL;


//////////////////////////////
// we remove the panel
//////////////////////////////
ptr_remove(fox_pan);

}


---------------------
There is no signature here.


QUIT LOOKING FOR ONE!
Re: see if a text is still valid [Re: FoxHound] #441750
06/01/14 16:24
06/01/14 16:24
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
You're testing a local variable for a change. The local variable however won't change until you modify it in the corresponding function. You can either use a global variable instead or pass a pointer to the pointer to the function and check the variable this way.


Always learn from history, to be sure you make the same mistakes again...
Re: see if a text is still valid [Re: Uhrwerk] #441751
06/01/14 16:57
06/01/14 16:57
Joined: Jun 2004
Posts: 2,234
Wisconsin USA
FoxHound Offline OP
Expert
FoxHound  Offline OP
Expert

Joined: Jun 2004
Posts: 2,234
Wisconsin USA
How am I using a local variable? I am assigning the pointer to a pointer and modifying it. This can be seen as when I destroy the text, it disappears from my screen.

If you can show an example of where I can keep the pointer in the skill of the panel and make this work it would be great, otherwise it seems a struct is my best hope.


---------------------
There is no signature here.


QUIT LOOKING FOR ONE!
Re: see if a text is still valid [Re: FoxHound] #441754
06/01/14 17:45
06/01/14 17:45
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Here is a working example for you that uses a pointer to the pointer:
Code:
#include <acknex.h>

void waitForThePointerToBecomeNull(void** p)
{
	while (*p)
		wait(1);

	sys_exit("e voila...");
}

TEXT* myText = NULL;

void main()
{
	myText = txt_create(1,1);
	waitForThePointerToBecomeNull(&myText);
	
	wait(-2);
	
	ptr_remove(myText);
	myText = NULL;
}



Always learn from history, to be sure you make the same mistakes again...
Re: see if a text is still valid [Re: Uhrwerk] #441755
06/01/14 19:03
06/01/14 19:03
Joined: Jun 2004
Posts: 2,234
Wisconsin USA
FoxHound Offline OP
Expert
FoxHound  Offline OP
Expert

Joined: Jun 2004
Posts: 2,234
Wisconsin USA
Still not working. However I did get it to work a different way by having the destory function set the skill_y of the text to 0 and tell the wait function to end if the skill y is zero. Not happy with it but it works.


---------------------
There is no signature here.


QUIT LOOKING FOR ONE!
Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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