kert349 Posted December 22, 2010 Share Posted December 22, 2010 (edited) Hianyone know why this script doesnt work? in dialog i have this script: ref self set self to GetSelf self.addScriptPackage 11BaseTargetPractice1 ; --- Ok self.evp ; --- Ok set self.changePackages to 2 ; --- Compiler error!!!!!!!!!!!!! changePackages doesnt exist? (its is defined in the script file) set someGuyRef.changePackages 2 ; ---- this would WORK but i cant use it, need to use via GetSelf Whats up with that "self.changePackages" ?only "someGuyRef.changePackages" works.... Edited December 22, 2010 by kert349 Link to comment Share on other sites More sharing options...
Glenstorm Posted December 22, 2010 Share Posted December 22, 2010 (edited) Hianyone know why this script doesnt work? in dialog i have this script: ref self set self to GetSelf self.addScriptPackage 11BaseTargetPractice1 ; --- Ok self.evp ; --- Ok set self.changePackages to 2 ; --- Compiler error!!!!!!!!!!!!! changePackages doesnt exist? (its is defined in the script file) set someGuyRef.changePackages 2 ; ---- this would WORK but i cant use it, need to use via GetSelf Whats up with that "self.changePackages" ?only "someGuyRef.changePackages" works.... I'm quite new to this myself, but I think self is a Compiler exclusive keyword. It's marked in blue color font like "ref". Try changing it to another name - not necessarily someGuyRef. Just change self to mySelf or something like that in the code above - and that includes the variable declaration. Edited December 22, 2010 by Glenstorm Link to comment Share on other sites More sharing options...
davidlallen Posted December 22, 2010 Share Posted December 22, 2010 (edited) This code is a little confusing. There are some assumptions you are making about object oriented languages and "self" which are not true for oblivion/FNV scripting. Many existing functions require a reference object to act upon; for example, "CastImmediateOnSelf" is normally used as "xyz.cios foo". The "xyz" is the reference object, and "foo" is the spell effect. Whenever a script is triggered, it occurs on some game object like a creature. Think about this as the "default" object. Any function which takes a reference object can be used without a reference object, in which case it uses the default object. So the following works, but is redundant: ref x begin ... set x to GetSelf x.cios foo The following is equivalent and much easier to understand: begin ... cios foo (EDIT: which, by the way, is stated explicitly on the geck webpage of getself.) It is possible that "self" is a keyword; it is a keyword in many object oriented languages, but I would not conclude too much from the fact that some external text editor uses syntax highlighting for it. It is unlikely (but possible) that the editor understands the exact keywords of the oblivion/FNV scripting language. Still, it is worthwhile to use nothing, if possible, or another word which is less likly to cofuse other readers. Now let us discuss your specific lines of code: set self.changePackages to 2 set someGuyRef.changePackages 2 It isn't clear if changePackages is a variable you have defined in the script. I assume so, because I can't find it in any geck or oblivion function listing. In that case, you must already have this line somewhere at the top of your script file: short changePackages The first line of code will not work because "self" refers to the object, not the script. To refer to the variable, just write set changePackages to 2 The second line of code will not work because (a) changePackage is a local variable only; you cannot refer to the variable in some other instance; and (b) the keyword "to" is missing.I hope that helps. Edited December 22, 2010 by davidlallen Link to comment Share on other sites More sharing options...
kert349 Posted December 22, 2010 Author Share Posted December 22, 2010 (edited) The proplem isnt the word "self". i changed it but still doesnt work. What im trying to do is script same way companions script variables are changed through dialog. Take a look cass' variables related for companion wheel orders Edited December 22, 2010 by kert349 Link to comment Share on other sites More sharing options...
kert349 Posted December 22, 2010 Author Share Posted December 22, 2010 (edited) think i found the problem...http://geck.bethsoft.com/index.php/GetSelf says: "GetSelf will return 0 if called on a reference that has been created dynamically (for example, created via PlaceAtMe, or dropped from an inventory into the game world). " though that should happen in runtime. not while in geck...but now i know ths method wouldnt work.. Edited December 22, 2010 by kert349 Link to comment Share on other sites More sharing options...
rickerhk Posted December 22, 2010 Share Posted December 22, 2010 Is this a dialog result script? You don't want to be defining variables there at all. Link to comment Share on other sites More sharing options...
llamaRCA Posted December 22, 2010 Share Posted December 22, 2010 In addition to what RickerHK said about defining variables in a dialogue results script, what are you trying to do? I think there is a very much more straightforward way to do this. Also, you don't want to evp after you do an AddScriptPackage. Script packages just drop on the NPC and don't live in their NPC packages list. So what happens is they do their thing and when the script package is done the NPC will evp back onto the first package whose conditions meet its current condititons. Usually that's the package they were on before you dropped that Script Package on them (well let's go with that anyway things could change in the interim, but let's say they could go back to the package they were on and you can plan for that and watch for it, etc). If you do the ScriptPackage thing and then evp the NPC you will force the ScriptPackage to end prematurely because the NPC will evaluate its packages right away and go through its list of packages and the Script Package isn't there so it's gonna draw from the list and end up on an entirely different package than you want. :) llama Link to comment Share on other sites More sharing options...
kert349 Posted December 23, 2010 Author Share Posted December 23, 2010 thx for all the info! what im doing is that i remove all the script packages when i want the NPC (followers) to follow me or do something special. then later i put the sandbox packages pack Link to comment Share on other sites More sharing options...
HugePinball Posted December 23, 2010 Share Posted December 23, 2010 ref self set self to GetSelf self.addScriptPackage 11BaseTargetPractice1 ; --- Ok self.evp ; --- Ok set self.changePackages to 2 ; --- Compiler error!!!!!!!!!!!!! changePackages doesnt exist? (its is defined in the script file) set someGuyRef.changePackages 2 ; ---- this would WORK but i cant use it, need to use via GetSelf Whats up with that "self.changePackages" ?only "someGuyRef.changePackages" works....Alright, I've never really worked with Actors and Packages, so I can only point out the structural problems with your script (not whether it will do what you want). First as RickerHK said, you shouldn't define variables within result scripts. If you need variables there, either use globals, quest script variables, or persistent object script variables. But the second thing is you DON'T need a "self" variable here. You're in a dialog result script, so the actor reference that GetSelf would return is already the implicit reference. So instead of: self.AddScriptPackage 11BaseTargetPractice1...you should just be calling: AddScriptPackage 11BaseTargetPractice1 Next, by the way you're trying to use it I'm assuming that changePackages is a variable defined in the script of the base Actor used by someGuyRef (and someGuyRef is a persistent RefID). Maybe it was at this point you thought you needed the "self" variable in order to set a variable on the actor in dialog, but you can't use a variable in this syntax: set self.changePackages to 2It needs to be a persistent RefID (like someGuyRef ) or an EditorID (like a quest EID if it was a quest script variable). I didn't actually know this because I never tried using a ref variable in that way, but Cipscis says so and I trust him ;). So how to change that variable on that actor ref? The most straightforward way is to use its persistent reference ID. Again, I haven't done much with actors, but I thought that's generally what you had to do (don't all the NPCs have placed refs somewhere?). If you're trying to make followers that are dynamically spawned or something (not sure if you can really do that), you'd have to go about it in a more complicated way, like launching a quest script from that dialog result script or something. Also, in your last line you're missing a "to". ... It's marked in blue color font like "ref".The coloring you see here has nothing to do geck script. It's a feature of the forum's code tag and I'm not sure what language based on (I think C). We should really get that disabled because it's not useful here and slows down page rendering. Link to comment Share on other sites More sharing options...
kert349 Posted December 24, 2010 Author Share Posted December 24, 2010 (edited) Is this a dialog result script? You don't want to be defining variables there at all. why not? does the ref fail at runtime? Also, you don't want to evp after you do an AddScriptPackage. Script packages just drop on the NPC and don't live in their NPC packages list. So what happens is they do their thing and when the script package is done the NPC will evp back onto the first package whose conditions meet its current condititons. Usually that's the package they were on before you dropped that Script Package on them (well let's go with that anyway things could change in the interim, but let's say they could go back to the package they were on and you can plan for that and watch for it, etc). If you do the ScriptPackage thing and then evp the NPC you will force the ScriptPackage to end prematurely because the NPC will evaluate its packages right away and go through its list of packages and the Script Package isn't there so it's gonna draw from the list and end up on an entirely different package than you want. im actually clearning the whole package list if i want the NPC to follow me as companion instead of hanging out. is there no " remove all packages " command? Edited December 24, 2010 by kert349 Link to comment Share on other sites More sharing options...
Recommended Posts