Manipulating quest variables from outside script.

Post » Sun Jun 17, 2012 7:46 pm

Hey, I tried following the instructions here:

http://www.creationkit.com/Variables_and_Properties#Getting_Properties_of_a_quest_script

But I keep getting a
no viable alternative at input '='
error.

Here are my two scripts...

The quest script.
Scriptname PMExtInebriationQuestScript extends QuestInt property InebriationLevel autoImageSpaceModifier property Drunk1 autoImageSpaceModifier property Drunk2 autoImageSpaceModifier property Drunk3 autoImageSpaceModifier property Drunk4 autoEvent OnReset()InebriationLevel = 0RegisterForUpdate(1)EndEventEvent OnUpdate()Drunk1.Remove()Drunk2.Remove()Drunk3.Remove()Drunk4.Remove()If (InebriationLevel>0 && InebriationLevel<3)  Drunk1.Apply()EndIfIf (InebriationLevel>=3 && InebriationLevel<4)  Drunk2.Apply()EndIfIf (InebriationLevel>=4 && InebriationLevel<6)  Drunk3.Apply()EndIfIf (InebriationLevel>=6 && InebriationLevel<8)  Drunk4.Apply()EndIfEndEvent

The outside script.
Scriptname PMExtIncreaseInebriation extends ActiveMagicEffectInt Property AlcoholLevel AutoPMExtInebriationQuestScript property myQuest automyQuest = GetOwningQuest() as PMExtInebriationQuestScriptEvent OnEffectStart(Actor akTarget, Actor akCaster)If (akTarget == Game.GetPlayer())  myQuest.InebriationLevel += AlcoholLevelEndIfEndEvent
User avatar
Brooke Turner
 
Posts: 3319
Joined: Wed Nov 01, 2006 11:13 am

Post » Sun Jun 17, 2012 5:20 pm

When exactly do you get the error? when you compile one of the scripts?
User avatar
James Wilson
 
Posts: 3457
Joined: Mon Nov 12, 2007 12:51 pm

Post » Sun Jun 17, 2012 1:36 pm

Do you have to set the myQuest property from inside your script for some reason? Why not just select it from the properties window?

If you do have to set it from inside the script for some reason, are you sure that you can use GetOwningQuest() on a magic effect? The creation kit only lists it for Aliases, Packages, Scenes and TopicInfos. If you're sure it works for magic effects, I guess you can try adding parentheses for the casting:
myQuest = (GetOwningQuest() as PMExtInebriationQuestScript)
User avatar
Jhenna lee Lizama
 
Posts: 3344
Joined: Wed Jun 06, 2007 5:39 am

Post » Sun Jun 17, 2012 8:04 pm

Just throwing this out there, I'm a total noob with this new scripting, but shouldn't you be using == instead of just = in scripts? Or did they change it? :shrug:
User avatar
Charles Mckinna
 
Posts: 3511
Joined: Mon Nov 12, 2007 6:51 am

Post » Sun Jun 17, 2012 4:10 pm

We'll need to know what line your script is failing at. Your "no viable alternative at input =" issue is a simple syntax problem.

My guess is this is where your problem is, based on my knowledge of other scripting languages. I'm not sure that += is a typo or what.


 myQuest.InebriationLevel += AlcoholLevel
User avatar
Vahpie
 
Posts: 3447
Joined: Sat Aug 26, 2006 5:07 pm

Post » Sun Jun 17, 2012 3:35 pm

"+=" is another valid assignment operator. The line you posted is essentially shorthand for this:[code]myQuest.InebriationLevel = myQuest.InebriationLevel + AlcoholLevel[/url]

As mentioned by others, and in the stickied "http://www.gamesas.com/topic/1347469-how-to-ask-for-scripting-help/" thread, when you're experiencing compiler errors please post the entire script and the entire compiler output. That line and character number information prevents us from having to look through your script line by line for what's usually a simple syntax error.

In this case the error is that you're trying to initialise the property "PMExtInebriationQuestScript" in the script "PMExtIncreaseInebriation" to a non-literal outside of a function. You can't do that. Both variables declared outside of function bodies and properties can only be initialised to http://www.creationkit.com/Literals_Reference.

Cipscis
User avatar
Aman Bhattal
 
Posts: 3424
Joined: Sun Dec 17, 2006 12:01 am


Return to V - Skyrim