Need help fetching variable from a separate script

Post » Wed Feb 19, 2014 9:04 am

Topic. I kind of do and kind of don't understand what I'm supposed to do to get this to work, but just as an example:

FredUtilScr Property FredSlime Auto

This should work to access the script FredUtilScr. And later on,

x = FredSlime.GetNeatThings(akActor)

should work to run that function (GetNeatThings) in script FredUtilScr and return the resulting value as x. I get it. In fact, these are basically lines ripped from a preexisting script from an entirely different mod which already makes use of FredUtilScr. My problem is that putting either of those lines in my script results in no compile. Fair enough, I tell myself, maybe CE wants me to load up the relevant .esm / .esp etc. Nope, that doesn't cut it either. I'm missing something important here, and as is often the case, the CE wiki seems to be written more or less from the assumption that folks have a much better foundation (say, from years and years of Elder Scrolls modding).

That's question #1. Why won't it compile when I add a line which ostensibly just references a script or function external to my script?

Question #2 is related: I assume I won't have to specifically slave my mod to anything besides Skyrim.esm. I'm trying to make it so my mod checks for the existence of mod#2, and if it finds it, fine, it tries instituting FredSlime, but if it doesn't find it, it instead does functions which do not rely upon FredUtilScr. The idea is that the user may or may not have/want mod#2. If I slave my mod to mod#2, then the user will have to also use mod#2 or things won't work. Is that about right or am I way off base?

User avatar
tiffany Royal
 
Posts: 3340
Joined: Mon Dec 25, 2006 1:48 pm

Post » Wed Feb 19, 2014 8:23 pm

I see you haven't figured out how to talk to your compiler yet ;)

In any case, my best guess is probably that FredUtilScr.psc doesn't exist in your Data\scripts\Source folder. It will need to be there in order for you to compile a script referring to it. You may have to unpack it from the other mod's .bsa

And re: Question 2, that'll work fine. You can use GetFormFromFile or GetModByName to check for the other mod's existence first, and then just do something like

FredUtilScr FredSlime = game.getFormFromFile(0x00abcd, "Fred'sMod.esp") as FredUtilScrFredSlime.GetNeatThings(akActor)
User avatar
Matthew Warren
 
Posts: 3463
Joined: Fri Oct 19, 2007 11:37 pm

Post » Wed Feb 19, 2014 5:19 pm

I was hoping that would have ended up being the problem, but it still doesn't compile, even with the script in the correct location. And a particular mystery is that once in a while (like the first time I try it after loading up CE), it actually does compile without complaint (this was before I put the script in that directory, too). But then if I compile once more, right after it just got through succeeding, it fails. I think.. I'll just ignore that anomaly and assume it wasn't supposed to work. Anyway, no dice on placement of script. Edit: Looks like it just didn't like where I was referencing the script. Now I'd rather just know if the script is going to cause someone's PC to explode if I reference another script that isn't there, since apparently I don't have a choice.

And re: Question 2, that'll work fine. You can use GetFormFromFile or GetModByName to check for the other mod's existence first

Actually, what I was after was whether or not it would be required to slave my mod to the other mod in order to successfully compile with references to said mod's scripts (so far, it hasn't made a difference one way or the other), and whether, if so, that would mean that another user of my mod would need to install the mod I slaved to, even if the script ultimately doesn't call on it.

, and then just do something like

>FredUtilScr FredSlime = game.getFormFromFile(0x00abcd, "Fred'sMod.esp") as FredUtilScr
>FredSlime.GetNeatThings(akActor)
The script I'm looking at doesn't have this function (game.getFormFromFile). Is it needed, or will "FredUtilScr property FredSlime auto" suffice?
User avatar
Etta Hargrave
 
Posts: 3452
Joined: Fri Sep 01, 2006 1:27 am

Post » Thu Feb 20, 2014 1:06 am

Well, in order to use "FredUtilScr property FredSlime auto" and fill that property in the CK, you will indeed have to "slave" your mod to Fred's mod by adding it as a master to yours, and requiring your users to download it. The Game.GetFormFromFile() apporach allows you to retrieve the reference from Fred's mod without including it as an explicit master to your file.

Regarding the compile error, if it still doesn't work with FredUtilScr.psc in the correct directory, then you will probably need to figure out how to read your compiler errors before I can help you with that one :turned:

User avatar
Adrian Morales
 
Posts: 3474
Joined: Fri Aug 10, 2007 3:19 am

Post » Wed Feb 19, 2014 6:44 pm

Actually, I'm looking at the CK compiler again (I don't usually use it, since I have Sublime Text set up to compile papyrus), and I notice there's a "View" option on the upper toolbar, and you can check the option to view "Output" which then displays the compiler errors on the bottom of the window after building. For me it always popped up by default, but maybe you need to explicitly choose that option for some reason -- worth giving it a try :)

User avatar
Miss Hayley
 
Posts: 3414
Joined: Tue Jun 27, 2006 2:31 am


Return to V - Skyrim