Cacodemon
Register | User Profile | Member List | F.A.Q | Privacy Policy | New Blog | Search Forums | Forums Home
Doomworld Forums : Powered by vBulletin version 2.2.5 Doomworld Forums > Classic Doom > Doom Editing > ACS help: LockedExecute
 
Author
All times are GMT. The time now is 15:39. Post New Thread    Post A Reply
Khorus
Strife!


Posts: 1378
Registered: 04-05


Hello helpful programmer genius types,

I want a switch to lower a floor while requiring the Oracle Key to do so. The script compiler complains that the "else" line in the following code is an invalid statement. I'm completely hopeless when it comes to anything code related, so any help here would be wunderbar! :D

code:
script 5 (void) { ACS_LockedExecute(6,0,6,0,15); } script 6 (void) { if (CheckInventory("OracleKey")) Print(s:"The way is open."); { Floor_LowerToLowest(15,14); } else Print(s:"You require the Oracle Key."); }

Old Post 11-06-12 14:53 #
Khorus is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
Gez
Why don't I have a custom title by now?!


Posts: 10683
Registered: 07-07



Khorus said:
Hello helpful programmer genius types,

I want a switch to lower a floor while requiring the Oracle Key to do so. The script compiler complains that the "else" line in the following code is an invalid statement. I'm completely hopeless when it comes to anything code related, so any help here would be wunderbar! :D

code:
script 5 (void) { ACS_LockedExecute(6,0,6,0,15); } script 6 (void) { if (CheckInventory("OracleKey")) Print(s:"The way is open."); { Floor_LowerToLowest(15,14); } else Print(s:"You require the Oracle Key."); }



Your "Print(s:"The way is open.");" is not in the curly-brace block. Therefore, it is the only thing executed conditionally. The block that comes after (with Floor_LowerToLowest()) is executed inconditionally, so it would always happen. It's "detached" from the if.

When you arrive at the else, it is no longer connected to the if, so it invalid.

The fix is simply to move the Print line inside the block.

Old Post 11-06-12 15:09 #
Gez is offline Profile || Blog || PM || Search || Add Buddy IP || Edit/Delete || Quote
Khorus
Strife!


Posts: 1378
Registered: 04-05


@Gez: Heeey, that worked just great! Much props! :D

One issue is that the switch is animating and playing the activation noise despite the player not having the key on them. Can anything be done about that?

Old Post 11-06-12 15:32 #
Khorus is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
Gez
Why don't I have a custom title by now?!


Posts: 10683
Registered: 07-07


What special does your switch linedef have?

From what I understand, you have script 5 that calls script 6 to run if the player has the Order key (key type 15).

If the script runs, there's no reason for the animation not to play.

Old Post 11-06-12 15:47 #
Gez is offline Profile || Blog || PM || Search || Add Buddy IP || Edit/Delete || Quote
Khorus
Strife!


Posts: 1378
Registered: 04-05



Gez said:
What special does your switch linedef have?

From what I understand, you have script 5 that calls script 6 to run if the player has the Order key (key type 15).

If the script runs, there's no reason for the animation not to play.



Action 80 "Script Execute". So the line action is triggered regardless if the player has the key or not. Not a huge deal, I can explain it away in the "key required" message.

Yes, that's correct. :)

Old Post 11-06-12 16:16 #
Khorus is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
Gez
Why don't I have a custom title by now?!


Posts: 10683
Registered: 07-07


Something you can do if you want the switch not to animate if the player does not have the key: use special 84:ACS_ExecuteWithResult. Then, in the script that is directly run by the linedef (so, script 5), have this:

code:
if (!(CheckInventory("OracleKey"))) { SetResultValue(0); }


So the script will be considered to have failed if the player does not have the key.

Old Post 11-06-12 16:27 #
Gez is offline Profile || Blog || PM || Search || Add Buddy IP || Edit/Delete || Quote
Khorus
Strife!


Posts: 1378
Registered: 04-05


That worked perfectly, thanks again. :)

Old Post 11-06-12 16:32 #
Khorus is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
All times are GMT. The time now is 15:39. Post New Thread    Post A Reply
 
Doomworld Forums : Powered by vBulletin version 2.2.5 Doomworld Forums > Classic Doom > Doom Editing > ACS help: LockedExecute

Show Printable Version | Email this Page | Subscribe to this Thread

 

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are OFF
[IMG] code is ON
 

< Contact Us - Doomworld >

Powered by: vBulletin Version 2.2.5
Copyright ©2000, 2001, Jelsoft Enterprises Limited.

Message Board Statistics