1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

strict.lua, now available to find/fix Lua typos!

Discussion in 'Civ5 - Creation & Customization' started by Pazyryk, Aug 16, 2014.

  1. Pazyryk

    Pazyryk Deity

    Joined:
    Jun 13, 2008
    Messages:
    3,584
    I've uploaded this for all you Lua modders. See thread here. It's really an extraordinary tool for finding typos and logical mistakes in your Lua code.

    The example I give is this:
    Code:
    local bWrapX = Map.IsWrapX()
    function AdjacentPlotIterator(plot)
    	[COLOR="Silver"]< snip >[/COLOR]
    	if bXWrap then
    		[COLOR="Silver"]< snip >[/COLOR]
    	end
    end
    A very nasty error that sat in my code for a very long time. This would never happen in C++ (or similar) but scripting languages are awful for letting you make this kind of error.

    You can use strict.lua to identify these kind of mistakes. It would identify the above as assignment to an undeclared global (with global name and file/line# where it happened). You may be dismayed by how many of these are in your code if your mod has >1000s of lines of Lua.

    And it can be used for table keys too! You can make a table "strict" allowing identification of cases where a misspelled key is causing you to get a nil or assign to a new key when you intended to assign to an existing key.

    So have fun slaying those Lua typos!
     

Share This Page