Frictional Games Forum (read-only)
Refrencing script libraries? - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Refrencing script libraries? (/thread-14558.html)



Refrencing script libraries? - Homicide13 - 04-06-2012

I know for scripting languages you can generally (read: always) build your own libraries of functions that can then be referenced from other scripts, and I was wondering if it is possible to do this kind of this with the level scripting for the hpl2 engine. I don't really know anything about AngelScript beyond what I've used to script levels with, but I have a list of function declarations that I would like to put into a library and have added to the script function list. Is this possible at all, or am I eternally doomed to copy and paste my list of functions into every script hps file?

Also as a bonus question, is it ok to have script below the "OnStart""OnEnter" and "OnLeave" functions? I remember from way back when when I tried to teach myself some cpp, I remember something about the order which functions are declared being important, but I don't really remember what these rules were exactly, so if someone could refresh my memory and tell me whether or not they apply to my dear hps files (though I assume that they would).



RE: Refrencing script libraries? - palistov - 04-06-2012

AngelCode has the keyword import, but I wasn't able to get it to work. Importing a function would let me call it, but it wouldn't do anything. Since AngelCode, like C++, ignores whitespace, you can delete all your return characters (newline characters) and compress your script into a single line once you're done writing it. That way when you copy and paste it over to another map, it doesn't take up a huge amount of screen space. Just be sure to make a comment so you know what that line of code does.

And yes, there's no requirement as to the order of the functions.


RE: Refrencing script libraries? - Your Computer - 04-06-2012

http://www.frictionalgames.com/forum/thread-12023.html

FYI, import only works if the module already exists. However, you cannot (AFAIK) create your own modules in HPL2.


RE: Refrencing script libraries? - Homicide13 - 04-06-2012

Sad sad day. Oh well, thanks a lot for the help!