Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
M1 Oversampling
by 11honza11. 04/20/24 20:57
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, rki), 390 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Turn Panels of and on - depending on a variable #408652
10/05/12 09:05
10/05/12 09:05
Joined: Jul 2010
Posts: 974
United Arab Emirates, Dubai
TheShooter Offline OP
User
TheShooter  Offline OP
User

Joined: Jul 2010
Posts: 974
United Arab Emirates, Dubai
Hi,
I'm trying to hide my ammopanel, when the variable armed = 0. And I want also to show panels for different weapontypes depending on the value of armed.
E.g.
armed = 1 - pistolammo
armed = 2 - rifleammo

I also tried to work with INVISIBLE and TRANSLUCENT, but both don't work for me. Since I noticed that INVISIBLE is only for Level-Entitys, I worked with TRANSLUCENT from this point.

Here's my code so far:

The ammo and armed variables are global.

Code:
function hud()
{
	//armed = 0 - unarmed
	//armed = 1 - Pistol
	//armed = 2 - Rifle
	//armed = 3 - Shotgun
	PANEL* pistol_muni_pan =
	{
		digits(1450,925,3,"Arial#150b",1,ammo_pistol);
		flags = TRANSLUCENT;
	}
	pistol_muni_pan.alpha = 0;
	
	PANEL* rifle_muni_pan =
	{
		digits(1450,925,3,"Arial#150b",1,ammo_rifle);
		flags = TRANSLUCENT;
	}
	rifle_muni_pan.alpha = 0;
	
	while(armed > 0)
	{
		switch(armed)
		{
			case 1:
			pistol_muni_pan.alpha = 100;
			
			case 2:
			rifle_muni_pan.alpha = 100;
			
		}
		wait(1);
	}
	pistol_muni_pan.alpha = 0;
	rifle_muni_pan.alpha = 0;
}



