GimmeBackMyMoney Posted August 29, 2017 Share Posted August 29, 2017 I made some changes to the Water Purifier script from Tales From The Burning Sands (a copy of the entire script can be found here: https://pastebin.com/LMiBDS5Z). This was to get it to work with Arwen's as well as purify irradiated water. I want to draw attention to this block under OnActivate: if PurInstalled == 0 if player.getitemcount IrradiatedWaterUnpurified >= 4 player.removeitem IrradiatedWaterUnpurified 4 1 player.additem ArwenEmptyDirtyWaterBottle 3 aaq1waterspray.enable set x1 to 1 else if player.getitemcount ArwenWaterDirty >= 3 player.removeitem ArwenWaterDirty 3 1 player.additem ArwenEmptyDirtyWaterBottle 2 aaq1waterspray.enable set x1 to 1 else if player.getitemcount WaterUnpurifiedHalf >= 4 player.removeitem WaterUnpurifiedHalf 4 1 player.additem ArwenEmptyGoodWaterBottle 3 aaq1waterspray.enable set x1 to 1 else if player.getitemcount WaterUnpurified >= 2 player.removeitem WaterUnpurified 2 1 player.additem ArwenEmptyGoodWaterBottle 1 aaq1waterspray.enable set x1 to 1 endif endif When I have at least three ArwenWaterDirty in my inventory, this block executes properly. However, if I have no ArwenWaterDirty and any number of Good Waters (base game's Dirty/Unpurified Water), the code ALWAYS executes the second if block i.e. I get two empty dirty water bottles while the amount of Good Water remains unchanged, INSTEAD of getting a single empty good water bottle and having the total count of Good Water decrementing by 2. I added a few debug lines to the second block to print out how many ArwenWaterDirty I have and it returns 0, yet it would appear this condition is evaluating as true regardless. Could anyone help me, even if it involves making me look stupid and pointing out an obvious error I've made? Because it's driving me batty. Thanks in advance. Link to comment Share on other sites More sharing options...
Mktavish Posted August 29, 2017 Share Posted August 29, 2017 (edited) The scripting problem that jumps out at me ... Is "else" & "If" should not be separated. It should be "elseIf" Or elseif , eLseIF, ElsEiF, ... the case of the letters matter not. But one word does. Because remember Else and IF can be used separately ... hence confusing the code crunching engine. Edited August 29, 2017 by Mktavish Link to comment Share on other sites More sharing options...
GimmeBackMyMoney Posted August 29, 2017 Author Share Posted August 29, 2017 ...and it's worked a treat. You're a champ, thanks for pointing that out. I couldn't remember whether or not you were supposed to put a space in between them, and assumed it would be parsed as the same as long as the "else" and "if" are on the same line because I never got any GECK errors. Now I'll have to go through all other scripts I've created and edited, but this will explain some of the peculiar behaviour I've encountered. Thanks again! Link to comment Share on other sites More sharing options...
dubiousintent Posted August 29, 2017 Share Posted August 29, 2017 Suggest you consider using the (free) "Notepad++" as your editor with "NotepadPlusPlus Syntax Highlighter" by DoctaSax as an imported "user defined language" addon. That will catch most similar syntax errors automatically for you. It will also popup a list of suggested keywords as you start to type, which you can select and then add with the <tab> key. -Dubious- Link to comment Share on other sites More sharing options...
Mktavish Posted August 30, 2017 Share Posted August 30, 2017 I couldn't remember whether or not you were supposed to put a space in between them, and assumed it would be parsed as the same as long as the "else" and "if" are on the same line because I never got any GECK errors. No ... never a space When else and if are to be used together ... always use "elseif" Other wise its just useing "else" by itself "IF" ofcourse is definitely used by itself , and must be !!! Link to comment Share on other sites More sharing options...
Mktavish Posted August 30, 2017 Share Posted August 30, 2017 IF MyX == 1 ; Do Something ... Link to comment Share on other sites More sharing options...
Mktavish Posted August 30, 2017 Share Posted August 30, 2017 Else is used after an IF Like ... IF MyX=1 Do thiselse Activate Link to comment Share on other sites More sharing options...
Mktavish Posted August 30, 2017 Share Posted August 30, 2017 (edited) ElseIf is used when there are multi things that happen after X = 1 ElseIf X= 2 Do thisElseIf X=3 Do thatElseIf X=7 Go F U self See , it is various outcomes. Edited August 30, 2017 by Mktavish Link to comment Share on other sites More sharing options...
GimmeBackMyMoney Posted August 30, 2017 Author Share Posted August 30, 2017 Yeah, my understanding was you never put a space in between else and if, I guess I didn't think much of it this time because it got past the GECK's syntax checks. That NP++ feature will come in handy so thanks for linking that, dubious. Thank you both for the help. Link to comment Share on other sites More sharing options...
Recommended Posts