Jump to content

Script Compile Error: No Viable Alternative at Input =


Recommended Posts

I have a script for milking a cow that won't compile. The error message is "No Viable Alternative at Input =" and it refers to the If statement below:

 

If NoMilkForYou = 0
MilkthePrettyCow()
Endif

 

Is there a problem calling a function within an If statement? I am still very new at Papyrus.

 

I put the entire script in a spoiler below just in case the problem lies outside of the If statement.

 

Any help is appreciated.

 

 

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
Scriptname GrimGrim31:Fragments:MilkTheCow Extends ActiveMagicEffect

MiscObject Property MilkBottleEmpty Auto
Potion Property _MY_CowMilk Auto
ActorValue Property _MY_CowMilkedTime Auto
ActorValue Property _MY_CowMilkedDaily Auto

;BEGIN FRAGMENT
Event OnEffectFinish(Actor akTarget, Actor akCaster)
Int NoMilkForYou = 0
CheckTime() ; Resets allowable number of daily milkings if it is a new day and checks the last time the cow was milked
EndEvent

Function CheckTime()
;BEGIN CODE
Debug.Notification("CheckTime function called.")
Float NowNow = Utility.GetCurrentGameTime()
Debug.Notification("The current time is: " + Utility.GetCurrentGameTime() + " in game days passed")

If NowNow > Game.GetTargetActor()._MY_CowMilkedTime + 1
SetValue (_MY_CowMilkedDaily, 0) ; Resets the number of allowable milkings for the cow for a new day
Elseif NowNow < _MY_CowMilkedTime + 0.167
Debug.Notification("This cow was milked less than four hours ago.")
NoMilkForYou = 1
Elseif Game.GetTargetActor()._MY_CowMilkedDaily >= 4
Debug.Notification("This cow cannot be milked again today.")
NoMilkForYou = 1
Endif

If NoMilkForYou = 0
MilkthePrettyCow()
Endif

EndFunction

Function MilkthePrettyCow()
Game.GetPlayer().RemoveItem(MilkBottleEmpty, 1, false) ; Removes one empty milk bottle from the player's inventory
Game.GetPlayer().AddItem(_MY_CowMilk, 1, false) ; Adds one bottle of Cow milk to the player's inventory
Game.GetTargetActor().SetValue(_MY_CowMilkedTime, Utility.GetCurrentGameTime()) ; Assigns the current game time as an actor value
Game.GetTargetActor().ModValue(_MY_CowMilkedDaily, 1) ; Adds one to the actor value for number of times the cow is milked that day
Debug.Notification("Milk the Pretty Cow function was called.")
;END CODE
EndFunction

;END FRAGMENT

;END FRAGMENT CODE - Do not edit anything between this and the begin comment

 

Link to comment
Share on other sites

niston has demonstrated the correction that you need.

 

For the future you may want to keep the following in mind...

 

When you want compare the thing on the left with the thing on the right you would use:

== the two things need to be the same

>= the thing on the left is greater than or equal to the one on the right

<= the thing on the left is less than or equal to the one on the right

!= the thing on the left is not equal to the one on the right

 

When you want to assign a value to a variable you would use:

= makes the thing on the left have the same value as what is on the right

-= reduces the thing on the left by the value of what is on the right

+= increases the thing on the left by the value of what is on the right

 

 

 

 

EDIT: Adjustment needed, added text in italics

Edited by IsharaMeradin
Link to comment
Share on other sites

Thank you both! I was able to compile the script (after correcting many more errors identified by the compiler) and was able to move forward and add new functions. It works great now.

 

I will add your explanations to my scripting notes. You explain this much better than Creation Kit's wiki. I would edit the Wiki but it won't let me. Something about it not recognizing that I have an account. Maybe it's a Windows 10 thing.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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