TangerineDog Posted September 29, 2017 Share Posted September 29, 2017 In one of my scripts, I put a conditional statement inside another conditional statement. No problems there. But in this scirpt, there's an if in an if in an if and it won't compile.When I reduce the ifs to one conditional statement within another, it works, but adding a third one breaks the script every time. Why? ScriptName HungerChangeScript extends activemagiceffectGlobalVariable Property HungerCount AutoGlobalVariable Property HungerCount1 AutoGlobalVariable Property HungerCount2 AutoGlobalVariable Property HungerCount3 AutoSpell Property SpellHunger01 AutoSpell Property SpellHunger02 AutoSpell Property SpellHunger03 Autoint Property HungerCountMod AutoEvent OnEffectStart(Actor akTarget, Actor akCaster)If akTarget == Game.GetPlayer()HungerCount.Mod(HungerCountMod)if HungerCount.GetValue() < HungerCount1.GetValue()If (Game.GetPlayer().HasMagicEffect(SpellHunger03))Game.GetPlayer().RemoveSpell(SpellHunger03)endifIf (Game.GetPlayer().HasMagicEffect(SpellHunger02))Game.GetPlayer().RemoveSpell(SpellHunger02)endifIf (Game.GetPlayer().HasMagicEffect(SpellHunger01))Game.GetPlayer().RemoveSpell(SpellHunger01)Debug.Notification("No more Hunger")endifelseif HungerCount.GetValue() < HungerCount2.GetValue()if HungerCount.GetValue() >= HungerCount1.GetValue()If (Game.GetPlayer().HasMagicEffect(SpellHunger03))Game.GetPlayer().RemoveSpell(SpellHunger03)endifIf (Game.GetPlayer().HasMagicEffect(SpellHunger02))Game.GetPlayer().RemoveSpell(SpellHunger02)endifIf (Game.GetPlayer().HasMagicEffect(SpellHunger01))Debug.Notification("Placeholder")ElseGame.GetPlayer().AddSpell(SpellHunger01)endifendifendifendifEndEvent Link to comment Share on other sites More sharing options...
agerweb Posted September 29, 2017 Share Posted September 29, 2017 You got 10 if's and 9 Endif's that might be something to do with it Link to comment Share on other sites More sharing options...
GSGlobe Posted September 29, 2017 Share Posted September 29, 2017 You should also replace game getplayer with PlayerRef Actor Property PlayerRef If akTarget = PlayerRef What i hear about IT is that its quicker. Link to comment Share on other sites More sharing options...
TangerineDog Posted September 29, 2017 Author Share Posted September 29, 2017 You got 10 if's and 9 Endif's that might be something to do with itOne endif is replaced by the elseif in the middle - that's fine in theory, right? Link to comment Share on other sites More sharing options...
IsharaMeradin Posted September 29, 2017 Share Posted September 29, 2017 Too many IF conditions doesn't make sense. I've gone at least 5 deep without issue. Also, your IF vs EndIF are correct. I copy/pasted to SublimeText where it shows lines when you indent and was able to line up each EndIf with an associating IF. Why not post the actual compiler error alongside the code you are attempting to compile? Link to comment Share on other sites More sharing options...
TangerineDog Posted September 29, 2017 Author Share Posted September 29, 2017 This is the full error text, the script is still the same. E:\SteamLibrary\steamapps\common\Skyrim\Data\scripts\Source>"E:\SteamLibrary\steamapps\common\Skyrim\Papyrus Compiler\PapyrusCompiler" E:\SteamLibrary\steamapps\common\Skyrim\Data\scripts\Source\HungerChangeScript.psc -f="TESV_Papyrus_Flags.flg" -i="E:\SteamLibrary\steamapps\common\Skyrim\Data\Scripts\Source" -o="E:\SteamLibrary\steamapps\common\Skyrim\Data\Scripts"Starting 1 compile threads for 1 files...Compiling "HungerChangeScript"...E:\SteamLibrary\steamapps\common\Skyrim\Data\scripts\Source\HungerChangeScript.psc(17,25): type mismatch on parameter 1 (did you forget a cast?)E:\SteamLibrary\steamapps\common\Skyrim\Data\scripts\Source\HungerChangeScript.psc(20,25): type mismatch on parameter 1 (did you forget a cast?)E:\SteamLibrary\steamapps\common\Skyrim\Data\scripts\Source\HungerChangeScript.psc(23,25): type mismatch on parameter 1 (did you forget a cast?)E:\SteamLibrary\steamapps\common\Skyrim\Data\scripts\Source\HungerChangeScript.psc(29,26): type mismatch on parameter 1 (did you forget a cast?)E:\SteamLibrary\steamapps\common\Skyrim\Data\scripts\Source\HungerChangeScript.psc(32,26): type mismatch on parameter 1 (did you forget a cast?)E:\SteamLibrary\steamapps\common\Skyrim\Data\scripts\Source\HungerChangeScript.psc(35,26): type mismatch on parameter 1 (did you forget a cast?)No output generated for E:\SteamLibrary\steamapps\common\Skyrim\Data\scripts\Source\HungerChangeScript.psc, compilation failed.Batch compile of 1 files finished. 0 succeeded, 1 failed.Failed on E:\SteamLibrary\steamapps\common\Skyrim\Data\scripts\Source\HungerChangeScript.pscE:\SteamLibrary\steamapps\common\Skyrim\Data\scripts\Source>pause Link to comment Share on other sites More sharing options...
IsharaMeradin Posted September 29, 2017 Share Posted September 29, 2017 Line 17: If (Game.GetPlayer().HasMagicEffect(SpellHunger03)) You are checking to see if the player has a magic effect but you are using a spell. You need to add properties for the actual effects you need to be checking for and change these statements to look for said effects rather than spells Link to comment Share on other sites More sharing options...
TangerineDog Posted September 29, 2017 Author Share Posted September 29, 2017 That did it!Thanks for looking it over! Link to comment Share on other sites More sharing options...
Recommended Posts