Thread: Function visiblity and data
-
July 8th, 2021, 10:02 #1
Function visiblity and data
Hello everyone.
After a break due to work, I resumed experimenting and studying FGU. I have two questions to you who
are much more experienced than I am.
Question 1
I found a way to override a function, which is to regenerate it with the same name and use super. to
recall the old version without having to completely rewrite it. This way I can afford to add my own
code while continuing to keep the function updated if CoreRPG (for example) updates it.
Code:function A() super.A(); ... my code end
(blue -> old version - yellow -> new version).
Immagine1.png
The problem I have, however, arises when the old version of Func A calls Func B. In this case the behavior
it seems to me corresponds to this.
Immagine2.png
I would like this instead.
Immagine3.png
Do you think is there a way to get it? The only solution I find is to completely overwrite ()copy) the
old function without calling it, and I don't like it.
Question 2
The ruleset I'm trying to experiment on is full of data. I have inserted all data in special LUAs with
functions to extract the info I need. But what if I also want to create a manual? Should I replicate
the data in the relative XML or can I use a data extraction function (perhaps automatically generating
a table, if I need it)?
-
July 8th, 2021, 10:55 #2
Question 1: It all depends on how the old version of Function A calls Function B. If it calls it via a global script name <GlobalScript>.<function name> then you can override the function in the global script package. If it calls it within it's own scope, then there's not much you can do - other than replicating similar code in your new function A.
Question 2: It's best to put data in a module. Things like tables and other records that are accessed by users are best created in a module, not generated from LUA in a ruleset. You'll need to create a module for your reference manual and it's also recommended to put other usable data records in a module.Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
July 8th, 2021, 11:14 #3
Tnx for your answers.
Question 1: function B is called in the middle of old function A. Take utility\scrips\ponter_selection_v4.lua. In this file you'll find updateColors function.
As you can see some other function call it, so if I write a new version of updateColors i can add my code and call older version, but onInit() will still call
the older version.
I think the only solution is to replicate the file... I'm not happy. Each new version force me to verify and replicate it again, if needed.
Question 2: so my idea to throw all data in LUAs is an error? Good (not so much ) to know.
Ok, I'll have to migrate in XML
-
July 8th, 2021, 11:49 #4Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
July 8th, 2021, 14:00 #5
Nope, I was defining LUA tables for races, classes and so on. So, I think is better to translate them in XML.
Ty 4 all
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks