Jump to content


Photo

Parsing error... again...


  • Please log in to reply
4 replies to this topic

#1 Andrea C.

Andrea C.
  • Modder
  • 457 posts

Posted 20 July 2021 - 06:32 AM

Welcome to another episode of, "What is wrong with my code?"

 

ACTION_FOR_EACH creature IN ~amnis~ ~amnis2~ ~amnis3~ ~amnis4~ ~amnise~ ~amnise2~ ~amsleep~ ~dead2~ ~deadfuck~ ~hick~ BEGIN
		ACTION_IF (FILE_EXISTS_IN_GAME ~%creature%.cre~) AND (MOD_IS_INSTALLED ~nostalgiapack.tp2~ (ID_OF_LABEL ~nostalgiapack.tp2~ "ac-bg-spritesns")) OR (MOD_IS_INSTALLED ~nostalgiapack.tp2~ (ID_OF_LABEL ~nostalgiapack.tp2~ "ac-bg-sprites")) THEN BEGIN
			COPY_EXISTING ~%creature%.cre~ ~override~		
					WRITE_LONG 0x28 0x5600
				END ELSE BEGIN
			COPY_EXISTING ~%creature%.cre~ ~override~		
					WRITE_LONG 0x28 0x6100
				END
			BUT_ONLY
		END

 

Any idea why this chokes on BUT_ONLY?
 


 



#2 Argent77

Argent77
  • Administrator
  • 1397 posts

Posted 20 July 2021 - 07:59 AM

BUT_ONLY has to come before END since END belongs to the higher level ACTION_IF construct.
 
There also seems to be a potential issue with the ACTION_IF condition. It uses AND and OR to combine three individual conditions. You have to take care about precedence though. AND has a higher prededence than OR. Currently it will always evaluate to true if the last MOD_IS_INSTALLED condition is true, regardless of the other two conditions. It can be fixed by enclosing the latter two conditions in parentheses.


Edited by Argent77, 20 July 2021 - 08:00 AM.


#3 Andrea C.

Andrea C.
  • Modder
  • 457 posts

Posted 20 July 2021 - 08:41 AM

Thank you, Argent.

 

Looking better like this?

 

ACTION_FOR_EACH creature IN ~amnis~ ~amnis2~ ~amnis3~ ~amnis4~ ~amnise~ ~amnise2~ ~amsleep~ ~dead2~ ~deadfuck~ ~hick~ BEGIN
		ACTION_IF (FILE_EXISTS_IN_GAME ~%creature%.cre~) AND ((MOD_IS_INSTALLED ~nostalgiapack.tp2~ (ID_OF_LABEL ~nostalgiapack.tp2~ "ac-bg-spritesns")) OR (MOD_IS_INSTALLED ~nostalgiapack.tp2~ (ID_OF_LABEL ~nostalgiapack.tp2~ "ac-bg-sprites"))) THEN BEGIN
			COPY_EXISTING ~%creature%.cre~ ~override~		
					WRITE_LONG 0x28 0x5600
				BUT_ONLY
			END ELSE BEGIN
			COPY_EXISTING ~%creature%.cre~ ~override~		
					WRITE_LONG 0x28 0x6100
				BUT_ONLY
			END
		END


 



#4 Argent77

Argent77
  • Administrator
  • 1397 posts

Posted 20 July 2021 - 08:56 AM

Yes, looks fine now.



#5 Andrea C.

Andrea C.
  • Modder
  • 457 posts

Posted 20 July 2021 - 08:59 AM

Thanks again.