Gamestudio Links
Zorro Links
Newest Posts
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,529 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Disable key_1? #394940
02/17/12 23:42
02/17/12 23:42
Joined: Nov 2009
Posts: 70
Siwler Offline OP
Junior Member
Siwler  Offline OP
Junior Member

Joined: Nov 2009
Posts: 70
Hi, everyone.

Can anyone show me how to disable key_1 on level_load

I tried many different ways and no luck.

Here is one of many examples that I have tried:

Code:
STRING* key_1 = "1";
/////////////////////////////
action WepShoppe_loadLvL() // attach this action to an entity at the weapons shoppes door 

{
       var key_1_off;
       while (vec_dist (player.x, my.x) > 100)  // wait until the player comes close to this entity
       {
               wait (1);        
       }

       wait (-1); // wait for a second
       level_load (WepShoppe_wmb); // now load the wepshoppe level
       mouse_mode = 4; // set courser on for this lvl
       mouse_map = cursor_pcx;
       key_1_off = 0;
       if(key_pressed(key_for_str(key_1)))
       {
       key_1_off = OFF; // or 0
       }
       ptr_remove(me);       

}



I tried enable_key but that only disables Esc button.


Honesty will get you far, were dishonesty will get you only so far in life.

Re: Disable key_1? [Re: Siwler] #394941
02/17/12 23:47
02/17/12 23:47
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
What do you mean by "disabling" ?


Always learn from history, to be sure you make the same mistakes again...
Re: Disable key_1? [Re: Siwler] #394942
02/17/12 23:47
02/17/12 23:47
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline
Serious User
PadMalcom  Offline
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
If you assigned a function to "key_1" you can reset it by settings "key_1 = NULL;".

Re: Disable key_1? [Re: PadMalcom] #394944
02/18/12 00:00
02/18/12 00:00
Joined: Nov 2009
Posts: 70
Siwler Offline OP
Junior Member
Siwler  Offline OP
Junior Member

Joined: Nov 2009
Posts: 70
Tried key_1 = NULL; no luck there.


Honesty will get you far, were dishonesty will get you only so far in life.

Re: Disable key_1? [Re: Uhrwerk] #394945
02/18/12 00:06
02/18/12 00:06
Joined: Nov 2009
Posts: 70
Siwler Offline OP
Junior Member
Siwler  Offline OP
Junior Member

Joined: Nov 2009
Posts: 70
Originally Posted By: Uhrwerk
What do you mean by "disabling" ?


If and when player enters new level I want to disable or ignore button 1 on input/press(pretty much if any action/function is activated by button 1, I want it to ignore any action a singed to it) and if its possible to force disable until player leaves that particular level.


Honesty will get you far, were dishonesty will get you only so far in life.

Re: Disable key_1? [Re: Siwler] #394946
02/18/12 00:14
02/18/12 00:14
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Originally Posted By: Siwler
pretty much if any action/function is activated by button 1, I want it to ignore any action a singed to it
That is exactly what PadMalcom told you.
Code:
on_1 = NULL;


If that does not work there is some other flaw in your code. Why not posting the code you have until now.

Last edited by Uhrwerk; 02/18/12 00:16. Reason: Not exactly, what PadMalcom said. Note it is "on_1", not "key_1". "key_1" is a variable that shows the pressed state of the key.

Always learn from history, to be sure you make the same mistakes again...
Re: Disable key_1? [Re: Uhrwerk] #394949
02/18/12 01:11
02/18/12 01:11
Joined: Nov 2009
Posts: 70
Siwler Offline OP
Junior Member
Siwler  Offline OP
Junior Member

Joined: Nov 2009
Posts: 70
not working
This is the entire code that I'm working on right now.
Code:
STRING* key_1off = "1";
      BMAP* cursor_pcx = "cursor.tga";
/////////////////////////////
action WepShoppe_loadLvL() // attach this action to an entity at the weapons shoppes door 

