Custom Notification Issues

Sneaks

Brooklyn Bum
Joined
Oct 15, 2010
Messages
1,877
Location
NYC
I have been attempting to create a notification system that would involve Addins much the same way alpaca's DiploCorner system does.

While I have had pretty solid success, there are still several errors I cannot seem to get past with my hacky lua skills. Primarily, the LuaEvent "LuaEvents.CustomNotification" that is called by any custom notifications seems to run too many times.

Right now, the modder calls the notification with the following variables (based almost entirely on alpaca's Improved Notifications):
name, summary, tooltip, city, plot, highlightcolor, and a true/false boolean for highlighting.

Depending on which variables have values and which are inputted as 0, the LuaEvent will trigger 1 of 3 notification types:

CityZoom: The notification will highlight the plot in plot value, and middle clicking the notification will zoom in on the city

PlotHighlight: The notification will highlight the plot

Basic: Simply shows in the stack

To get this to work, there are 2 Modding Addin points: 1 in NotificationPanel.lua and 1 in CustomNotification.lua. The one in NotificationPanel adds each custom notification's Context files (thus stopping the need to append NotificationPanel.xml) and the one in CustomNotification calls a name and type value to be added to the custom notifications list. There is a third call in CustomNotification which checks to see if NotificationOptions exists, and if so, will add a "is this type of notification hidden?" check if that mod is on.

Attached is a .rar file including the entire solution.

What I ask is that some experienced eyes comb through the code looking for where the problems might exist.

To explain the folders:
The files in CustomNotification and lib.lua are the only files directly needed to add to another mod to allow notifications.

ImprovedEvents contains files that hook in 2 custom notifications from alpaca's Improved Notifications mod.

NotificationOptions contains files to a Notification Options UI that allows the user to choose which notifications should show. This code is also from alpaca.

Thanks again for any help anyone can give at debugging this.
 

Attachments

Primarily, the LuaEvent "LuaEvents.CustomNotification" that is called by any custom notifications seems to run too many times.

I'm not at home and so can't check your code, but I've run into this issue before after the December megapatch with the custom notification logic. Specifically, this happens if you have it being loaded in the Content tab (or InGame.xml) AND have VFS=true; it'll run it twice, and the second time won't use the right arguments. Since the CustomNotification logic is being handled as an Include inside NotificationPanel.lua (assuming you've copied Whys' code), which is part of the existing code, the correct method to use is the VFS.
 
Found the error in my ways.

I was idiotically calling one lua in another, and had the LuaEvent added to the file being called, thus the double functions.
 
Back
Top Bottom