GrimGrim31 Posted March 16, 2021 Share Posted March 16, 2021 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 = 0MilkthePrettyCow()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 commentScriptname GrimGrim31:Fragments:MilkTheCow Extends ActiveMagicEffectMiscObject Property MilkBottleEmpty AutoPotion Property _MY_CowMilk AutoActorValue Property _MY_CowMilkedTime AutoActorValue Property _MY_CowMilkedDaily Auto;BEGIN FRAGMENTEvent OnEffectFinish(Actor akTarget, Actor akCaster)Int NoMilkForYou = 0CheckTime() ; Resets allowable number of daily milkings if it is a new day and checks the last time the cow was milkedEndEventFunction CheckTime();BEGIN CODEDebug.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 + 1SetValue (_MY_CowMilkedDaily, 0) ; Resets the number of allowable milkings for the cow for a new dayElseif NowNow < _MY_CowMilkedTime + 0.167Debug.Notification("This cow was milked less than four hours ago.")NoMilkForYou = 1Elseif Game.GetTargetActor()._MY_CowMilkedDaily >= 4Debug.Notification("This cow cannot be milked again today.")NoMilkForYou = 1EndifIf NoMilkForYou = 0MilkthePrettyCow()EndifEndFunctionFunction MilkthePrettyCow()Game.GetPlayer().RemoveItem(MilkBottleEmpty, 1, false) ; Removes one empty milk bottle from the player's inventoryGame.GetPlayer().AddItem(_MY_CowMilk, 1, false) ; Adds one bottle of Cow milk to the player's inventoryGame.GetTargetActor().SetValue(_MY_CowMilkedTime, Utility.GetCurrentGameTime()) ; Assigns the current game time as an actor valueGame.GetTargetActor().ModValue(_MY_CowMilkedDaily, 1) ; Adds one to the actor value for number of times the cow is milked that dayDebug.Notification("Milk the Pretty Cow function was called.");END CODEEndFunction;END FRAGMENT;END FRAGMENT CODE - Do not edit anything between this and the begin comment Link to comment Share on other sites More sharing options...
niston Posted March 16, 2021 Share Posted March 16, 2021 If (NoMilkForYou == 0) MilkthePrettyCow()EndIf A single = is for assignment: Int variableA = 1Float variableB = 2.5 Two equal signs == is for equality comparison. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted March 16, 2021 Share Posted March 16, 2021 (edited) 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 March 16, 2021 by IsharaMeradin Link to comment Share on other sites More sharing options...
GrimGrim31 Posted March 16, 2021 Author Share Posted March 16, 2021 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 More sharing options...
niston Posted March 16, 2021 Share Posted March 16, 2021 It's probably not you - I can't even create an account on the wiki. Link to comment Share on other sites More sharing options...
SKKmods Posted March 16, 2021 Share Posted March 16, 2021 To be fair its already in there https://www.creationkit.com/index.php?title=Operator_Reference But, its the unknown unknowns if your not aware that Logical, Comparison and Assignment operators can (must!) be different. Link to comment Share on other sites More sharing options...
Zorkaz Posted March 16, 2021 Share Posted March 16, 2021 The server that handles the wiki activation might just be dead. There's an old thread about this. Link to comment Share on other sites More sharing options...
AnishaDawn Posted March 18, 2021 Share Posted March 18, 2021 It's probably not you - I can't even create an account on the wiki.My IP got banned there from simply trying to create one. O_o Link to comment Share on other sites More sharing options...
Recommended Posts