{
       var key_1off;
       while (vec_dist (player.x, my.x) > 100)  // wait until the player comes close to this entity
       {
               wait (1);        
       }

       wait (-1); // wait for a second
       level_load (WepShoppe_wmb); // now load the wepshoppe level
       mouse_mode = 4; // set courser on for this lvl
       mouse_map = cursor_pcx;
      
       if(key_pressed(key_for_str(key_1off)))
       {
       on_1 = NULL; 
       }
       ptr_remove(me);       

}




Honesty will get you far, were dishonesty will get you only so far in life.

Re: Disable key_1? [Re: Siwler] #394954
02/18/12 02:21
02/18/12 02:21
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
This cannot be your whole code as WepShoppe_wmb is not defined. Apart from that I don't get the point what this code is supposed to do. By the way: you never assign anything to on_1 so the engine won't do anything at all when you press "1". Hence there is no need to unassign the key later on.

First you wait until the player gets closer than 100 quants. Ok so far. Then you wait a second - no idea why - and load a new level. Later on you try to check if "1" is pressed.
Code:
if(key_pressed(key_for_str(key_1off)))

This seems dangerous to me. Note that key_1off is ambiguous. It's a var as well as a STRING*. Not sure if Lite-C detects that the string is required or passes the var to key_for_str. I'm afraid it's the latter one and that may cause trouble.

Finally you try to remove the "my" entity which should be removed anyways through level_load.

Maybe you describe in more detail what you want to achieve?


Always learn from history, to be sure you make the same mistakes again...
Re: Disable key_1? [Re: Uhrwerk] #394962
02/18/12 04:51
02/18/12 04:51
Joined: Nov 2009
Posts: 70
Siwler Offline OP
Junior Member
Siwler  Offline OP
Junior Member

Joined: Nov 2009
Posts: 70
Lol, I know.
Its a test code, testing out various possibilities on how to code something. Its more like a teary in staged action, is it possible to code it this way or some other way, I have many different verities of codes, but none of them work laugh

What is this code supposed to do?
Its supposed to load 2nd level, disable button 1, enable mouse courser. All other actions that relate to this code are in another .c file like player movement, mouse_right click and so on.
But I see what you mean by assign anything to on_1.
I thought that on_1 = NULL; will disable button 1 no matter what.
So I need to make a hole new function that disables button 1 and than call it from another function as on_1 = NULL; but if I make function that disables button 1 and call it button1OFF
then I should call it out as on_1 = button1OFF; instead of on_1 = NULL; right?

WepShoppe is defined I just forgot to include it in the code, there is to much going on in this file, stuff that don't work I keep them under commentators so I would remind my self not to code that way again, I see how stuff would end up in active code.

everything else works fine except disable button 1 which I guess needs code function that disables button 1, which again is bringing me back to my question how do I code function that disables button 1?

function (button1OFF)
{

}






Honesty will get you far, were dishonesty will get you only so far in life.

Re: Disable key_1? [Re: Siwler] #394994
02/18/12 18:53
02/18/12 18:53
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
I am not sure if you totally understood the concept of assigning events to keys. Ok, the first thing you do is writing a function that is to be executed. Like this:
Code:
void my_key_event()
{
	printf("my_key_event was called");
}


Note that this function is not called until now. In order to assign it to a certain key you have to do the following:
Code:
on_1 = my_key_event;


That's all. There is nothing more to do. You can get rid of the key assignment by simply writing:
Code:
on_1 = NULL;


If that does not work for you there is another place in your code where on_1 gets changed as well. You can easily check this by doing the following:
Code:
on_1 = NULL;
wait(1);
if (on_1)
	printf("Oh crap! on_1 got reassigned some place else!")


Here you have a running example:
Code:
#include <acknex.h>

void foobar()
{
	beep();
}

void main()
{
	on_1 = foobar;
	wait(-10);
	on_1 = NULL;
}


In the example a key press of 1 will beep for the first ten seconds. After that the key will get disabled.



Always learn from history, to be sure you make the same mistakes again...
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