ACS Question

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
Cyrez
Posts: 81
Joined: Tue Jul 15, 2003 4:20 pm
Location: Missouri
Contact:

ACS Question

Post by Cyrez »

hey all, can i get an example of how Checkweapon works please?
I no this but it's one of them brain fart days and I can't for the life of we figure it out. what im wanting is a

if curweapon is blah
do blah
else if curweapon is blah2
do blah2

sorry for asking such a dumb question but hey :wink:
User avatar
ace
Posts: 787
Joined: Tue Jun 21, 2005 10:14 am
Location: Just south of the True North

Post by ace »

I'm not sure, but wouldn't it be something like:

Code: Select all

script 123 (void)
{
   if(CheckWeapon("Shotgun")==1)
   {
       do this
   }
   if(CheckWeapon("PlasmaRifle")==1)
   {
       do that
   }
   if(CheckWeapon("RocketLauncher")==1)
   {
       blow stuff up
   }
}
And so on... again, just a guess but it sounds similar to CheckInventory to me.
User avatar
Wasted Youth
Posts: 358
Joined: Mon Jan 05, 2004 9:59 pm
Location: Earth

Post by Wasted Youth »

This would work:

Code: Select all

Script 1 (void) {
	If(CheckWeapon("Shotgun")) {
		action;
	}
	Else {
		If(CheckWeapon("PlasmaRifle")) {
			action;
		}
		Else {
			If(CheckWeapon("RocketLauncher")) {
				action;
			}
		}
	}
}
One thing to remember about IF and ELSE statements.

If you have a script like this.

Code: Select all

Script 1 (void) {
	If(cat1 == 1) {
		action;
	}
	If(cat2 == 1) {
		action;
	}
	If(cat3 == 1) {
		action;
	}
}
If cat1 = 1, cat2 = 1, and cat3 = 1, it will do all actions for cat1, cat2, and cat3.
If cat1 = 0, cat2 = 1, and cat3 = 1, it will do all actions for cat2 and cat3.
If cat1 = 0, cat2 = 0, and cat3 = 1, it will do all actions for cat3.

If you have a script like this.

Code: Select all

Script 1 (void) {
	If(cat1 == 1) {
		action;
	}
	Else {
		If(cat2 == 1) {
			action;
		}
		Else {
			If(cat3 == 1) {
				action;
			}
		}
	}
}
If cat1 = 1, cat2 = 1, and cat3 = 1, it will only do the action for cat1.
If cat1 = 0, cat2 = 1, and cat3 = 1, it will only do the action for cat2.
If cat1 = 0, cat2 = 0, and cat3 = 1, it will only do the action for cat3.

Why? Because it reads straight down the list. If you are using ELSE statements, if the IF statement is True it will ignore anything in the ELSE statement.
Dr_Ian
Posts: 41
Joined: Wed Sep 07, 2005 4:19 pm
Location: Edinburgh

Post by Dr_Ian »

Wasted Youth wrote:This would work:
You are using a lot of surplus brackets. This is equivilent:

Code: Select all

Script 1 (void) {
	If(CheckWeapon("Shotgun")) {
		action;
	}
	Else If(CheckWeapon("PlasmaRifle")) {
		action;
	}
	Else If(CheckWeapon("RocketLauncher")) {
		action;
	}
}
User avatar
Wasted Youth
Posts: 358
Joined: Mon Jan 05, 2004 9:59 pm
Location: Earth

Post by Wasted Youth »

I know, I just like to do it that way. I like to have good order.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49223
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Post by Graf Zahl »

Dr_Ian's is better ordered. All paths are on the same level so more indentations only make it harder to read. ;)
Locked

Return to “Editing (Archive)”