Replies: 3 (Who?), Viewed: 5690 times.
Original Poster
#1 Old 5th Jan 2019 at 6:11 AM Last edited by scumbumbo : 5th Jan 2019 at 6:34 AM.
Default Notification Example Using Module Tuning
WARNING -- You may find it boring to generate notifications with this method. It's just really easy compared to the old ways. There's simply no challenge what-so-ever to it, and who wants to do that?

The basics:
  • The attached example should make all this stuff perfectly clear. All the information below may make it seem complex but you can probably just read the sources and figure it all out except perhaps what instance number to use for the module tuning.
  • You'll need an STBL with any strings that you want to use in your notification. The one I've included contains only the English translation, but of course you'll want one for every game language even if you don't have a translation for that language, otherwise players with that locale will see just blanks.
  • You'll need an XML module tuning for your script module.
    • Type = 0x03B33DDF
    • Instance = FNV-64 hash of the Python module name containing the class with your notification(s) WITHOUT forcing the high-bit to 1 like you normally would with a modded instance number. Leave the high-bit natural, don't set it, don't clear it.
    • If your module is in a Python package, replace the dot you would normally use to specify the package.module with a dash (-) when generating the hash. So if your package name was "ui" and the module name was "notifications" you would normally refer to this in an import as "ui.notifications". For the hash, use "ui-notifications" (0xD90049B58B2C79E4). You should still use "ui.notifications" for the "n" attribute of the XML <M> tag.
  • The module tuning will contain the notification tuning, which is coded like any other XML notification tuning. It can contain icons, command buttons (shown in example) and so forth just by setting the appropriate tuning.
  • Your script module should define a class to contain your notifications of type UiDialogNotification.TunableFactory.
  • Your class can contain more that one notification if you wish. Each one should have a unique variable name and matching XML in your module tuning.
  • Create an instance of that UiDialogNotification class, and run the show_dialog() method contained in it.

Download - please read all instructions before downloading any files!
File Type: zip Notif Tuning (2.2 KB, 104 downloads) - View custom content
Original Poster
#2 Old 5th Jan 2019 at 6:16 AM
Oh yeah, to run the example open a cheat command window and type notif.example Leave the cheat command window open to see the output from the command button on the notification.
Test Subject
#3 Old 5th Jan 2019 at 6:49 AM
Oh wow, you weren't kidding about this being a lot easier hahaha. Thanks again Scumbumbo - Will definitely be utilizing this now.
Original Poster
#4 Old 5th Jan 2019 at 8:41 AM
Realized I didn't really explain how to include tokens in the text. Rather than do a full-blown example I figure I can just explain it hopefully. You'd want to pass a tuple with the tokens in an 'additional_tokens' argument to the show_dialog. So, for example if in the main text value in the string table if instead of "Press the "Run Command" button below to trigger a cheat console command." I had done "Press the "{0.String}" button below...." I could insert the "Run Command" string table entry in as a token using
from sims4.localization import _create_localized_string
example_notification.show_dialog( additional_tokens = (_create_localized_string(0x8996059B), ) 

You can also pass integer values, etc. as tokens.
Back to top