Complete: method not triggering at all in Events

var announcePacks = {
        id: packid,
        date: '23/7/3',
        ignoreGameLengthModifier: false,
        getNotification: function (company) {
            return new Notification({
                sourceId: packid,
                header: "Unknown PM".localize("heading"),
                   text: "Hello. After some years of hard work, we, some professional fans who happen to have a Research lab, are finally glad to tell you that we are awarding you some research packs for your awesome games! These packs contain lots of different kinds of researches that you can use to your benefit.".localize()
            });        
        },
        complete: function(decision) {
            if (decision === 0) {
                dataStore.data.resPacksAnnounced = true
            }
        }
    };

The complete: method isn’t triggering at all. If the default OK button is pressed, it doesn’t trigger. I have another notification like this, with multiple options, and it still doesn’t trigger.

I understand the code, but i don’t know the solution. Maybe try asking the devs or/and mods. Or send an e-mail to the support :wink:

E-mail to support: support@greenheartgames.com

1 Like

are you adding the announcePacks as an event?

Also, you are checking for a decision yet you do not provide any options for the player. I’m not sure if a notification with just an OK button will call the complete method.

I knew there was something really wrong in that code, but I couldn’t see it. That’s what I get for not touching javascript for ages, I guess. Also, correct me if I’m wrong, but complete only works with events, and that’s basically a notification. If not, I can’t see what effect the event has. Must be that I need glasses or something.

Also, correct me if I’m wrong, but complete only works with events, and that’s basically a notification. If not, I can’t see what effect the event has. Must be that I need glasses or something. BTW sorry for double post, but edit keeps telling me an error has occured for some reason, and I can’t edit my post…

as an event. I just forgot to add that piece of code. I have something almost similar, but it doesn’t seem to trigger it.

var dataStore = GDT.getDataStore("extendedgdtfire");
dataStore.data.pwAnnounceFunctionAnnouncedResetDATA2 = false;
var shortvar = dataStore.data.pwAnnounceFunctionAnnouncedResetDATA2;

    //Notification
var id = "exGDT_pwAnnounceFunctionID.RESET.1.2.3";
var pwAnnounceFunctionRemadeReset = {
    id: id,
    date: '17/7/3',
    isRandomEvent: false,
    ignoreGameLengthModifier: false,
    trigger: function (company) {
        var company = GameManager.company;
        return company.currentLevel == 4 && company.isLaterOrEqualThan(17,7,3);
    },
    getNotification: function (company) {
        return new Notification({
            sourceId: id,
            header: "Gaming News".localize(),
            text: "Dear Developers,\n from now on, you can contact us to release info about your in-progress games! To begin with, you must send an e-mail here: pixelware@support.gdt and we will grant you access to Private Messages.".localize(),
            image: [exGDT_FireChaos.modPath + "/images/notifications/pixelwareUpdated.png"],
            options: ["Accept", "Decline"]
        });
    },
    complete: function (decision) {
        var company = GameManager.company;
       if (decision === 0) {
            dataStore.data.pwAnnounceFunctionAnnouncedResetDATA2 = true;
            console.log("First call reached. (pwAnnFunc)");
            var n = new Notification({
                header: "PixelWare PM".localize(),
                text: "Thank you for participating in our program! And you were among other companies which replied immediately! We'll go on informing our fans about this."
            });
            return;
       }
       if (decision === 1) {
            dataStore.data.pwAnnounceFunctionAnnouncedResetDATA2 = true;
            console.log("First-2 call reached. (pwAnnFunc)");
            var n = new Notification({
                header: "PixelWare PM".localize(),
                text: "You don't have to use it! We feel that you might use it someday, so here you go."
            });
            return;
       }
    }
}
GDT.addEvent(pwAnnounceFunctionRemadeReset);

This is a copy of the event but with options, and the full code. It’s the same thing, won’t work.

Wonder why you deleted your post. You said you fixed it… Did you? :smiley:

Nope, I ran another text and it didn’t work. I don’t know why it doesn’t.

It once happened to me. I tried every debugging method I know but it couldn’t be fixed. But for some reason when I rewrote the code from scratch it didn’t happen. And it is worth noting that I was experimenting with events like yours: complex, multi-option and roughly the same style of coding.

There is a complex and working example in the official modding API:

If you can’t get yours to work, I suggest you copy/paste this one and adjust it with your own values.

Patrick, just a question, is it possible to create notifications which also have multiple options? (Notifications, not events) Because when I tried to do this the event wouldn’t appear altogether.

The main difference between a notification and a event is that the notification only shows a message, while the event allows for a callback to respond to a selected option.

A notification (not a event) with multiple options would be pointless, since you wouldn’t be able to respond to the options.

I copy pasted the example, and this one worked. and I found my problem. I didn’t use .localize() at the end of the text: value in the complete: method.

So instead of this:

text: "That's a nice text!".localize()

It was this:

text: "That's a nice text!"

I bet that was causing the problem.

Well I did use localize so it’s probably something else.

That’s the only thing I found to be wrong. Could be more.

You’re correct. In another version of my code, it doesn’t trigger again, but I have used .localize() where I should :stuck_out_tongue:

this should make no practical difference. Should be caused by something else.

Hi Patrick, I’ve been trying to make my own simple mod based on examples.js. I am unable to get anything to trigger. I’ve even set isRandom: false, in examples.js, but it won’t show me any dialogues.

It’s probably best to start a new topic and post your complete event code (try to make a small example).

I simply made a package.json file for examples.js and moved the entire example package as is into the mods folder so it would launch as a mod. I set isRandom: false to force it to launch as soon as the first game is being developed, but nothing happens. I’m able to load the mod, but I don’t know if it’s working properly.

I’ll start a new topic as suggested. Thanks.