PDA

View Full Version : Using LUA Script from an Imported Ruleset



UrsaTeddy
April 21st, 2020, 06:19
Greetings,

So I am developing a ruleset and extends upon another ruleset.

I am using the <importruleset> tag to indicate the base ruleset. I do not want to rewrite anything of the original but rather extend or overwrite.

Two questions have cropped up (thus far) ...

1. How can I REQUIRE that the imported ruleset exists so that if it does not, this ruleset cannot be selected in the Create New Game.

2. Can I call functions that are inside the imported ruleset? For example if it has a function called RegisterNewAttribute, can I use that function somehow to register my own additional Attributes?

All help appreciated,
D

superteddy57
April 21st, 2020, 07:45
The import makes the ruleset code available. You can make calls to global scripts, use templates and also merge new code into already defined elements.If the imported ruleset doesnt exist, it would error out as it wont find the code your importing.

UrsaTeddy
April 21st, 2020, 09:56
The import makes the ruleset code available. You can make calls to global scripts, use templates and also merge new code into already defined elements.If the imported ruleset doesnt exist, it would error out as it wont find the code your importing.

Okay from what you stated, it seems that #1 is answered if not an elegant result for the user - but it is answered.

#2, however, I am not clear on. The ruleset has a specific function within one of its LUA scripts. I want to execute that function. I cannot just call it from my LUA script. So am I missing something?

Thanks in advance,
D

superteddy57
April 21st, 2020, 10:47
I honestly need more information on what you are trying to accomplish to give you a more detailed answer, as this could go in a few different ways. The quick answer as I am assuming it's a global script is to call it and the function using dot notation. (e.g ActorManager.getActor()). If it's not a global script, then that will require using the class it's attached to or pull the code and attach it in a new file to the ruleset. Again, these are broad strokes to answer your question as not many specifics are given.

UrsaTeddy
April 21st, 2020, 14:07
I honestly need more information on what you are trying to accomplish to give you a more detailed answer, as this could go in a few different ways. The quick answer as I am assuming it's a global script is to call it and the function using dot notation. (e.g ActorManager.getActor()). If it's not a global script, then that will require using the class it's attached to or pull the code and attach it in a new file to the ruleset. Again, these are broad strokes to answer your question as not many specifics are given.

Thanks again, I located the problem.

I accidentally set a namespace in my extension to the same namespace in the imported ruleset - thus the function was being "destroyed" and thus not available.

All working up to this point now.

Thank you again,
D