tobbe84 Posted March 5, 2012 Share Posted March 5, 2012 (edited) I'm trying to make a script to an armor which is supposed to add the actor to a faction when equipped and remove the actor from that faction when unequipped, but it isn't working. When I press Save, a little box tells me that a compilation failed. There is a message in the Compiler Output window that says "variable myfaction is undefined". How do I fix this? Edited March 5, 2012 by tobbe84 Link to comment Share on other sites More sharing options...
kromey Posted March 5, 2012 Share Posted March 5, 2012 To fix an undefined variable error, you define your variable. Guessing from what little context you've given us to work with (for future reference, please provide your script, or at least the relevant part of your script, for us to see what's going on), you want a faction property, so you'll need to add a line like this to your script:Faction property myfaction autoYou'll then have to use the Properties dialog in the CK to "hook up" your faction to this property, or you can change the name "myfaction" to match the name of the faction and leave the default value (it will default to the faction named the same as the property, if there is one). Link to comment Share on other sites More sharing options...
tobbe84 Posted March 5, 2012 Author Share Posted March 5, 2012 Here it is: Scriptname XXXXXX extends ObjectReference Event OnEquipped(Actor akActor) akActor.AddToFaction(YYYYYY)EndEvent Event OnUnEquipped(Actor akActor) akActor.RemoveFromFaction(YYYYYY)EndEvent (I guess the name of my script and faction is irrelevant, so I replaced it with XXXXXX and YYYYYY) Link to comment Share on other sites More sharing options...
kromey Posted March 5, 2012 Share Posted March 5, 2012 Yup, ahead of your first Event block (but after your Scriptname line) you'll need to declare your YYYYYY faction property:Faction property YYYYYY autoThen when you hook into this script in the CK, you'll have to open the Properties dialog and connect YYYYYY to the faction you want the armor to add the player to. Link to comment Share on other sites More sharing options...
tobbe84 Posted March 5, 2012 Author Share Posted March 5, 2012 Thanks a lot :) Link to comment Share on other sites More sharing options...
Korodic Posted March 5, 2012 Share Posted March 5, 2012 you do not need to physically writ the properties, there is a window for that as well. so YYYYY can be named anything and point to a specific object/faction(in this case) Link to comment Share on other sites More sharing options...
Recommended Posts