Am i using this wrong

Post » Tue Jun 19, 2012 5:50 am

Im trying to make an alternative traveling system in skyrim, which i got got working mostly but i have one problem.
i want the player not be able to use it while he's overcumberd, so i use this script.

Scriptname actorvaluebugtest extends ObjectReferencefloat maxcarryweight = game.getplayer().getactorvalue("Carryweight") as floatfloat currentcarry = game.getplayer().getactorvalue("Inventory") as floatevent onactivate(objectreference akactivator)if currentcarry > maxcarryweight  debug.show("Travel")else  debug.show("Dont travel")endifendevent

im my eyes this should work fine but the comiler gives these errors

Starting 1 compile threads for 1 files...Compiling "actorvaluebugtest"...c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\actorvaluebugtest.psc(3,23): no viable alternative at input 'game'c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\actorvaluebugtest.psc(3,27): required (...)+ loop did not match anything at input '.'c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\actorvaluebugtest.psc(3,6): Unknown user flag gamec:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\actorvaluebugtest.psc(4,21): no viable alternative at input 'game'c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\actorvaluebugtest.psc(4,25): required (...)+ loop did not match anything at input '.'c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\actorvaluebugtest.psc(4,6): Unknown user flag gameNo output generated for actorvaluebugtest, compilation failed.Batch compile of 1 files finished. 0 succeeded, 1 failed.Failed on actorvaluebugtest

i tried getting the actor in a spererate variable first but that also doest seem to work.
i think i might be using game.getplayer() wrong but i dont think so since it uses it the same on the wiki.
i realy hope someone want to take a look at this since it is realy buging me.
User avatar
Jordan Moreno
 
Posts: 3462
Joined: Thu May 10, 2007 4:47 pm

Post » Tue Jun 19, 2012 4:38 pm

Non-declarative code can only exist within the body of a function (including events), and this includes the initialisation of variables. Variables declared outside of a function body can only be initialised with a http://www.creationkit.com/Literals_Reference.

Instead, use an http://www.creationkit.com/OnInit event to initialise your variables.

Cipscis
User avatar
El Goose
 
Posts: 3368
Joined: Sun Dec 02, 2007 12:02 am


Return to V - Skyrim