6 years ago
Is it possible to load tuning for a custom module?
Hello!
Hopefully someone can help me here. I want to write a new class that has some tunable settings. As soon as these are loaded, I then want to use the values to do something else. However, I have been unable to get the game to read my tuning.
For instance, in the code below ("my_tuning.py") I have a custom class with two tunables: A_NUMBER and A_TRAIT. I set up a command to print the value of MyTuning.A_NUMBER and it's always 0.1 (the value of A_TRAIT is None because I didn't set a default), regardless of the value I specify in the corresponding XML.
This is the XML I'm trying to load (03B33DDF!00000000!F9C4C5D3009CC2E9.my_tuning.Tuning.xml). The guid (17997727520918389481) is the FNV64 of the Python's module name: "my_tuning."
Is there something I'm missing? Or is loading tuning for modules/classes something that only works for EA classes?
If anyone can help or shed a light in the right direction, it would be greatly appreciated!
Hopefully someone can help me here. I want to write a new class that has some tunable settings. As soon as these are loaded, I then want to use the values to do something else. However, I have been unable to get the game to read my tuning.
For instance, in the code below ("my_tuning.py") I have a custom class with two tunables: A_NUMBER and A_TRAIT. I set up a command to print the value of MyTuning.A_NUMBER and it's always 0.1 (the value of A_TRAIT is None because I didn't set a default), regardless of the value I specify in the corresponding XML.
from sims4.commands import Command, CheatOutput, CommandType
from sims4.tuning.tunable import Tunable
from traits.traits import Trait
class MyTuning:
A_NUMBER = Tunable(
tunable_type = float,
default = 0.1)
A_TRAIT = Trait.TunableReference()
@classmethod
def _tuning_loaded_callback(cls):
# do stuff with cls.A_NUMBER and cls.A_TRAIT
pass
@Command('test_tuning', command_type=CommandType.Live)
def test_tuning(_connection=None):
output = CheatOutput(_connection)
output(str(MyTuning.A_NUMBER))
This is the XML I'm trying to load (03B33DDF!00000000!F9C4C5D3009CC2E9.my_tuning.Tuning.xml). The guid (17997727520918389481) is the FNV64 of the Python's module name: "my_tuning."
0.8
102448
Is there something I'm missing? Or is loading tuning for modules/classes something that only works for EA classes?
If anyone can help or shed a light in the right direction, it would be greatly appreciated!