Jump to content
RobertaME

(Mod) AMPS Development Thread

785 posts in this topic Last Reply

Highlighted Posts

Posted:
Last Online:  
 
1 minute ago, RobertaME said:

Yeah... I see that too. Maybe try to split the difference... so they're at the median point between the two extremes?

Or not! Seriously, these look GREAT as-is and are most assuredly good enough for a mod that is still partially broken.

On that front, I have managed to re-assemble 95% of the LUA code related to building access. (i.e. which buildings are available based on grid construction) Now I just have to fix the loadbalance.lua and I can do my alpha release! (only a week late... good thing I never went into programming like I wanted to when I was little... I'd have been fired a dozen times over!)

That is great news.

Don't be so hard on yourself. You are going wonderful things. Hard work doesn't come easy. 

  • Thanks 1

Kloudkicker
Life's cold and I'm chillin
Kloudkicker's Lot Creations
Kloudkicker's Tech Tools, News and More

 

Share this post


Link to post
Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    3 hours ago, Kloudkicker said:

    Don't be so hard on yourself. You are going wonderful things. Hard work doesn't come easy. 

    Thanks! I'm just disappointed in myself... it's a rookie mistake and I know better. I'm better now that I have most of it fixed. ;^)

    • Like 1

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    I have five reloted substations ready for review from two separate mods . There are a lot of objects added and a lot of LODs to fight. I think I was able to get almost all the objects to line up right. About three or four objects that are going to have to be the way they are in one view angle were it is off slightly or covered a little.

    I am writing up the depends list and will PM someone the files and the depends list needed, if you have the time to review them. I could nit pick them for a while. But I need to stop somewhere, and these look cool as heck right now. 

    If not, should turn them in for further modifications of the settings @RobertaME?

    • Like 1

    Kloudkicker
    Life's cold and I'm chillin
    Kloudkicker's Lot Creations
    Kloudkicker's Tech Tools, News and More

     

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    @RobertaME

    This will be my last post here in your thread and I'll unfollow it as well. I do realize you feel strongly that everything to know about Lua in the game was already discovered, but the tone of your reply just doesn't sit well with me. I do get the gist of it ofc. Put up or shut up. So, here's what I had in mind:

    Considering how brilliant your mod is and that others might like to follow in your footsteps with similar creations for other utilities, I feel that each one needing to override the same _constants.lua entry would have the potential to inadvertently cause overlap (or stepping on each other's toes if you will) sometime in the future.

    While it was prolly already discovered long ago (and I never found info about it), there are 4 layers of SC4 memory which the Lua code can access. The two of interest for this project are what CB and I call the System level and the Game level. As you've correctly stated, the game level lua cannot directly access the tables created and loaded at the system level.

    My proposal is to override _package_startup.lua (entry CA63E2A3-4A5E8F3F-FF823A6D) to use it like a table of contents for calling your code to add to the track_buildings table. Should anyone else later wish to use your method to add realism to the game, they could add their entry there so _constants.lua remains untouched. This method still allows your code to insert entries in the table and also be actual human readable (and tweakable) text in a file in Plugins.

    The location of my added code is after the dofile("_config.lua"); line. This works because there is a chain of dofile commands such that when control is returned to this module the _constants.lua has been called and run.

    Contents of the code in FF823A6D Lua Startup Override.dat (also attached in a zip later in this post).

    --#-package:00000001#
    --
    -- _package_startup.lua
    --
    -- This is the entry point for the automata scripts when they are read as resource
    -- files.  It initializes the dofile() mechanism and then loads _config.lua, the standard
    -- entry point.
    --
    
    -- re-assign "dofile" in scripts to the published function _dofile_from_resource
    if (rawget(globals(), "_dofile_from_resource") ~= nil) and
         (rawget(globals(), "__old_dofile") == nil) then 
       __old_dofile = dofile                        -- set this so that _system.lua doesn't try to overwrite dofile again
       dofile = _dofile_from_resource
    end
    
    -- then include the main entry point
    dofile("_config.lua");
    
    -- ^ End Maxis original code
    ----------------------------
    
    -- Start Cori code to load external Lua file
    --------------------------------------------
    
    -- Set up path to Plugins Folder
    --------------------------------
        local cmTmpProfile = os.getenv("USERPROFILE")
        local cmUserDir = string.gsub(cmTmpProfile, "(\\)", "/")
        local cmPluginFolder = cmUserDir .. "/My Documents/SimCity 4/Plugins/"
    
    -- Get Lua code from external file
    ----------------------------------
        loaded_chunk = loadfile(cmPluginFolder .. "Tracked Power Grid Buildings.lua")
    
    -- Execute the complied Lua script
    ----------------------------------
        loaded_chunk()
    
    
    -- The following will create a text file in the SimCity 4 folder to show the contents
    --  of the track_buildings table.
    
    -- Delete all below for actual release as peeps won't want a new text file each time
    --  they load a city tile.
    
    -- 2021.02.18 - Output text file of Table
    -----------------------------------------
    
    -- Default Output Location
    --------------------------
        local cmUserDir = os.getenv("USERPROFILE")
        local cmOutputPath = cmUserDir .. [[\My Documents\SimCity 4\]]
    
    -- Squish the file name parts together and run the requested report
        local Unique = os.time()
        local cmTheFile = cmOutputPath .. "CoriBoom Runtime Report - " .. Unique .. ".txt"
    
    -- Open file and output data
    ----------------------------
        local exist = io.open(cmTheFile) --open file overwriting if exists
        local cmDateTime = os.date()
        io.output(cmTheFile)
        io.write("-----------------------------------","\n")
        io.write("File output as: ",cmTheFile,"\n")
        io.write("DateTime stamp: ",cmDateTime,"\n")
        io.write("-------------------------------------","\n\n")
        io.write(" * * * Content of track_buildings Table * * *\n\n")
    
        io.write("\nTABLE = track_buildings","\n---------------------------\n")
        for i,v in pairs(track_buildings) do 
          local t = type(v)
          io.write(t,": ")
          io.write(i)
          if (t == "string" or t == "number") then
            io.write(" = ",v,"\n")
          end
          if (t == "userdata") then
            if (v ~= nil) then
              io.write(" = ",tostring(v),"\n")
            else
              io.write(" = nil","\n")
            end
          end
          if (t == "function") then
            cmTestTable = {}
            cmTestTable = debug.getinfo(v)
            TableList = tprint(cmTestTable)
            io.write(TableList, "\n\n")
          end
          if (t == "table") then
            local p1, p2 = string.find(tostring(i),"track_buildings",plain)
            if (p1 ~= nil) then
              io.write("\np1 = ",p1,"\n")
            end
            if (p2 ~= nil) then
              io.write("p2 = ",p2,"\n")
            end
            if (p1 == nil and p2 == nil) then
              TableList = tprint(v)
              io.write(TableList, "\n\n")
            end
          end
        end
        io.write("\n\n")
    
    -- Close out file
    -----------------
        io.flush()
        io.close()
    
    --Recursively Serialize Tables written by Luiz Menezes (then minor tweaks by me)
    -- Original public code: https://stackoverflow.com/questions/41942289/display-contents-of-tables-in-lua
    function tprint (tbl, indent)
        if not indent then indent = 0 end
        local toprint = string.rep(" ", indent) .. "{\n"
        indent = indent + 2 
        for k, v in pairs(tbl) do
          toprint = toprint .. string.rep(" ", indent)
          if (type(k) == "number") then
            toprint = toprint .. "[" .. k .. "] = "
          elseif (type(k) == "string") then
            toprint = toprint  .. k ..  " = "   
          end
          if (type(v) == "number") then
            toprint = toprint .. v .. "\n"
          elseif (type(v) == "string") then
            toprint = toprint .. "\"" .. v .. "\"\n"
          elseif (type(v) == "table") then
            toprint = toprint .. tprint(v, indent + 2) .. "\n"
          else
            toprint = toprint .. "\"" .. tostring(v) .. "\"\n"
          end
        end
        toprint = toprint .. string.rep(" ", indent-2) .. "}"
        return toprint
    end

    ^ The bulk of that is for debugging and can be deleted before release. It's labeled as such in a comment.

    What the debugging part does is create a text file into the SimCity 4 folder which will show the contents of the track_buildings table after your code adds to it. The first number is the array subscript and the second is the actual data it contains. There is more code than needed as I copied if from a more elaborate memory analysis program we wrote, but I left it there in case you wish to explore other System level tables. *;)

    There are two files in the attached zip. Drop both in Plugins (in Documents) and not in a sub folder. (If you want them in a sub folder, you can change the second part of the cmPluginFolder = variable to reflect that.)

    SC4 Lua Test for Power Grid.zip

    • Like 1
    • Thanks 1

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    @CorinaMarie

    I read your post hours ago. I wanted to react then, but I had other obligations to my family.

    Once they were all in bed, I spent the next hour crying. I'm going to try and do this as dispassionately as I can.

    12 hours ago, CorinaMarie said:

    I do realize you feel strongly that everything to know about Lua in the game was already discovered, but the tone of your reply just doesn't sit well with me.

    I know NOTHING about LUA in this game compared to you. I've seen your code and you make me look like a monkey slapping keys. The only things I know are what I can glean from other people's work. I'm not a programmer. I've stated that several times. I'm a semi-retired Statistical Data Analyst who played with programming when she was 15... a lifetime ago. I'm also HORRIBLE at expressing myself, and have said so in this thread repeatedly. Now you're the 2nd person who I've (unintentionally) irritated enough to walk away from this project with enough vigor that you had to make a public statement of the fact.

    This is MY fault... because I'm HORRIBLE at communication, I drive people away. I have NO IDEA what you mean by "the tone of your reply"... HONESTLY. No clue.

    12 hours ago, CorinaMarie said:

    I do get the gist of it ofc. Put up or shut up.

    I do not have one iota of a clue how you got that from "If you know a way to do this". I was being SERIOUS. I'm an idiot with an idea and a vague understanding of program logic. Everything I know about this game's workings I learned from reading your work and the work of others before you.

    So... I'm done.

    I quit.

    If anyone wants to pick up this project and take it over... feel free to use anything you see here and I wish you better luck. Maybe someone more qualified can do it without alienating every important person here.

    I want to say "delete this thread", but someone might find something useful in the important people's replies to my idiotic blather.


      Edited by RobertaME  

    Remove lock request
    • Sad 3

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    @@RobertaME,

    You are amazing for even trying. I wish you would not give up. Even if this means starting over. With a new way of looking at it, who knows what could come about of it. 

    I was afraid of this happing after you read the message. I am very sorry you feel this way. And I wish you would take the time to think this over, once you can collect your thoughts. This has real potential, and others are looking forward to seeing something like this develop.

    Please think about this further.

    Sincerely,

    Kloudkicker


    Kloudkicker
    Life's cold and I'm chillin
    Kloudkicker's Lot Creations
    Kloudkicker's Tech Tools, News and More

     

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Oh dear. :O

    This has suddenly taken a drastic sharp turn in a direction that none of us ever wanted to happen. *:(


    @RobertaME

    The way I see this, it's all a matter of perspective.

    As we chat on a regular basis, I know Cori was quite upset herself after reading your reply initially. Simply making a humble suggestion there might be another way with the Lua coding to help you, Cori felt you were dismissing her as wrong. So to recap, and here's how I personally see the way your words came across...


    (Emphasis mine in red for highlighting key words.)

    13 hours ago, RobertaME said:
    19 hours ago, CorinaMarie said:

    Are you planning for your Lua code to be replacement overrides for those two Maxis Lua entries?

    I feel it'd really be better to make yours standalone so then they can work with any other Lua and not fight with them. Ofc, if you need to override specific instances of code like advisor triggers and messages, you can still do that on a selected basis.

    In order to track building counts, the same way the BSC Essentials does, WITHOUT stealing 512 of the 4095 BSC Occupant Groups, I have to override the _constants.lua, the exact same way that the BSC Essentials does (just AFTER it, so my mod steals it after BSC Essentials does) to alter the track_buildings array. Since a major dependency does this, I didn't see an issue. I've tried several options, but I'm guessing that Daeley determined the same thing I have. You have to do it this way to work.

    ...

    If you can think of a way to add 512 lines to the track_buildings array that actually WORKS without stealing the _constants.lua, I'd love to hear it.

     

    Breaking this down individually:

    • The first sentence up to the "_constants.lua" which comes across as saying there is no other way and to let Cori know this too.
    • Then the "You have to do it this way to work." is again telling Cori she made a bad suggestion, due to implying her idea has no ground.
    • Wrapping it up with "If you can think of a way ... that actually WORKS ..." is the put up or shut up part.
    • Ending with "I'd love to hear it." at that point feels sarcastic after the preceding.

     

    So in this way, it's seen as instructing Cori and denouncing her suggestion as pointless. Using the ALL CAPS certainly doesn't help the tone either. Also if there was doubt about this, asking for help rather than dismissing a prospective idea would've prevented what happened next. This is the way it came across from our vantage point, and we'll take your word for it that this wasn't intentional. Now whether the intention behind written words are meant or not, they still hold face value as interpreted.


    The thing is, one of the shortfalls with text-based communication is the tone can so easily be lost. Written words can easily be misinterpreted regardless of intention. That means others may read what's said and get a completely different idea of not only the apparent meaning, but the underlying purpose behind it. This is how it unfolded here, because even though you didn't want to cause this to spiral out of control, it's sadly what has transpired.

    Now I'm typing this at some crazy daft hour and hoping that all this can be resolved peacefully. Cori did not want this outcome, nor did I or anyone here. She wanted to help you with additional usefulness with the Lua code from her own experiences. We wanted to see your powerful power project come to fruition. You've progressed so far with it now, and have the support of us and also the entire community here. None of us want you to give up.

    All this has resulted from is words as written to be seen a certain way as they were. We saw it one way, and then you looked at it from your own shoes differently. This is the result of the commotion here, and leading to what is an entirely undesirable outcome now. It's all very sad is this indeed.

    Now please, all we wish to do now is press the reset button or something. Again, this is not what any of us want for you calling it quits. It is of course your decision, but for a fact many people in the community have recognised your contributions to this project already. Over 7 pages and almost 200 posts is a rare thing for a new topic to acquire so quickly. You absolutely are intelligent, and doing a very good job with your power project. At least from Cori's and my own viewpoint, we feel you've made no "idiotic blather" in the slightest. Quite the contrary in fact, and all this was merely how your previous points came across to Cori and me at the time.

    So we're not making an issue of this any further, and it can be chalked down as a messy miscommunication.

    -CB & Cori

     

    Finally I'll need to wear my Admin hat for this last part:

    This topic shall remain open for now, however all discussion is to return to the subject and not this matter any further.


    Which calls for a line to be drawn under this:
     


     

    • Like 3
    • Thanks 4

    Quick Links

    “SimCity 4 is not just a game, but a tool driven by our own imagination and creativity.”

    Buy me a coffee

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    At this point, I don't think I can continue. I obviously don't know what I'm doing and in WAY over my head. Some key aspects of the code are STILL broken and I don't know why.

    If "the incident" (the thing we're not supposed to discuss any more per @Cyclone Boom) has brought anything to light, its that I DON'T know what I'm doing. I can't even understand why a simple line like "{variable} = sc4game.automata.get_source_building_count(hex2dec("{Occupant Group}"))" doesn't work, when I KNOW that sc4game.automata.get_source_building_count(hex2dec("{Occupant Group}")) works inside a later IF condition in the same LUA as a numeric value equal to the building count... but won't assign that numeric value to a variable.

    So... at this point I think the idea is dead. I'm obviously not qualified to continue it, at any rate. (just for clarification, so there are no further misunderstandings, this is NOT a flippant statement, but my own opinion of my lack of ability to solve key problems in the code)

    Comments welcome, for what it's worth.

    Edit: Ignore this... I was frustrated and despondent... but I'm NOT giving up. :^)


      Edited by RobertaME  

    Ignore This
    • Like 2
    • Thanks 2

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    There are many folks here that want to see this project success. You don't have to do it alone. This is an opportunity to learn from those that know how to code and I am sure that there are a few that would be happy to help. All you have to do is ask. You have already succeeded at the majority of what you wanted to accomplish. 

    Please don't give up.

    • Like 4
    • Yes 1
    • Thanks 1

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    1 hour ago, RobertaME said:

    At this point, I don't think I can continue. I obviously don't know what I'm doing and in WAY over my head. Some key aspects of the code are STILL broken and I don't know why.

    If "the incident" (the thing we're not supposed to discuss any more per @Cyclone Boom) has brought anything to light, its that I DON'T know what I'm doing. I can't even understand why a simple line like "{variable} = sc4game.automata.get_source_building_count(hex2dec("{Occupant Group}"))" doesn't work, when I KNOW that sc4game.automata.get_source_building_count(hex2dec("{Occupant Group}")) works inside a later IF condition in the same LUA as a numeric value equal to the building count... but won't assign that numeric value to a variable.

    So... at this point I think the idea is dead. I'm obviously not qualified to continue it, at any rate. (just for clarification, so there are no further misunderstandings, this is NOT a flippant statement, but my own opinion of my lack of ability to solve key problems in the code)

    Comments welcome, for what it's worth.

    Sorry to hear that, but I think simmer has given you some very valid advice. Sometimes a project can seem overwhelming especially when tackling it without a team. Taking a step back to get a more distant view and some perspective of your problem might help. There is no pressure and good things take time ;)

    • Like 4
    • Yes 2

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    I'm sad that it has gotten to this point Roberta, but I understand.  I enjoyed being able to follow this project (even if I only discovered your work at the very last day) and see the potential for this game's power system that you have brought to the surface, beyond even my wildest dreams.  Take care!

    • Like 2
    • Thanks 3

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    2 hours ago, RobertaME said:

    At this point, I don't think I can continue.

    How about we both reconsider our decisions? You really do have a grand concept here for bringing realism to the game.

     

    2 hours ago, RobertaME said:

    "the incident"

    Thank you so much for your heartfelt PM. I'll reply there separately as it'll be in ST's best interest for us to keep that to ourselves. (I feel we can work this out so we both understand what happened and move past this.)

     

    2 hours ago, RobertaME said:

    I can't even understand why a simple line like "{variable} = sc4game.automata.get_source_building_count(hex2dec("{Occupant Group}"))" doesn't work, when I KNOW that sc4game.automata.get_source_building_count(hex2dec("{Occupant Group}")) works inside a later IF condition in the same LUA as a numeric value equal to the building count... but won't assign that numeric value to a variable.

    This indicates to me that your project is still very much something you would like to work on and see it to completion because the difficulty related to a specific aspect of it is playing on your mind and you want a solution.

    From a coding perspective, it's generally a good idea to work with a minimal set of variables initially. What might be good to do is to work with just one specific power plant which responds to your load balancing code and which is dependent on the increasing count of one other particular lot. If we can get the foundation firmly established for this to work along with advisor messages and such, then that should help when adding more and more to expand it to the full package.

    Now, back to the Lua concept about overriding or standalone. (The idea itself.) My initial question was if you had planned to override Maxis Lua and I was more concerned about the Advisor triggers and messages and where your load balance code was going to go. The part about _constants.lua was a lesser concern, but one for which I believe we could do well to not overwrite.

    More specifically, I was wondering if you were planning to add to and release a new version of adv_utilities.lua. This was just a question and then if the answer was "yes", I then planned to show how that part can be its own package and also if any of the triggers / messages in the original need altered that can still be accomplished without having to change the Maxis code itself.

    I do hold @Daeley in very high regard because it was his code and his explanations which allowed me to understand some very key aspects of Lua coding for the game. From there I've studied and experimented and I believe I've discovered additional useful techniques which build upon his work. Also, because the BSC was the only mod then to utilize the track_buildings, it didn't conflict with any other override of that code. My plan was then to work with you to flesh out what might be a better method with the idea that your added realism concept would go well for other utilities and as such there could be more mods all needing to alter that same table. If we can create a method here in the beginning which allows for that, then it would make it easier for later additions along the same lines.

    • Like 6
    • Thanks 2

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    8 hours ago, Skyroguen said:

    Please don't give up.

    I've decided not to. I want to see this project finished. Thanks for not giving up on ME. ::hug::

    7 hours ago, Simmer2 said:

    If I may be so bold as to say, this is a classical case of burnout. Been there done that.

    Partially that, and partially a VERY poor choice of words on my part causing interpersonal issues... compounded by issues with the base LUA code that were frustrating me... all piling up at once into making me give up. I won't let it stop me, though. I WILL see this through.

    7 hours ago, AP said:

    Taking a step back to get a more distant view and some perspective of your problem might help. There is no pressure and good things take time

    Thanks! I put the pressure on myself as a motivator to get it done. I know no one else is DEMANDING this be done on a certain schedule. It'll take however long it takes... and I WON'T give up!

    7 hours ago, metarvo said:

    I'm sad that it has gotten to this point Roberta, but I understand.

    I will see this through... if for no other reason than to let people like you enjoy the fruits of the effort. Thanks for seeing the potential!

    5 hours ago, CorinaMarie said:

    How about we both reconsider our decisions? You really do have a grand concept here for bringing realism to the game.

    Thank you so much for your heartfelt PM. I'll reply there separately as it'll be in ST's best interest for us to keep that to ourselves.

    Agreed. :,^)

    5 hours ago, CorinaMarie said:

    This indicates to me that your project is still very much something you would like to work on and see it to completion because the difficulty related to a specific aspect of it is playing on your mind and you want a solution.

    From a coding perspective, it's generally a good idea to work with a minimal set of variables initially. What might be good to do is to work with just one specific power plant which responds to your load balancing code and which is dependent on the increasing count of one other particular lot.

    I DO... it's driving me NUTS that such a simple line of code refuses to parse and I DON'T understand why it won't. I've already boiled it down to just a single building, in this case a substation, to try and resolve the problem.

    For context, here is the basis of the code:

    --#-package:0BB35100# -- package signature
    
    -- This LUA written by RobertaME Feb 2021 --
    
    --------- unlocker functions and variables -----------
    
    ::snip::
    
    clean_intermediate_hex_id = {
       PV_PANEL_SET_36_KW = "490FF4A1",
       SOLAR_POWER_PLANT_533_KW = "690A0D1A",
       SOLAR_THERMAL_PLANT_2_5_MW = "1F440000",
       WIND_TURBINE_1_MW = "1F450000"
    }
    kva_rating = {
       ID_BB350010 = 25,      --Transformers--
       ID_BB350011 = 50,
    
    ::snip::
      
       ID_BB350020 = 500,     --Distribution Substations--
       ID_BB350021 = 1000,
       ID_BB350022 = 2000,
    
    ::snip::
       
       ID_BB3500EE = 0
    }
    TRANSMISSION_RATING = 0
    SMALL_PLANTS_RATING = 0
    DISTRIBUTION_RATING = (sc4game.automata.get_source_building_count(hex2dec("BB350020"))*kva_rating.ID_BB350020)
    -- Removed for testing -- + (sc4game.automata.get_source_building_count(hex2dec("BB350021"))*kva_rating.ID_BB350021) + (sc4game.automata.get_source_building_count(hex2dec("BB350022"))*kva_rating.ID_BB350022) + (sc4game.automata.get_source_building_count(hex2dec("BB350023"))*kva_rating.ID_BB350023) + (sc4game.automata.get_source_building_count(hex2dec("BB350024"))*kva_rating.ID_BB350024) + (sc4game.automata.get_source_building_count(hex2dec("BB350025"))*kva_rating.ID_BB350025) + (sc4game.automata.get_source_building_count(hex2dec("BB350026"))*kva_rating.ID_BB350026) + (sc4game.automata.get_source_building_count(hex2dec("BB350027"))*kva_rating.ID_BB350027) + sc4game.automata.get_source_building_count(hex2dec("BB350028"))*kva_rating.ID_BB350028) + (sc4game.automata.get_source_building_count(hex2dec("BB350029"))*kva_rating.ID_BB350029) + (sc4game.automata.get_source_building_count(hex2dec("BB35002A"))*kva_rating.ID_BB35002A) + (sc4game.automata.get_source_building_count(hex2dec("BB35002B"))*kva_rating.ID_BB35002B) + (sc4game.automata.get_source_building_count(hex2dec("BB35002C"))*kva_rating.ID_BB35002C) + (sc4game.automata.get_source_building_count(hex2dec("BB35002D"))*kva_rating.ID_BB35002D) + (sc4game.automata.get_source_building_count(hex2dec("BB35002E"))*kva_rating.ID_BB35002E) + (sc4game.automata.get_source_building_count(hex2dec("BB35002F"))*kva_rating.ID_BB35002F)
    DISTRIB_AVAILABLE = DISTRIBUTION_RATING - (TRANSMISSION_RATING + SMALL_PLANTS_RATING)
    ------------------------------------------------------
    ------------- unlocker news message ------------------
    
    ::snip::
    
    ----------- Reward record 36 kW PV Panel Set ----
    a = create_reward_cityplanning(clean_intermediate_hex_id.PV_PANEL_SET_36_KW)
    function a.condition()
    	if  ((sc4game.automata.get_source_building_count(hex2dec("BB35004F"))*16) <= sc4game.automata.get_source_building_count(hex2dec("BB350050"))) then
    		return [[text@bb352150]]
    	else
    		return reward_state.AVAILABLE
    	end
    end
    a.frequency = 1
    a.timeout = tuning_constants.ADVICE_TIMEOUT_LONG
    a.title = [[text@bb352050]] -- title instance ID
    a.message = [[text@bb352250]] -- body text instance ID
    a.priority  = tuning_constants.ADVICE_PRIORITY_URGENT -- triggers popup
    a.mood = advice_moods.GREAT_JOB -- green title
    a.persist = 1

    I snipped out the longer sections of code that are irrelevant to the issue. The problem is this line:

    "DISTRIBUTION_RATING = (sc4game.automata.get_source_building_count(hex2dec("BB350020"))*kva_rating.ID_BB350020)"

    where BB350020 is the Occupant Group set for one of the substations. For testing I removed all other substation tests, just focusing on this ONE to get the system to return a value for DISTRIBUTION_RATING equal to the count of the number of substation buildings times the set value for kva_rating.ID_BB350020. I even tried replacing the variable kva_rating.ID_BB350020 with the number 500 for testing and it STILL returns a value of "0" for DISTRIBUTION_RATING. Further testing using other buildings KNOWN to have their count reported correctly (I used the Modular Solar Panels, the count of which is KNOWN to work within its reward LUA shown above) and no matter what I do DISTRIBUTION_RATING continues to return a value of "0". I'm evaluating the value of the variable using a Description LTEXT for another lot... this is proven to work and reports the value correctly if I set DISTRIBUTION_RATING to a set number in the LUA.

    If anyone can see what I'm doing wrong, I would greatly appreciate the help. Without the ability to set a variable to the value of sc4game.automata.get_source_building_count(hex2dec("{Occupant Group}")), this mod CANNOT do what it needs to do for load balancing. (which is still a hot mess due to this issue)

    5 hours ago, CorinaMarie said:

    Now, back to the Lua concept about overriding or standalone.

    For the time being, I'm just going to override _constants.lua as it works... and I have bigger fish to fry... so to speak. Before we get to a release though, I'm TOTALLY willing to use another method to avoid overriding a game file. I never liked that solution to begin with... but thought there was no alternative. I'm glad you found a way to get around the issue. :^)

    5 hours ago, CorinaMarie said:

    More specifically, I was wondering if you were planning to add to and release a new version of adv_utilities.lua.

    No. At most, I override a bunch of LTEXT files to alter the advisors' comments to suit the changed environment. If and when I get to adding ADDITIONAL advisor messages on top of the normal ones, I can just add additional conditionals to an external LUA separate from the adv_utilities.lua. I can appreciate that you thought I would, though.

    5 hours ago, CorinaMarie said:

    From there I've studied and experimented and I believe I've discovered additional useful techniques which build upon his work.

    And its BRILLIANT... an elegant solution!

    5 hours ago, CorinaMarie said:

    Also, because the BSC was the only mod then to utilize the track_buildings, it didn't conflict with any other override of that code.

    I STILL don't like the use of an override, but I get that it was necessary at the time. I did however, in my own override, include @Daeley's code, since its harmless if you don't need it and critically BAD to be missing if you do. I can TOTALLY see your point though of others then adding more overrides... and then more... etc. You finding a solution to that avoids all those problems. ;^)

    So... picking up where we left off... solutions to my current conundrum welcome!

     


      Edited by RobertaME  

    Typos
    • Like 6

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    46 minutes ago, RobertaME said:

    If anyone can see what I'm doing wrong, I would greatly appreciate the help.

    I will look into it. I need to get something set up here so I can see it in my game and that might take me a little while to be sure I have what's needed.

    One tiny thing I notice different than the code Maxis uses is (snipped out) hex2dec("BB350020"). They use the ' instead of the " in there. I'm almost certain this doesn't matter and either will work fine, but it would be something you could quickly test.

     

    46 minutes ago, RobertaME said:

    I even tried replacing the variable kva_rating.ID_BB350020 with the number 500 for testing and it STILL returns a value of "0" for DISTRIBUTION_RATING.

    That's good troubleshooting logic. Maybe go one step further and make it a + rather than a * just to see if you then get a non-zero answer. (The idea is to show the command is at least being executed. I suspect it's returning a count of zero and no matter what that gets multiplied by will still be zero.)

    One important tip for Lua in the game is if it finds fault with anything from a syntax perspective it will simply quit executing code at that point and there's no error thrown that will be apparent. (I did write some debugging / trapping code for one of the projects CB and I worked on and we can add that for yours in time if needed.)

     

    46 minutes ago, RobertaME said:

    For the time being, I'm just going to override _constants.lua as it works... and I have bigger fish to fry... so to speak.

    That's a perfectly good idea as it's not hurting anything at all during development. (As you go on to say, that can be looked into before release.)

    • Like 3
    • Thanks 1

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    *:thumb:

    Just to say how this is a barnstormingly brilliant outcome, and so pleasing to see how yesterday's silly little situation has now been settled. Let's all move forward indeed, and focus on what can be achieved from this point forward. There can be ups and downs (and lefts and rights) sometimes, and it's how we strive towards the summit. Also given SC4 has such limitless possibilities, it's how ingenuity comes in to develop revolutionary new methods, taking the game to yet further heights.

    This is all very much uncharted territory, so it understandably takes time. Also even though not all of us are technically gifted, the main thing is as a community we back you in your mission. We know you'll succeed because it's clear your passion for this field shines bright. Motivation is the key to achieve anything well, because there is the underlying drive towards achieving goals. Step by step, piece by piece is the way. Even though there can be frustrations and techy setbacks sometimes, this is all part of the process for the greater good. As the Mars Perseverance rover landed yesterday, this name aptly sums up what a vast project entails.

    Mayors around SimNation and the wider planetary systems of mayoralness will be overjoyed that you have decided to continue!

    You have the power and our support to prevail. *:8)

    • Like 5

    Quick Links

    “SimCity 4 is not just a game, but a tool driven by our own imagination and creativity.”

    Buy me a coffee

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    35 minutes ago, CorinaMarie said:

    One tiny thing I notice different than the code Maxis uses is (snipped out) hex2dec("BB350020"). They use the ' instead of the " in there. I'm almost certain this doesn't matter and either will work fine, but it would be something you could quickly test.

    Good catch. Tested and it didn't seem to make any difference. Tested in areas where the sc4game.automata.get_source_building_count is known to work and the system doesn't seem to care whether you use ' or "... so there's that!

    35 minutes ago, CorinaMarie said:

    Maybe go one step further and make it a + rather than a * just to see if you then get a non-zero answer.

    I removed the "*kva_rating.ID_BB350020", which didn't seem to make any difference either... it still reported "0" for DISTRIBUTION_RATING. I even added an additional data output that directly reported the value of sc4game.automata.get_source_building_count(hex2dec("BB350020")) independantly, which properly returned the building count. Removing "sc4game.automata.get_source_building_count(hex2dec("BB350020"))*" just returned kva_rating.ID_BB350020's value of 500... so I know at least the basic functions work... just not using the correct source data.

    I'm at a loss...

    35 minutes ago, CorinaMarie said:

    One important tip for Lua in the game is it if finds fault with anything from a syntax perspective it will simply quit executing code at that point and there's no error thrown that will be apparent.

    I figured that out through trial and error, but it's good to find that it's confirmed. I threw in a routine below the working code at the bottom of the LUA that changes a visible output as a test to see if the LUA is parsing through to the end or not. It's saved me a TON of time from testing code that wasn't even running and I didn't know it!

    31 minutes ago, Cyclone Boom said:

    We know you'll succeed because it's clear your passion for this field shines bright. Motivation is the key to achieve anything well, because there is the underlying drive towards achieving goals. Step by step, piece by piece is the way. Even though there can be frustrations and techy setbacks sometimes, this is all part of the process for the greater good.

    A very noble sentiment, but it may turn out that what I'm trying to fully accomplish just isn't POSSIBLE in the existing framework. I know PART of it is possible, as I did it before... but the load balancing I just self-enforced, using data collected and reported to me through queries and advisor messages. Getting the system to enforce load balancing may well be outside the possible... but I WILL find out one way or the other... the project won't fail on account of lack of trying!

    Edit: I just checked the LUA 4 manual my son got me and it is confirmed that f "..." and f '...' and f [[...]] are syntactic sugar... that is they all mean the same thing and just allow different ways to express the same function.

     


      Edited by RobertaME  

    Additional Info
    • Like 4

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    @RobertaME

    You are definitely doing the right things. Especially already noticing that quirk and adding a routine at the end of your code to see it arrives there. *:yes:

    I happen to have a separate comp set up with a fresh install of the game and my plugins contains only a couple of screen fixes. Would you mind to zip up something which would have all I need to run the same tests you are conducting? For this, I envision one lot that gets counted properly and then the one that is not working.

    • Like 4

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    12 minutes ago, CorinaMarie said:

    For this, I envision one lot that gets counted properly and then the one that is not working.

    The lots ARE being counted... I can confirm that though direct dumping of the sc4game.automata.get_source_building_count into a lot description LTEXT through adding the line:

    #sc4game.automata.get_source_building_count(hex2dec("BB350020"))#

    ...which properly reports the count of the lot in the city. That's the WEIRD part. The system will parse the above line and report a numerical value that is correct for the building count, but when used to assign that number to a global variable, it returns "0".

    I'll assemble a file to share with you that includes a stripped down version of the LUA (removing the irrelevant parts) and one or two lots that can be counted by it.

    Should I just include a link to the dependent lot or go ahead and include the lot in my ZIP? (don't want to step on toes or anything or claim other people's work as my own)

    Edit: Nevermind. I'll just use the game default Wind Plant as a test bed and a Park or something as the counted lot.


      Edited by RobertaME  

    Clarification
    • Like 4

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    That sounds good. When I can see the trouble first hand it might allow me to figure out why Lua is being so recalcitrant in that one instance. And for the required building, let's go the safest route with a linky to it.

    • Like 4

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    33 minutes ago, CorinaMarie said:

    And for the required building, let's go the safest route with a linky to it.

    I just used the Maxis Gazebo as a "Substation" and the Wind Power Plant as the test object. You should have to put down 3 gazebos before it lets you build a wind turbine.

    Test.zip

     

    Let me know if I borked up the Exemplar overrides. (it SHOULD be fine)

    Edit: Well, I messed SOMETHING up as the Gezebo isn't even showing up in the menus.... give me a moment...

    Edit 2: Fixed. It was the Parent Cohort. Dropped it and it showed up. (duh!)


      Edited by RobertaME  

    Oops: Fixed
    • Like 4

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    22 minutes ago, RobertaME said:

    Edit 2: Fixed. It was the Parent Cohort. Dropped it and it showed up.

    Got the new file and here's what I see in game:

    HPR01-0006.jpg

     

    Is this the error which we need to troubleshoot or do I also need another lot to represent the Wind Farm Maintenance Facility?

    • Like 2
    • Thanks 1

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    10 minutes ago, CorinaMarie said:

    Is this the error which we need to troubleshoot or do I also need another lot to represent the Wind Farm Maintenance Facility?

    That is the error. See where it says " - 3 get_source_building_count" in the Wind Turbine description? That's the result of:

    #sc4game.automata.get_source_building_count(hex2dec("BB350020"))#

    being added to the LTEXT file, showing that the count IS being done, and done correctly... you have 3 Gazebos planted and it correctly reports 3 as the count.

    But then the lines "0 DISTRIB_AVAILABLE" and "0 DISTRIBUTION_RATING" are the error. The LUA is SUPPOSED to take the get_source_building_count, multiply it by 500, and assign that value to DISTRIBUTION_RATING, then pass that value on to DISTRIB_AVAILABLE for the reward conditional to unlock the Wind Turbine for construction... now that there is enough distribution capacity to support the turbine.

    But the math isn't working... get_source_building_count is returning a 0 in the equation, even though it returns a 3 in the Description.

    See the cause for my hair pulling? It makes no sense! (at least to ME it doesn't) Even if get_source_building_count is returning a text value of "3", LUA should convert text numerals to their numerical value by default... at least according to the LUA manual it should.

    Thoughts welcome.

    • Confused 1
    • Thanks 3

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Got it! *:)

    Now that I'm certain I have all that's needed, I'll see what I can figure out.

    • Like 2
    • Thanks 2

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    26 minutes ago, CorinaMarie said:

    Got it! *:)

    Now that I'm certain I have all that's needed, I'll see what I can figure out.

    Thanks! I appreciate the second set of eyes. (third actually as my oldest son looked at it and he's stumped, too)

    Of note, I tested the Global Variables by assigning a value of -500 to TRANSMISSION_RATING, which resulted in a displayed value of 0 for DISTRIBUTION_RATING and a value of 500 for DISTRIB_AVAILABLE, so that confirms that the Description LTEXT is correctly reporting the values of the Global Variables and that the LUA is correctly processing these variables.

    Curiouser and curiouser...

    • Like 3

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Ok. It seems to be a quirk of Lua in the game that was causing all the trouble so I slapped it around several times, cursed at it a lot, and now I believe I've figured out what will work.

    Check the text in the hover over thinger in these pics:

    7010-8937.jpg

    7010-8938.jpg

    7010-8939.jpg

    7010-8940.jpg

    7010-8941.jpg

    7010-8942.jpg

    7010-8943.jpg

    7010-8944.jpg

     

    It seems there's a delay and I found not only does it need some time between updating the data, it also helps to select a completely different menu tree. I used the transportation one.

    In a nutshell, the name between the #'s in the LText doesn't have any way to force the info in those variables to update in real time. I'm too tired to explain it right now, but essentially what I did is move the calculations to functions and then call the functions themselves from the LText. That's why the building count was ok, but the other two didn't do squat. They got calculated once and never again. This method forces it to recheck, but still there's that time delay before even that gets its attention.

    I split your Lua code out so it's called externally. That lets me edit in Notepad++, save and run without need to muck around in Reader editing there or copy and pasting into it. So, I don't have it in a runable form that will work for you atm, but I will do so and test on my other comp before sending it tomorrow.

    • Like 4
    • Yes 1

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    1 hour ago, CorinaMarie said:

    Ok. It seems to be a quirk of Lua in the game that was causing all the trouble so I slapped it around several times, cursed at it a lot, and now I believe I've figured out what will work.

    Sounds like what I've been doing the last several hours. ;^) Difference is, I never got it to do anything except not parse at all several times... and irritate me with it's lack of actually doing what i wanted it to do.

    1 hour ago, CorinaMarie said:

    In a nutshell, the name between the #'s in the LText doesn't have any way to force the info in those variables to update in real time. (I have some ideas for that too.) I'm too tired to explain it right now, but essentially what I did is move the calculations to functions and then call the functions themselves from the LText. That's why the building count was ok, but the other two didn't do squat. They got calculated once and never again.

    I think I understand. The package is run once and never again, so the global variable is set once and then never updated again, so it remains 0, even after get_source_building_count changes. That makes total sense! The reason it updates in the LTEXT files is that the LTEXT is calling get_source_building_count at the moment it's run... and it works inside the reward conditionals because those are functions being called iteratively. (if I'm way off base here.. feel free to slap ME several times!)

    So if that's the case... we need to nest the formulas in functions that can be called iteratively, the way the reward functions are called... but not so often as to bog down the process. If we could figure some way to call the function every game day... or even every game week... it would update more responsively without bogging things down in too much math.

    Thank you! You've helped me understand how things operate better! (unless I just totally misunderstood you... in which case I'll wait and see what you have tomorrow... no rush)

    Edit: I got it! I got it to do the same thing you did!

    working.jpg.bbd2ab5cad67e3261ddc3c75a502d870.jpg

    getcount_building() is a function I created to run the equations:

            DISTRIBUTION_RATING = sc4game.automata.get_source_building_count(hex2dec("BB350020"))*kva_rating.ID_BB350020
            DISTRIB_AVAILABLE = DISTRIBUTION_RATING - (TRANSMISSION_RATING + SMALL_PLANTS_RATING)

    Then the description LTEXT for the Wind Turbine calls getcount_building() for a value, iterating the global variables and consequently unlocking the wind turbine once enough gazebos were planted. (the extra 200 difference between DISTRIB_AVAILABLE and DISTRIBUTION_RATING is part of my testing, ensuring that DISTRIB_AVAILABLE is subtracting TRANSMISSION_RATING and SMALL_PLANTS_RATING... ignore TESTING_VARIABLE; it's an outdated test object I just haven't removed from my version yet)

    The key point is that it TOTALLY makes sense now! It never even occurred to me that each LUA package runs only once. Of COURSE they do! They only NEED to run once! Everything else is just function calls!

    ::squeee!::


      Edited by RobertaME  

    More stuff
    • Like 3

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    34 minutes ago, RobertaME said:

    I think I understand.

    Yes! Yes, you do understand it exactly. *:ohyes:

     

    34 minutes ago, RobertaME said:

    If we could figure some way to call the function every game day... or even every game week... it would update more responsively without bogging things down in too much math.

    I agree, but I'm not at all certain if we can do that any sooner than once per game month (or per cycle since the game sometimes feels overwhelmed and puts some things off while it catches its breath).

    So, since you really do grasp what's going on and how it worked out, I can prolly just post the details and you can integrate it rather than me repackaging it for you. *;)

    I left the two lines in place for the calculations, but also duplicated them in new functions. This is added to the bottom of your code:

    function Calc_Rating()
      DISTRIBUTION_RATING = sc4game.automata.get_source_building_count(hex2dec('BB350020'))*kva_rating.ID_BB350020
      return DISTRIBUTION_RATING
    end
    
    function Calc_Avail()
      DISTRIB_AVAILABLE = DISTRIBUTION_RATING - (TRANSMISSION_RATING + SMALL_PLANTS_RATING)
      return DISTRIB_AVAILABLE
    end

    Ofc, you can name them anything you like. I went with shorter names just as a proof of concept. They might be better as:

    • Calc_Distribution_Rating()
    • Calc_Available_Distribution()

    And then change them in the LText to match. Here's how that looks without being all scrunched up as Reader displays them:

    1 MW Wind Power Plant is not available.
    Requirements:
        - Wind Farm Maintenance Facility (#sc4game.automata.get_source_building_count(hex2dec("BB350040"))# built)
        - Unused Distribution Capacity: 1,250 kVA
        - #Calc_Avail()# DISTRIB_AVAILABLE
        - #Calc_Rating()# DISTRIBUTION_RATING
        - #sc4game.automata.get_source_building_count(hex2dec('BB350020'))# get_source_building_count

    Then what I would do next is remove the two original lines where those calculations are currently and replace them with calls to the functions so they do still get executed upon entering a city tile, but only need defined in one place.

    I suspect you will need a lot of those so we'd prolly do well to create them with two passable parameters (the source building hex ID and the kva_rating.ID) so then that single function can serve for all you'd need rather than each getting their own separate one. I don't know what all your other code for different power plants and transformers and such will be doing so you can let me know if this sounds workable or not.

    As a sample, the call to the function could then look like: Calc_Avail('BB350020', kva_rating.ID_BB350020) and in the function itself those would be assigned to local variables and placed within the calculation.

    • Like 2
    • Thanks 1

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    My edit posted as you did. We both got to the same result... calling the function from the LTEXT.

    One difference is that I figured out that you don't NEED to return the variable, so I didn't... I just returned the raw value. Once the function is called, since the global variable is updated within the function, it updates everywhere it's referenced. My function reads as:

    function getcount_building()
        if (sc4game.automata.get_source_building_count(hex2dec("BB350020")) > 0) then
            DISTRIBUTION_RATING = sc4game.automata.get_source_building_count(hex2dec("BB350020"))*kva_rating.ID_BB350020
            DISTRIB_AVAILABLE = DISTRIBUTION_RATING - (TRANSMISSION_RATING + SMALL_PLANTS_RATING)
            return sc4game.automata.get_source_building_count(hex2dec("BB350020"))
        else
            return "0"
        end
    end

    and that works without returning the variables. (you probably know all this) Just calling the function forces the variables to update. I only included the return as a check. I'll have to play around with it to see how minimal I can get the function and how much math I can put in to be updated without overwhelming things.

    • Like 4

    Share this post


    Link to post
    Share on other sites

    Sign In or register to comment...

    To comment in reply, you must be a community member

    Sign In  

    Already have an account? Sign in here.

    Sign In Now

    Create an Account  

    Sign up to join our friendly community. It's easy!  

    Register a New Account


    ×

    Thank You for the Continued Support!

    Simtropolis depends on donations to fund site maintenance costs.
    Without your support, we just would not be in our 24th year online!  You really help make this a great community. *:thumb:

    But we still need your support to stay online. If you're able to, please consider a donation to help us stay up and running. This helps sustain a platform where we can share our community creations for years to come.

    Make a Donation, Get a Gift!

    Expand your city with the best from the Simtropolis Exchange.
    Make a Donation and get one or all three discs today!

    STEX Collections

    By way of a "Thank You" gift, we'd like to send you our STEX Collector's DVD. It's some of the best buildings, lots, maps and mods collected for you over the years. Check out the STEX Collections for more info.

    Each donation helps keep Simtropolis online, open and free!

    Thank you for reading and enjoy the site!

    More About STEX Collections