Make your first plugin - Facebook Payments

4

Index

Stats

9,875 visits, 23,690 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 17 Aug, 2015. Last updated 19 Feb, 2019

Conditions

Next item down we will be changing starts on line 58. However browse through lines 30 through 56 which list example conditions because that is what we are working on next.

A condition in Construct 2 is the first item entered into an event on the event sheet. For example a "trigger once". It means what needs to happen for our action to take place. We are going to have two trigger actions, so.....

remove lines 58 and 59. They are listed here if you don't have the lines listed in your editor.

    AddNumberParam("Number", "Enter a number to test if positive.");
    AddCondition(0, cf_none, "Is number positive", "My category", "{0} is positive", "Description for my condition!", "MyCondition");

Once those two lines are deleted we will add two lines where the other two items were just removed from(beginning on line 58.

    AddCondition(0, cf_trigger, "Payment complete", "Payments", "On payment complete", "Triggered when the user has successfully bought a good", "Onpurchsuccess");
    AddCondition(1, cf_trigger, "Payment failed", "Payments", "On payment failure", "Triggered when the user fails to buy a good", "Onpurchfail");

What we just did was added a trigger which will run when a user either completes a purchase or when something else happens(Facebook error, or user cancelled dialog). Let's pick apart the first line so you can understand better.

After the AddCondition( you see:

0 -- This is the numerical index for the condition and must be unique. You cannot have two lines of 1 for example without an error. Also I do not believe they need to be in order.

cf_trigger, -- This is the type of condition we want to use. This could be any number of choices listed in the examples above line 58. Ours means that it will happen everytime a certain action completes( the action is defined in a different file)

"Payment complete", -- When you are choosing which condition to use for an event, this is what will be displayed.

"Payments", -- the category that it appears when deciding which condition to use for our plugin.

"On payment complete", -- How it appears in our event sheet.

"Triggered ...", The description of the condition in case someone needs a little help choosing.

"Onpurchsuccess"); -- This option is the invisible name of the condition which we will be referencing in our next file.

  • 0 Comments

Want to leave a comment? Login or Register an account!