Jump to content
Kel9509

Custom Queries for Custom Buildings

318 posts in this topic Last Reply

Highlighted Posts

  • Original Poster
  • Posted:
    Last Online:  
     
    5 hours ago, marcio1977 said:

    As below, I put general information in the first column, paths in the second and third and in the fourth, I tried to reduce repeated words (see exemples for "Pedestrian" and "Sub/Light Rail")

    I don't know the technicalities and feasibility, so you can disregard if I went too far.

    Well, nothing is impossible here but it would be an effort to move everything around.  It can be done but it will take a bit of time.

    I think you make a good point about repetition of words.  I'll see if I can come up with a consolidated way of arranging the Volume data to make it easier to read.  I'll probably play around with this but overall I think your way is probably much better.

    As far as reorganizing the other columns, that might make sense also.  I did build this out in a spreadsheet at first and my purpose was to have even amounts of data in the columns such that they aligned at the top and bottom.  I notice in your example, the 3rd column is noticeably larger than all others.  To me, that cannot be correct.  But I'll see if I can play around with the info to re-arrange things better.  

    This is exactly the sort of criticism that I need to make this larger query workable.  Thanks very much!  

    • Like 1

    Share this post


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

    Here's a draft of the new layout as a spreadsheet.  Right now, one line is longer than the others but I suppose that's ok.  It's important to nail down the layout because moving all the entries is going to be a lot of work.

    688c30f123111_Captures-FileExplorer7_31_202511_12_53PM.jpg.174a63281305c82ccd9741eedbb390c9.jpg

    • Like 1

    Share this post


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

    Here's the revised Query in the UI previewer.  I'll need to consolidate the LTEXT files in Reader and repurpose some to make some the new headers for "Commute Time" and "Bridges", but I think this is much improved over prior versions. The Traffic Volume isn't as dense either.  I also moved the rail to the second column and the subways to the 3rd column, to consolidate the rail information as much as possible.  Please let me know what you think and if there's anything else that might improve the look.

    Thanks!

    68901ff9883b7_DepartmentofTransportationUI-Horizontal-beta33.txt-UIEditor8_3_202510_46_53PM.jpg.082de000d67732f49c3e8b983929e58c.jpg

    • Like 3

    Share this post


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

    I'd say this is quite an improvement alright! *:) Grouping all the rail stuff together makes sense, this would have been my suggestion as well. The "Busses" information looks a bit lost between "Neighborhood Connections" and "Commute Time" (I'd put those two closer together), alas, maybe it could be placed somewhere near the subway stats? For the rightmost column, an alternative to the colored numbers could be some colored bar under "Pedestrian", "Car" etc. (like the bars in the traffic overlay legend) while keeping the actual values in the default dark blue text color. This might look even more consistent with the rest of the UI.

    • Like 1

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    7 hours ago, Andreas Roth said:

    The "Busses" information looks a bit lost between "Neighborhood Connections" and "Commute Time" (I'd put those two closer together), alas, maybe it could be placed somewhere near the subway stats?

    That's definitely possible.  I can move Neighborhood Connections and Commute Time together, and put Highways underneath them above Bridges.  Then I could move Busses where the Highways were.  The only issue with that is that the second column will be the shortest visually.  also, I may need to expand the entire query to make more room for my logo, which will be pushed down on the left by the extra row of info that Highways has (4 rows) instead of Busses (3 rows).  So I'm not sure if it's worth it.

    7 hours ago, Andreas Roth said:

    an alternative to the colored numbers could be some colored bar under "Pedestrian", "Car" etc. (like the bars in the traffic overlay legend) while keeping the actual values in the default dark blue text color.

    You mean the bars I've outlined in this box?

    68918c4d2223e_SimCity48_5_202512_39_21AM.jpg.4a4f54092aa10701c5a733e3a000e50b.jpg

    Well, it's in the Traffic Query so it must be possible somehow.  I'm not sure how Maxis did it though.  I'll need to look into that to see if it's possible to duplicate in mine.

    • Like 1

    Share this post


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

    I don't think I can duplicate the bar that Maxis uses in the Data Graph views.  I think that's just something the game adds to any graph that fits the properties provided by the game.  Every other graph, including custom graphs, include those boxes and no one does anything special to create them because the game automatically does it when it's parsing a data graph. 

    But since my query isn't a data graph, the only way otherwise would be to try to create a picture or something.  I'm not sure it's worth the effort.

    Share this post


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

    Yeah, I meant those. I don't know how Maxis did it, but I would have assumed it's some simple PNG graphics. Anyway, it's just an idea that came to my mind, if you think it's not worth the effort, then the current setup works as well. *:) Regarding the lenght of the columns, I agree, but then again, one of them in the current setup is one line longer than the others, too. With "Busses" moved into the place where "Highways" is located right now, it would have the same height as the "Rail" column at least. Maybe you can move your logo to the right, so it's located centered instead of aligned to the left?

    • Like 1

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    4 hours ago, Kel9509 said:

    Well, it's in the Traffic Query so it must be possible somehow.  I'm not sure how Maxis did it though.

    Looking at the data view UI file (IID 0x0B72F276), they use a control called GZWinFlatRect. One of the definitions from that UI file is:

    <LEGACY clsid=GZWinFlatRect iid=IGZWinFlatRect id=0x8a909e10 area=(370,61,383,71) fillcolor=(200,200,200) winflag_visible=yes winflag_enabled=yes winflag_moveable=yes winflag_sizeable=no winflag_sortable=no winflag_pbuff=yes winflag_pbufftrans=yes winflag_pbufferase=yes winflag_pbuffvid=no winflag_alphablend=no winflag_acceptfocus=yes winflag_mousetrans=no winflag_ignoremouse=no colorleft=(63,73,103) colortop=(63,73,103) colorright=(63,73,103) colorbottom=(63,73,103) style=left style=top style=right style=bottom >

    They tweak the fill color in C++ based on the values set in the 0x4a0b47f2 "DataView: Legends Color" property, but I would expect that the fillcolor field sets the default. I haven't tested it.

    • Like 2

    Share this post


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

    Well well!  Thank you very much @Null 45, that amazingly did the trick!  I just had to change the fill color to the one used for the colored text.  But it works!  Moreover, I believe the box can be defined in any basic size, so I should be able to tweak it a bit to fit the Query.

    6892529d35edf_SimCity48_5_20252_47_46PM.jpg.7ecff8e509d4451dcb85252a6e170427.jpg

    With this, I'll remove the colored numbers (maybe keep the highlighting?) and add the boxes to visually align the Query with the Data Graph.  Still not sure if I want to go through the trouble of moving the highway info over.  I feel it should be next to Roads.

    • Like 4

    Share this post


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

    Great finding! *:golly: As for the grouping, maybe Roads, Highways, Bridges and Busses could be together in one column. Subway would fit better with the Rail stuff, but it's probably ok to put it below all the Commute and Neighbor Connection figures. Whatever you decide, it's quite a bit of work, naturally, but looking at what you achieved so far, it might be worth to go the extra mile. *;)

    • Like 1

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    6 hours ago, Kel9509 said:

    Still not sure if I want to go through the trouble of moving the highway info over.

    When I've worked on long, tedious projects I sometimes get in a rut where I see a better way to do something, but I'm simply not in the mood to put in all the extra work. Then I also find I can't enjoy finishing it up without said extra work cause it doesn't feel as satisfying.  I'll then get into a funk for a few days or weeks and nothing at all gets done. :O *:blush: 

    Ofc, it's your call, but a month from now you'll prolly sleep better and be more satisfied if you bite the bullet, dig in, and slug thru the extra dredgework. *;) 

    Or not. YMMV *:P 

    • Like 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:  
     

    Ok, ok... What do you think?  I still need to do some tooltips but I'm hopeful that this query is nearly final.

    689be9fb4dae8_SimCity48_12_20259_23_45PM.JPG.26c4bac7f5909351b88a5b5954bd758b.JPG

    • Like 7

    Share this post


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

    Wow, that looks super clean and tidy, I like it a lot! *:golly: It might be even more logical to switch the middle colums, so highway, bridges and road stats are closer together on the left, but I can already see your hands grabbing my throat because of all the nitpicking. *:D

    But jokes aside, this really came together nicely. I was a bit worried that the huge amount of data would be overkill, but all the extra effort with the grouping and the nice color coding really paid off, and provides usefull stats that can be accessed conveniently. Even the tongue-in-cheek intro text doesn't really apply anymore. *:P

    Oh, and if you like, I can provide a German translation once everything is done. *:)

    • Like 2

    Share this post


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

    The Department of Transportation v1.0 has finally been uploaded.  Apologies for the extensive delay!

     

    • Thanks 2

    Share this post


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

    I've been trying to see if I can add to my RCI DLL Query, when querying a residential building, the ability to show that building's actual EQ.  I know that the Data View can show EQ tracts in the game.  However, merely plugging in #game.l_tract_eq_l_subject# into the query does nothing, as expected.

    I looked in Simcity1.DAT and that variable, game.l_tract_eq_l_subject, does not appear to be used in any Advisor scripts as far as I can tell.  If it's used at all, I suspect it might only relate to querying an actual educational building (I haven't tried that yet).  

    In contrast, the current Mayor Rating in the Residential Query is merely the average citywide mayor rating, and has never been based on location either.  But if I can do EQ, I'd try to localize the Mayor Rating as well.

    Separately, I've been wondering about the "education coverage" variable, #game.g_education_coverage_p#, which spits out a number.  I first noticed it in @CorinaMarie's CORI Reports.  Frankly, it makes no sense to me. 

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    57 minutes ago, Kel9509 said:

    I looked in Simcity1.DAT and that variable, game.l_tract_eq_l_subject, does not appear to be used in any Advisor scripts as far as I can tell.  If it's used at all, I suspect it might only relate to querying an actual educational building (I haven't tried that yet).  

    It doesn't appear to be used.

    The way the *_subject variables appear to work is that they paired with another variable without the _subject suffix, e.g. game.l_road_congestion_h and game.l_road_congestion_h_subject. The _subject variable is only used as input to game.camera_jump in a related advisor message body. An example of this pairing can be seen in Local Road Reaches Limit - A Chaos of Cars.

    33 minutes ago, Kel9509 said:

    Separately, I've been wondering about the "education coverage" variable, #game.g_education_coverage_p#, which spits out a number.  I first noticed it in @CorinaMarie's CORI Reports.  Frankly, it makes no sense to me. 

    From the two trigger conditions it is used in (ABCs Will Put Sims On Solid Ground and #City# Slums Hold Meager Development Promise), it looks to be measuring the percentage of the total residential population that is covered by education buildings.

    • Like 1

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    On 9/20/2025 at 1:26 AM, Null 45 said:

    From the two trigger conditions it is used in (ABCs Will Put Sims On Solid Ground and #City# Slums Hold Meager Development Promise), it looks to be measuring the percentage of the total residential population that is covered by education buildings.

    Yeah, supposedly.  I've been testing "game.g_education_coverage_p" a lot with your Detokenizer DLL and frankly it makes absolutely no sense to me.  It's supposed to be a percentage variable but it sure doesn't look like it.  In cities with a school and a library, the variable can be 2.  In a regular high EQ (160+) city, the variable is 5.  But after plopping a ton of libraries and museums, including the Opera House and the Main Library, to get my EQ up to 170, the variable comes back as 4.  How could the percentage go down?  So I have no idea what it means.  Those trigger scripts in the game look slightly broken to me if this variable makes no sense.  The other conditions of those triggers hold up, but this one is really odd.

    Even more confusing are some of the game trend values. For instance, "game.trend_value(game_trends.G_POPULATION_SCHOOL_COVERAGE,12)" reports back 0 (over 12 months) or 0 over the current month, no matter if I try it in an existing established city or a newly fresh one with new school students.  It appears that trend value is only used by the game in one advisor script, Sour Sims See Poor Prospects, and frankly probably isn't needed.  I'm not sure that value could ever be anything other than zero.  

    Is it possible that Maxis made variables that don't really work with their own scripts?

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    3 hours ago, Kel9509 said:

    Is it possible that Maxis made variables that don't really work with their own scripts?

    It is. The game's scripts have quite a few examples of things that only exist in Lua, such as the SC3K ordinances. G_POPULATION_SCHOOL_COVERAGE isn't implemented on the C++ side, so it makes sense for it to always return 0.

    3 hours ago, Kel9509 said:

    I've been testing "game.g_education_coverage_p" a lot with your Detokenizer DLL and frankly it makes absolutely no sense to me.  It's supposed to be a percentage variable but it sure doesn't look like it.

    The disassembly of that calculation makes no sense to me, it appears to effectively be this in pseudo code:

    float someSchoolQueryValue = ...
    float totalResidentialPopulation = ...
    
    g_education_coverage_p = (someSchoolQueryValue / (totalResidentialPopulation + 1)) x 100.0

    Without EA releasing a DLL SDK (or the full source code), it is hard to say what someSchoolQueryValue is. The C++ compiler optimized the cISC4ResidentialSimulator::tQueryData structure down to unnamed fields, with only limited type information remaining.

    • Thanks 2

    Share this post


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

    Working on my latest query:

    68f2ddde8b4f2_SimCity410_17_20258_20_12PM.jpg.d87030d7766c03ae9d2c2c1c3c0d6819.jpg

    Unfortunately, some of the variables are messed up a bit:

    1. The lowest funding and lowest grades are gigantic numbers if no buildings exist.  I think I can fix it based on code I used for the Dept of Transportation that @CorinaMarie provided.

    2. The Number of Educational buildings is inaccurate, since it's equivalent to the number of schools.  I think this can be fixed with just some addition, hopefully.

    3. The funding amounts are inaccurate when querying the actual buildings.

    4. Strangely enough, even though "Lowest Museum Grade" isn't used in any Advisor scripts in-game, the variable actually works!  I was expecting it to fail but it strangely works.

    5. Overall educational funding, represented by "game.g_education_funding_p", is not the actual simoleon amount of funding but is a percentage.  I'm not sure how useful that information really is.

    • Like 3

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    On 10/17/2025 at 8:30 PM, Kel9509 said:

    Unfortunately, some of the variables are messed up a bit:

    1. The lowest funding and lowest grades are gigantic numbers if no buildings exist.  I think I can fix it based on code I used for the Dept of Transportation that @CorinaMarie provided.

    2. The Number of Educational buildings is inaccurate, since it's equivalent to the number of schools.  I think this can be fixed with just some addition, hopefully.

    3. The funding amounts are inaccurate when querying the actual buildings.

    4. Strangely enough, even though "Lowest Museum Grade" isn't used in any Advisor scripts in-game, the variable actually works!  I was expecting it to fail but it strangely works.

    5. Overall educational funding, represented by "game.g_education_funding_p", is not the actual simoleon amount of funding but is a percentage.  I'm not sure how useful that information really is.

    Working on this building some more and an update from my last post:

    1. Lowest funding/grades are now fixed with appropriate LUA coding based on the DOT code.

    2. Number of Educational buildings is fixed by adding the # of schools + libraries + museums.

    3. Funding numbers for buildings were, after extensive testing, determined to be percentage amount of funding represented by the slider and not actual $ amounts, consistent with the overall education funding percentage noted above.

    With these fixes, I'm very close to a final version of the query.  Just need to test it a bit more.  

    As far as buildings/lots go, that's another issue.  I was again thinking of using @Diego Del Llano's Aldred Building for an urban version.  Not sure about a rural version yet.

    • Like 3

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    On 11/4/2025 at 7:56 PM, Kel9509 said:

    2. Number of Educational buildings is fixed by adding the # of schools + libraries + museums.

    I noticed that the # of educational buildings doesn't take into account Opera Houses.  Yet when you click on the Data Views map for Education, obviously Opera Houses are highlighted.  Since the Data Views information is different from the variables for queries, it's once again an instance in the game of the left hand not talking to the right hand.  It knows that Opera Houses are educational buildings yet the variable was never build to account for them.  Yet I wonder if there's a way to count the Opera House for purposes of this query anyway?  I suppose if there were code that knew the Occupant Group, I could add that up with the known variables (schools, libraries and museums) to get a true amount of Educational Buildings.  

    Does anyone know of any code from a model that might be useful to examine? I don't think I've seen this in the ModPacc Zero Town Hall, or the Ministry of Garbage.  Hmmm.. actually now that I recall, some SimGoober buildings count others to see if a reward unlocks.  Maybe that's the way to go?

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    18 minutes ago, Kel9509 said:

    Yet I wonder if there's a way to count the Opera House for purposes of this query anyway? 

    Are you able to display: sc4game.automata.get_source_building_count(building_groups.OPERA) in your UI? (You might need to do it as a function from LText as we did elsewhere.)


    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:  
     
    1 hour ago, Kel9509 said:

    I noticed that the # of educational buildings doesn't take into account Opera Houses.  Yet when you click on the Data Views map for Education, obviously Opera Houses are highlighted.  Since the Data Views information is different from the variables for queries, it's once again an instance in the game of the left hand not talking to the right hand.  It knows that Opera Houses are educational buildings yet the variable was never build to account for them.  Yet I wonder if there's a way to count the Opera House for purposes of this query anyway?  I suppose if there were code that knew the Occupant Group, I could add that up with the known variables (schools, libraries and museums) to get a true amount of Educational Buildings.  

    Does anyone know of any code from a model that might be useful to examine? I don't think I've seen this in the ModPacc Zero Town Hall, or the Ministry of Garbage.  Hmmm.. actually now that I recall, some SimGoober buildings count others to see if a reward unlocks.  Maybe that's the way to go?

    You have two options

    1. Write an algorithm that automatically calculates all Opera buildings. Like This: (grid_logic_var.LARGE_COAL_COUNT = sc4game.automata.get_source_building_count(hex2dec("IID BUILDING EXEMPLAR")) + sc4game.automata.get_source_building_count(hex2dec("IID BUILDING EXEMPLAR")) + ....)
    2. @CorinaMarie's proposal

    From personal experience, I recommend following CorinaMarie's suggestion, as it is easier. 

    • Like 1

    Federal Republic of SiculiaFederal Republic of Sonora

       Ain Member  Wiki

    NAM Team - Co-developer of Pedestian Revolution Mod - Railway Department (Hybrid Railway | HRW Expert) - MTA Member - BAT Creator

    Ulisse Wolf YouTube Channel - Ulisse Wolf Mastodon Profile

    Share this post


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

    it's once again an instance in the game of the left hand not talking to the right hand.

    I suspect that it may have been a typo. The Opera House is tagged as Building: School Other (0x151b), but that value was omitted from the array that contains the school occupant groups.

    • Thanks 1

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    On 11/15/2025 at 6:08 PM, CorinaMarie said:

    Are you able to display: sc4game.automata.get_source_building_count(building_groups.OPERA) in your UI? (You might need to do it as a function from LText as we did elsewhere.)

    I did add that into the query directly in the amount representing the # of Educational Buildings as this: #sc4game.automata.get_source_building_count(building_groups.OPERA)#

    And it displayed zero.  But plopping an Opera House didn't change the result:

     691a5ce1d1829_GDriverWindow--DirectX11_16_20256_17_07PM.jpg.028c7139640842654ab89669cdb2da5a.jpg

    So I'll try it as a function.  Like this?

    function edubuilds()
      sc4game.automata.get_source_building_count(building_groups.OPERA)+game.g_num_schools+game.g_num_libraries+game.g_num_museums
    end

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    4 minutes ago, Kel9509 said:

    I did add that into the query directly in the amount representing the # of Educational Buildings as this: #sc4game.automata.get_source_building_count(building_groups.OPERA)#

    And it displayed zero.  But plopping an Opera House didn't change the result:

     691a5ce1d1829_GDriverWindow--DirectX11_16_20256_17_07PM.jpg.028c7139640842654ab89669cdb2da5a.jpg

    So I'll try it as a function.  Like this?

    function edubuilds()
      sc4game.automata.get_source_building_count(building_groups.OPERA)+game.g_num_schools+game.g_num_libraries+game.g_num_museums
    end

    Try this

    sc4game.automata.get_source_building_count(hex2dec("00001909"))


    Federal Republic of SiculiaFederal Republic of Sonora

       Ain Member  Wiki

    NAM Team - Co-developer of Pedestian Revolution Mod - Railway Department (Hybrid Railway | HRW Expert) - MTA Member - BAT Creator

    Ulisse Wolf YouTube Channel - Ulisse Wolf Mastodon Profile

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    48 minutes ago, Kel9509 said:

    So I'll try it as a function.  Like this?

    function edubuilds()
      sc4game.automata.get_source_building_count(building_groups.OPERA)+game.g_num_schools+game.g_num_libraries+game.g_num_museums
    end

    Edit: I see you did try this. I don't know how I missed reading that. So, none of this is likely to work. Maxis must not be updating the variable.

    It's been a long while. *:blush: I could look up my notes sometime later, but let's try: 

    #sc4game.automata.get_source_building_count(building_groups.OPERA)# first in your LText (assuming you haven't already). Note that I don't actually know if the variable is populated by the game. I've just seen it as an option in their Lua.

    Then, too, yes your function should work, but remember to return that data and make a token of the function when you call it in your LText.

    So like this:

    function edubuilds()
      return sc4game.automata.get_source_building_count(building_groups.OPERA) +
      
    game.g_num_schools +
      game.g_num_libraries +
      game.g_num_museums
    end

    And then in your LText you make a token like:  #edubuilds()#


    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:  
     
    1 hour ago, Kel9509 said:

    And it displayed zero.  But plopping an Opera House didn't change the result:

    sc4game.automata.get_source_building_count only works with a predefined list of occupant groups, and the opera group isn't in the default list. This is called out in the documentation for sc4game.automata.get_source_building_count, but there is a typo in the name of the Lua list. It uses tracked_buildings when the actual name is track_buildings.

    Maxis most likely used a predefined list for performance, the game counts the tracked buildings when loading the city and then only has to update the count when buildings with those OGs are added or removed.

    You should be able to modify the track_buildings list by adding Lua code to a script that is similar to the following (untested):

    table.insert(track_buildings, building_groups.OPERA)

    Note that the code needs to be outside of a function to enure that the Lua system executes it when reading the script. Scripts that modify the tracked_buildings table also need to use the automata script group id (0x4a5e8f3f), this ensures that the script is run before the C++ side reads the track_buildings table.

    • Thanks 1

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    5 hours ago, Ulisse Wolf said:

    Try this

    sc4game.automata.get_source_building_count(hex2dec("00001909"))

    I was hoping that would work, because except for the reference to the Opera House occupant group, that code is identical to what SimGoober uses for counting his custom occupant group buildings like in his reward and text in his Mitchell Building.  It is exactly what he uses (with the #'s of course, and not using 0001909 for the Opera House).  Yet it didn't work.  I don't understand why it wouldn't work for a Maxis building when it works for his custom occupancy group.  I don't get it at all.

    4 hours ago, Null 45 said:

    You should be able to modify the track_buildings list by adding Lua code to a script that is similar to the following (untested):

    
    table.insert(track_buildings, building_groups.OPERA)

    Note that the code needs to be outside of a function to enure that the Lua system executes it when reading the script. Scripts that modify the tracked_buildings table also need to use the automata script group id (0x4a5e8f3f), this ensures that the script is run before the C++ side reads the track_buildings table.

    I'm not sure why that's necessary when SimGoober didn't do that for his Mitchell Building.  But even if it is necessary, I'm not sure I follow how to make it work.  I wonder if there are any other examples out there.

    By the way, I'm plopping the Opera House using the Advanced Lot Plop mod.  And I have CoriBoom's Opera House fix installed.  Not sure if that makes a difference at all.  

    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