DICE PACKS BUNDLE

Thread: data_common.lua

  1. #1
    Varsuuk's Avatar
    Join Date
    Dec 2015
    Location
    New York
    Posts
    2,075

    data_common.lua

    What guides the choice of putting things in one place or another.

    For 5E, there are many maps/arrays defined "globally" outside of a function. This is followed by an "onInit()" method where other maps are defined but one thing they all have in common is a call to "Interface.getString("XXXX")" - Not sure why they would be separated as not sure when "onInit()" would be called for a file vs control "scope"?

    For the AD&D Core, Celestian adds variables empty declares outside of onInit() then onInit() populates the maps vs trying to declare nested maps in one "=" assignment? Is that the only reason to have the empty declare then onInit() splitup?

    Just hit adding my own data lookups and wanted to know how to design what goes where

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,362
    Quick answer - Interface.getString is used to allow translation of the GUI. Allowing just the string XML files to be changed to translate the GUI to a different language.
    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!

  3. #3
    Varsuuk's Avatar
    Join Date
    Dec 2015
    Location
    New York
    Posts
    2,075
    Yup, I use that everywhere. When I started in the business I used to work on a client GUI app for Pager/Cellular Carriers (Notify!) and I had set it up for easy (... well debugging the Traditional Chinese one was really rough, Portuguese was not as bad) translation using string resources in Visual C++.

    My question was why is some of the code in that file in the onInit() method and the rest not. Not sure why the onInit() was needed in DataCommon.lua. Not >challenging< this - I really am just unexperienced to know and I am creating my own such file so I want to know rule of thumb and rationale for putting in "global scope" or "function scope (of a global vs control script)"

    The only thing I saw to distinguish in 5E one was that all in onInit() called Interface.getString() - that was the common part of every assignment in onInit(). In AD&DCore - no such commonality existed.

    So was looking for insight.

  4. #4
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,362
    Quote Originally Posted by Varsuuk View Post
    The only thing I saw to distinguish in 5E one was that all in onInit() called Interface.getString() - that was the common part of every assignment in onInit(). In AD&DCore - no such commonality existed.
    I'm not sure what you're saying here - in data_common.lua in both 5E and AD&D Core the Interface.getString API function is only used in the onInit function, not outside of it.

    Quote Originally Posted by Varsuuk View Post
    My question was why is some of the code in that file in the onInit() method and the rest not. Not sure why the onInit() was needed in DataCommon.lua.
    I haven't tested it, but I'm guessing that Interface.getString will only work as part of code that runs, not a static LUA table record definition (outside of onInit).

    There is only the need for Interface.getString within the LUA table records defined in data_common.lua if there is data that might need to be translated. Looking at 5E, this is: class names, skill names, party sheet ability and skill drop-down names.
    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!

  5. #5
    Varsuuk's Avatar
    Join Date
    Dec 2015
    Location
    New York
    Posts
    2,075
    The needing to be once “loaded” (I’m not hep to terminology) via onInit() for the Interface is what I guessed from that being the common thread to ALL the lines in 5e’s onInit().

    If that was the only thing I looked at, I’d assume that and walk away.

    Was then wondering in AD&D, he has a variety of array assignments in onInit(). Now that first part seems verified, why were these put in onInit(). Random/style choice or also, like Interface, needs to have something “loaded” before it was valid to assign these? So, I get Interface - why in AD&D are other things there?


    But I guess that’s likely only something Celestian will easily answer if he sees this. He IS a busy (super) bee hard at work making yumminess

  6. #6

    Join Date
    Jun 2013
    Location
    Isanti, MN
    Posts
    2,922
    Because he needed them initialized at the beginning of a session...

  7. #7
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,362
    Quote Originally Posted by Varsuuk View Post
    Was then wondering in AD&D, he has a variety of array assignments in onInit(). Now that first part seems verified, why were these put in onInit(). Random/style choice or also, like Interface, needs to have something “loaded” before it was valid to assign these? So, I get Interface - why in AD&D are other things there?
    If you look closely at the entries that don't have getString commands in onInit in the AD&D ruleset - these are all setting a LUA table record to be blank - where in 5E these all had getString assignments - the 5E code remains in the LUA file, but is commented out.

    This empty LUA table doesn't have to be here (in onInit), it could be in the main section of the LUA script (outside of onInit). But, it makes more sense to put the code right by the commented out code - so that when people look at this they see the commented out code and the new blank table. In theory, reducing confusion and random questions! ;-)

    It's purely ascetics and a decision celestian made in the code. Don't try to over analyze it!
    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!

  8. #8
    Varsuuk's Avatar
    Join Date
    Dec 2015
    Location
    New York
    Posts
    2,075
    Thanks

    Yeah, I know - I overanalyze things.
    But in 7 years, no outages on a Financial Exchange Server I code (last 5, solo) and maintain *knocks on head*

    I like to understand things as I pass them - I think it comes from all the old RogueSix/Battlefield 2 tourney games - I learned never to advance without clearing all corners and leave unopened doors at your back.

    Troof.


    But yeah, that's what I wanted to grokk - in case there was a reason - I am more feeling my way through with Lua then a qualified Lua guy

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Product Walkthrough Playlist

Log in

Log in