Am I doing something wrong? I did this a year ago the same way, and it worked just fine. (unfortunately I don't have the code any more)

Would be really thankful for help,
Shooter


Staub ist das neue Prime!!

Programming is like sex:
One mistake and you have to support it for the rest of your life.

Aktuelles Projekt: http://thisiswargame.bplaced.net/index.html

A8 Commercial *freu*
Re: Turn Panels of and on - depending on a variable [Re: TheShooter] #408653
10/05/12 09:06
10/05/12 09:06
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
you should really just take a look in the manual under Panel->Panel Properties->Flags....
RTFM


Visit my site: www.masterq32.de
Re: Turn Panels of and on - depending on a variable [Re: MasterQ32] #408654
10/05/12 09:08
10/05/12 09:08
Joined: Jul 2010
Posts: 974
United Arab Emirates, Dubai
TheShooter Offline OP
User
TheShooter  Offline OP
User

Joined: Jul 2010
Posts: 974
United Arab Emirates, Dubai
I did already, and found this:

TRANSLUCENT
Das Panel wird seinem alpha-Parameter entsprechend transparent gezeichent.


Which means at english, that the panel gets transparent with it's alphavalue.

And exactly this I tried in my code, since INVISIBLE didn't seem to work.

Last edited by TheShooter; 10/05/12 09:14.

Staub ist das neue Prime!!

Programming is like sex:
One mistake and you have to support it for the rest of your life.

Aktuelles Projekt: http://thisiswargame.bplaced.net/index.html

A8 Commercial *freu*
Re: Turn Panels of and on - depending on a variable [Re: TheShooter] #408655
10/05/12 09:22
10/05/12 09:22
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
INVISIBLE is for entities only
just try to use SHOW instead of invisible ^^ (and don't forget: SHOW is positive, IVISIBLE negative)


Visit my site: www.masterq32.de
Re: Turn Panels of and on - depending on a variable [Re: MasterQ32] #408658
10/05/12 09:34
10/05/12 09:34
Joined: Jul 2010
Posts: 974
United Arab Emirates, Dubai
TheShooter Offline OP
User
TheShooter  Offline OP
User

Joined: Jul 2010
Posts: 974
United Arab Emirates, Dubai
Yes, I use SHOW to make them visible. But what can I use to make them invisible again? (!SHOW would be useful)
I can't use toggle, because the panelmanagement is in a while, which would lead to complete chaos. grin

regards,
TheShooter


Staub ist das neue Prime!!

Programming is like sex:
One mistake and you have to support it for the rest of your life.

Aktuelles Projekt: http://thisiswargame.bplaced.net/index.html

A8 Commercial *freu*
Re: Turn Panels of and on - depending on a variable [Re: TheShooter] #408660
10/05/12 09:45
10/05/12 09:45
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
what about reset(pan, SHOW); ??


Visit my site: www.masterq32.de
Re: Turn Panels of and on - depending on a variable [Re: MasterQ32] #408661
10/05/12 09:50
10/05/12 09:50
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline
Serious User
PadMalcom  Offline
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
reset switches a flag off, set switches it on.

In particular: reset(pan, SHOW) makes your panel invisible, set(pan, SHOW) makes it visible.

Re: Turn Panels of and on - depending on a variable [Re: PadMalcom] #408662
10/05/12 10:05
10/05/12 10:05
Joined: Jul 2010
Posts: 974
United Arab Emirates, Dubai
TheShooter Offline OP
User
TheShooter  Offline OP
User

Joined: Jul 2010
Posts: 974
United Arab Emirates, Dubai
AH, thank you, I didn't know this command.

The fully working code: (In the case someone needs such a code)

Code:
function hud()
{
	//armed = 0 - unarmed
	//armed = 1 - Pistol
	//armed = 2 - Rifle
	//armed = 3 - Shotgun
	PANEL* pistol_muni_pan =
	{
		digits(1450,925,3,"Arial#150b",1,ammo_pistol);
	}
	
	PANEL* rifle_muni_pan =
	{
		digits(1450,925,3,"Arial#150b",1,ammo_rifle);
	}
	
	PANEL* shotgun_muni_pan =
	{
		digits(1450,925,3,"Arial#150b",1,ammo_shotgun);
	}
	
	while(1)
	{
		switch(armed)
		{
			case 1:
			{
				set(pistol_muni_pan, SHOW);
				reset(rifle_muni_pan, SHOW);
				reset(shotgun_muni_pan, SHOW);
				break;
			}
			case 2:
			{
				set(rifle_muni_pan, SHOW);
				reset(pistol_muni_pan, SHOW);
				reset(shotgun_muni_pan, SHOW);
				break;
			}
			
			case 3:
			{
				set(shotgun_muni_pan, SHOW);
				reset(pistol_muni_pan, SHOW);
				reset(rifle_muni_pan, SHOW);
				break;
			}
			
			default:
			reset(pistol_muni_pan, SHOW);
			reset(rifle_muni_pan, SHOW);
			reset(shotgun_muni_pan, SHOW);
			
		}
		wait(1);
	}

}



Thank you,
Shooter


Staub ist das neue Prime!!

Programming is like sex:
One mistake and you have to support it for the rest of your life.

Aktuelles Projekt: http://thisiswargame.bplaced.net/index.html

A8 Commercial *freu*
Re: Turn Panels of and on - depending on a variable [Re: TheShooter] #408663
10/05/12 10:21
10/05/12 10:21
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline
Serious User
PadMalcom  Offline
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
Hey, eine kleine Verbesserung noch:

- Setze die Panel-Definitionen (PANEL* pistol_muni_pan...) nicht in eine Funktion. Sonst kannst du später nicht von außen darauf zugreifen falls das mal nötig werden sollte.

P.S. Sehr schön formatierter Quelltext laugh

EDIT: Und ich finde es toll, dass du die fertige Lösung nochmal postest!!!

Last edited by PadMalcom; 10/05/12 10:21.
Re: Turn Panels of and on - depending on a variable [Re: PadMalcom] #408664
10/05/12 10:56
10/05/12 10:56
Joined: Jul 2010
Posts: 974
United Arab Emirates, Dubai
TheShooter Offline OP
User
TheShooter  Offline OP
User

Joined: Jul 2010
Posts: 974
United Arab Emirates, Dubai
Alles klar, danke für den Tip. laugh


Staub ist das neue Prime!!

Programming is like sex:
One mistake and you have to support it for the rest of your life.

Aktuelles Projekt: http://thisiswargame.bplaced.net/index.html

A8 Commercial *freu*

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