Jump to content
Null 45

Lua Extensions - DLL Plugin

7 posts in this topic Last Reply

Highlighted Posts

Posted:
Last Online:  
 

A DLL Plugin for SimCity 4 that extends the game's Lua system with new functions. This file is a dependency for plugins that use the new Lua script functions.

This DLL provides a number of functions for the game's Lua scripts. See null45_lua_extensions.lua for a list of the provided functions, and null45_lua_extensions_tests.lua for examples of their use.

It also re-enables the Lua error logging that Maxis disabled in the retail version of the game. Note that due to the way that the game loads plugin Lua scripts, the error messages only give the line number within the script unless the error occurs within a function.

Download: https://community.simtropolis.com/files/file/36925-lua-extensions-dll/

Source Code: https://github.com/0xC0000054/sc4-lua-extensions

System Requirements

The plugin may work on Windows 7 or later, but I do not have the ability to test that.

Installation

  1. Close SimCity 4.
  2. Copy SC4LuaExtensions.dll, and SC4LuaExtensions.dat into the top-level of the Plugins folder in the SimCity 4 installation directory or Documents/SimCity 4 directory.
  3. Start SimCity 4.

Troubleshooting

The plugin should write a SC4LuaExtensions.log file in the same folder as the plugin.
The log contains status information for the most recent run of the plugin.

If you would like to make voluntary contributions to support me in continuing to create more content for SimCity 4, I accept donations via PayPal: https://paypal.me/0xC0000054

Thanks to the few people who have donated to me.

  • Like 5

Share this post


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

Wow.  I was looking at the list of LUA functions in your example and those are really, really powerful.  I know that you already highlighted the ability to take screenshots, but there are others that are really cool and might actually be very useful for modders in the future.  Like the ability to construct a particular building lot at a specified place.  This could make for some interesting reward lots that are auto-built.  Heck, you could auto-plop a lot, growify it with the cheat code, and then take a screenshot to capture your reward.  That sounds incredible.

The ability to get department budget income and expenses is also very interesting.  I assume that those amounts are the same as included in the budget table (and updated the same way?).  I recall in my update to the Census Repository that certain numbers weren't updated until the 28th of the month and they never really aligned with what was shown in the budget window. I wonder if it'd be possible to iron that out now with this new LUA coding...  Hmm.

(As an aside, I'm still working off of my wife's old laptop and hence it's very difficult to mod.  My new computer is coming along nicely though and I'm waiting for the motherboard to arrive before putting it together, hopefully next month.  Damn tariffs messed everything up, and it doesn't help that I'm an idiot and decided to build a top of the line system after having an old one for nearly 15 years....).

  • Like 2

Share this post


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

    I assume that those amounts are the same as included in the budget table (and updated the same way?).

    They are the same as the budget window.

    4 hours ago, Kel9509 said:

    My new computer is coming along nicely though and I'm waiting for the motherboard to arrive before putting it together, hopefully next month.  Damn tariffs messed everything up, and it doesn't help that I'm an idiot and decided to build a top of the line system after having an old one for nearly 15 years....

    I am planning to build a new machine, but the tariffs and limited supply on components such as cases and GPUs is making that difficult.

    • Like 1

    Share this post


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

    Release version 1.0.1, which has the following changes:

    • Fixed a bug where sc4game.budget.get_department_total_expense and sc4game.budget.get_department_total_income returned a string.
    • Removed the print function from null45_lua_extensions.lua, this re-definition was turning the built-in Lua print function into a no-op for plugin scripts.
    • Like 1
    • Thanks 1

    Share this post


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

    Release version 1.1.0, which adds  a dbpf table with functions to read cohort/exemplar properties and check if specific TGI values exist.

    • Thanks 2

    Share this post


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

    Release version 1.1.1, which made a number of functions that take hexadecimal ids easier to use by letting them read hexadecimal strings in addition to numbers.

    The fact that APIs required the hexadecimal strings to be converted to numbers with hex2dec was easy to miss. Using sc4game.budget.get_department_total_income as an example:

    Old code:

    return tostring(sc4game.budget.get_department_total_income(hex2dec('a2963983')))

    New code:

    return tostring(sc4game.budget.get_department_total_income('a2963983'))
    • Like 2

    Share this post


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

    Automated Notice Message

    All posts after 1 March, 2026 @ 01:37 GMT were lost in the site crash.

    We've added this message thread divider in every topic across all forums for what were then active threads. (We decided active is if the most recent extant post (from the backup) was on or after 1 January, 2026.)

    This divider serves as notice that the conversation was interrupted. Answers and further discussion which used to be here have been lost. Keep this in mind when replying. Our hope is to rebuild what is missing.


    I am Lab Rat.

    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