How to pass parameters from Advanced Options to Lua Scripts?

isau

Deity
Joined
Jan 15, 2007
Messages
3,071
I'm so close to getting the "faster borders" feature in my mod working, but I've run into an issue with passing option information from the Advanced Options screen to the script.

Here's the setup I have.

In the config file I establish a drop-down box with some new options:

Code:
    <Parameters>
            <Row ParameterId="QuoOptionBorderSpeed" Name="LOC_QUO_OPTION_BORDER_SPEED_NAME" Description="LOC_QUO_OPTION_BORDER_SPEED_DESCRIPTION" Domain="QuoOptionBorderSpeed" DefaultValue="DEFAULT_NUMBER" ConfigurationGroup="Map" ConfigurationId="QuoOptionBorderSpeed" GroupId="MapOptions" Hash="0" SortIndex="1000"/>
        </Parameters>

    <DomainValues>
        <Row Domain="QuoOptionBorderSpeed" Value="1" Name="Quo Speed" Description="City borders expand 200% faster than the Vanilla game." SortIndex="10"/>
        <Row Domain="QuoOptionBorderSpeed" Value="0" Name="Vanilla Speed" Description="City borders expand at a rate similar to unmodded game." SortIndex="20"/>
    </DomainValues>


This (I think) should establish the name of the option as "QuoOptionBorderSpeed." It's a drop-down box that defines two values. This works fine on the options screen.


In my Lua, I have this:


local quo_option_border_speed = MapConfiguration.GetValue("QuoOptionBorderSpeed") ;


I thought this would pass the value of QuoOptionBorderSpeed defined in the option selection over to the local Lua variable quo_option_border_speed. However, it keeps coming up as "nil."

Any ideas what I'm doing wrong? Or just an example mod where it is done correctly?
 
Last edited:
I was able to fix this, uh, "bug."

The Print command I was using to show the variable value had a typo. :P At least its fixed and working now!
 
Back
Top Bottom