Suggestion: "Pinned to UID" condition

Discussion and feedback on Construct 2

Post » Sat Feb 09, 2013 10:43 pm

Hi, I ran into a scenario where I had multiple characters on screen with effect items pinned to them. Whenever a character dies, I need to destroy the effects associated with that character. My first solution was to add instance variables to all characters. When creating each effect, I would do something like:
Effect1: Pin Pin to Character (position and angle)
Character: Set Effect1UID to Effect1.UID

And then when a character dies, choose effect instance by:
Effect1: Pick instance with UID Character.Effect1UID

It would be nicer if I didn't need to set and refer to the instance variable like that. It would be nicer if, on death, I could simply say:
Effect1: Pinned to UID Character.UID

I've included code to add that functionality to make it super easy for you if you think it's a good idea!

[code]AddNumberParam("UID", "The UID of the object this object is pinned to.");
AddCondition(1, cf_none, "Is pinned to UID", "", "{my}ned to UID <b>{0}</b>", "True if object is pinned to the object with given UID", "IsPinnedTo");[/code]
[code]Cnds.prototype.IsPinnedTo = function (uid)
     return !!this.pinObject && this.pinObject.uid === uid;
Also, if you do agree that this change is useful, it's probably worth removing the text "Pin " on this line since "Pin" is implicit in "{my}".

[code]//results in "Pin Pin to obj (method)"
AddAction(0, af_none, "Pin to object", "", "{my} Pin to {0} ({1})", "Pin the object to another object.", "Pin");
//results in "Pin to obj (method)"
AddAction(0, af_none, "Pin to object", "", "{my} to {0} ({1})", "Pin the object to another object.", "Pin");
[/code]Cowdozer2013-02-09 22:45:25
Posts: 26
Reputation: 727

Return to Construct 2 General

Who is online

Users browsing this forum: lol525, shanek32 and 12 guests