sys_exit

Posted By: DLively

sys_exit - 04/23/14 19:45

Hi, I am noticing that I cannot use my esc button to exit my game. I've tried:

Code:
function on_esc_event(){sys_exit("321");}



and that didn't work, which is strange since

Code:
function on_x_event(){sys_exit("321");}



^^ This does.

Hmm..?
Posted By: Superku

Re: sys_exit - 04/23/14 19:49

Have you tried to set
on_esc = ...;
somewhere in your script (let's say the main function)?
Posted By: DLively

Re: sys_exit - 04/23/14 19:58

Yes and with no result smirk

Its very strange as I have not defined anywhere that on_esc = null
Posted By: Superku

Re: sys_exit - 04/23/14 20:09

Do you have default.c included? Normally this should not overwrite it but try to comment the include of default.c and try again.
Posted By: DLively

Re: sys_exit - 04/23/14 20:57

No such luck smirk

This also happens on my other machine.

This works:


function on_grave_event(){sys_exit("321");}

with or without the default.c
Posted By: Uhrwerk

Re: sys_exit - 04/23/14 21:28

Then you're overwriting on_esc yourself. This sample code works flawlessly:
Code:
#include <acknex.h>

function on_esc_event()
{
	printf("Oh yeah!");
	sys_exit(NULL);
}

Posted By: DLively

Re: sys_exit - 04/23/14 22:32

that is literally the only place in my script that deals with esc.

I tried your alternative with much excitement and it didn't work for me smirk
Posted By: DLively

Re: sys_exit - 04/23/14 22:37

as mentioned every other key seems to work..
Posted By: Superku

Re: sys_exit - 04/23/14 22:46

Code:
#include <acknex.h>

void main()
{
	while(1)
	{
		DEBUG_VAR(key_esc,20);
		wait(1);
	}
}


If this shows 1 then you are overwriting it somewhere else, maybe in some include file, I don't know. Maybe add an "DEBUG_VAR(on_esc,40);" as well.
Posted By: DLively

Re: sys_exit - 04/24/14 07:45

It stays at 0 :?

It was 1 giant script. There was no esc being used until I tried to define it cause it wasn't working.

If I try DEBUG_VAR(on_esc,40); I get a number 207856.813
Posted By: Ch40zzC0d3r

Re: sys_exit - 04/24/14 09:24

Its a void-pointer so print out its address and not a number xD
Addresses are hex so use printf(Address: %X", on_esc);
Posted By: Superku

Re: sys_exit - 04/24/14 12:15

Quote:
If I try DEBUG_VAR(on_esc,40); I get a number 207856.813

That's fine because we now know your on_esc pointer gets not overwritten/ set to NULL.
The problem apparently is your keyboard or some other hardware/ driver issue. Have you tried to execute your code on some other PC (for example as an executable)?
Posted By: DLively

Re: sys_exit - 04/24/14 13:13

I have noted it works better when the computer is restarted, but seems to only work for short amount of time.. I guess im kinda re-leaved its not 3dgs :?
Posted By: Emre

Re: sys_exit - 04/24/14 13:50

Do you have another program like photoshop or something similar?

http://superuser.com/questions/211556/photoshop-causing-other-programs-not-receive-esc-key
Posted By: DLively

Re: sys_exit - 04/25/14 01:36

omg Emre!!!!!! Thats the glitch!! its that damn photoshop CS2!!!!!!!!!!!

THANK YOU!! laugh
Posted By: Emre

Re: sys_exit - 04/25/14 04:50

You are welcome wink
© 2024 lite-C Forums