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!

edittime.js:44
[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]
runtime.js:139
[code]Cnds.prototype.IsPinnedTo = function (uid)
{
     return !!this.pinObject && this.pinObject.uid === uid;
};[/code]
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}".

edittime.js:65
[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
B
6
Posts: 26
Reputation: 577

Return to Construct 2 General

Who is online

Users browsing this forum: Colludium, Google [Bot] and 8 guests