Modifying Addon Constants

So far, this has gone without mention, but the `Addon` class takes in a `constants` argument. This page will go over that.

What is AddonConstants?

As said, Addon takes in a constants argument. We can pass a custom AddonConstants instance to override the default constants.

The constants dictate how long a token takes to expire, the tick rate for the on_tick event, how long since the last request from SWToPython to declare that the addon has stopped, etc.

Using Custom Constants

Simply pass in a custom AddonConstants instance to the constants argument of Addon.

# ...

constants = AddonConstants(
    TICK_INTERVAL = 4, # tps = 64 / TICK_INTERVAL, so this would make the TPS 16
    CALL_TIMEOUT_SECONDS = 5 # calls will error after 5 seconds if they don't get a response
)

addon = Addon(
    "My Addon",
    path = ".",
    port = 2500,
    
    constants = constants
)

# ...

Last updated

Was this helpful?