Jump to content

No viable alternative at input "If"


Mayfly53

Recommended Posts

IsharaMeradin, thank you for all your efforts so far. I'm not sure how to create functions. I did some research and tried, but unfortunately it gave me a ridiculous amount of errors. I've never created nor called custom functions before.

 

Scriptname MercCuirassCheckScript extends ObjectReference

Armor Property MercCuirassProperty auto
Armor Property ArmorCuirass auto

Function PlayerCheck()

If akActor == Game.GetPlayer()
	Unequip(akActor)
Else
	GoToState("Empty")
EndIf

EndFunction

Function Unequip()

If akActor.WornHasKeyword(ArmorCuirass) && !akActor().WornHasKeyword(MercCuirassProperty)
	akActor.UnequipItem(self)
EndIf

EndFunction

Event OnEquipped(Actor akActor)

PlayerCheck(akActor)

EndEvent

Link to comment
Share on other sites

They are keywords:

 

http://i.imgur.com/SgBfQ.jpg

 

It's still the same error. I think it's something to do with having an If statement inside a state.

Then I must be blind. :blink:

Armor Property MercCuirassProperty auto
Armor Property ArmorCuirass auto

 

 

If you want to work with states, try this:

 

Scriptname MercCuirassCheckScript extends ObjectReference
;put this script on the chest armor piece

Armor Property MercCuirass auto  	;link this to the leg armor piece
Keyword Property ArmorCuirass auto      ;can be auto-filled

State Equipped
Event OnEquipped(Actor akActor)
	If akActor == Game.GetPlayer() && !akActor.IsEquipped(MercCuirass) && akActor.WornHasKeyword(ArmorCuirass)
		akActor.UnequipItem(self)
		GoToState("Unequipped")		
       endif
EndEvent
Event OnUnequipped(Actor akActor)
	If akActor == Game.GetPlayer() && !akActor.IsEquipped(self)
		GoToState("Unequipped")
	endif
EndEvent
EndState

auto State Unequipped
Event OnEquipped(Actor akActor)
       If akActor == Game.GetPlayer() && akActor.IsEquipped(self)
		GoToState("Equipped")
	endif
EndEvent
EndState

Link to comment
Share on other sites

Thank you so much for the effort, it compiles perfectly (and even better, I understand what you did), but there is no effect in game. I wonder if there is any way to script an armour piece lying on an unused slot so that it gets unequipped the same as if it were on the body slot.
Link to comment
Share on other sites

This compiles without error... whether or not it works, I have no clue. I also changed the scriptname for testing purposes

Scriptname AA_TEST extends ObjectReference

Keyword Property MercCuirassProperty auto
Keyword Property ArmorCuirass auto

Function PlayerCheck(Actor akActor)
       If akActor == Game.GetPlayer()
               Unequip(akActor)
       Else
               ;do nothing
       EndIf
EndFunction

Function Unequip(Actor akActor)
       If akActor.WornHasKeyword(ArmorCuirass) && !akActor.WornHasKeyword(MercCuirassProperty)
               akActor.UnequipItem(self)
       EndIf
EndFunction

Event OnEquipped(Actor akActor)
       PlayerCheck(akActor)
EndEvent

Link to comment
Share on other sites

your statements for the IF are not on the same line as the IF.

 

also akActor = Game.GetPlayer() tells the game to make akActor have the same value as Game.GetPlayer()

whereas akActor == Game.GetPlayer() tells the game to check if akActor does have the same value as Game.GetPlayer()

 

that said your script needs adjust in the following manner

 

Scriptname MercCuirassCheckScript extends ObjectReference

Armor Property MercCuirassProperty auto
Armor Property ArmorCuirass auto

Event OnEquipped(Actor akActor)
       GoToState("PlayerCheck")
EndEvent

State PlayerCheck
       If  akActor == Game.GetPlayer()
                       GoToState("Unequip")
       Else
               GoToState("Empty")
       EndIf
EndState

State Unequip
       If  akActor.WornHasKeyword(ArmorCuirass) && !akActor().WornHasKeyword(MercCuirassProperty)
                       akActor.UnequipItem(self)
       EndIf
EndState

 

 

Um, no.

 

a) you haven't put any function blocks in the STATES so the script won't work. You need to add an event such as OnBeginState or Equip or Unequip to each state block.

b) empty state is not called "empty", it is called "".

Link to comment
Share on other sites

This compiles without error... whether or not it works, I have no clue. I also changed the scriptname for testing purposes

Scriptname AA_TEST extends ObjectReference

Keyword Property MercCuirassProperty auto
Keyword Property ArmorCuirass auto

Function PlayerCheck(Actor akActor)
       If akActor == Game.GetPlayer()
               Unequip(akActor)
       Else
               ;do nothing
       EndIf
EndFunction

Function Unequip(Actor akActor)
       If akActor.WornHasKeyword(ArmorCuirass) && !akActor.WornHasKeyword(MercCuirassProperty)
               akActor.UnequipItem(self)
       EndIf
EndFunction

Event OnEquipped(Actor akActor)
       PlayerCheck(akActor)
EndEvent

 

Um... :facepalm:

 

This does EXACTLY the same thing:

 

Scriptname AA_TEST extends ObjectReference

Keyword Property MercCuirassProperty auto
Keyword Property ArmorCuirass auto

Event OnEquipped(Actor akActor)
       If akActor == Game.GetPlayer() && (akActor.WornHasKeyword(ArmorCuirass) && !akActor.WornHasKeyword(MercCuirassProperty))
               akActor.UnequipItem(self)
       EndIf
EndEvent

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...