compound object

For developers using the Construct 2 Javascript SDK

Post » Thu May 28, 2015 5:59 pm

@rexrainbow - Thanks for your help!

I can't seem to be able to get a plugin call to work, though: It always returns NaN...

//Runtime
Acts.prototype.SetX = function (tilemap, zX)
{
cr.plugins_.Tilemap.prototype.Exps.PositionToTileX.call(tilemap , fake_ret , zX);
this.testing = fake_ret.value;
};

//edittime
AddObjectParam("TileMap", "Set the tilemap");
AddNumberParam("X", "X");
AddAction(6, af_none, "Get tilemap x ", "", "gets test x", "No Description", "SetX");
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,153

Post » Fri May 29, 2015 3:24 am

tilemap in "Acts.prototype.SetX = function (tilemap, zX)" is an "object type", not an "object instance".

the first parameter of "cr.plugins_.Tilemap.prototype.Exps.PositionToTileX.call(tilemap , fake_ret , zX);" should be "object instance".
So you could try

Acts.prototype.SetX = function (tilemap, zX)
{
var tilemap_inst = tilemap.getFirstPicked();
cr.plugins_.Tilemap.prototype.Exps.PositionToTileX.call(tilemap_inst , fake_ret , zX);
this.testing = fake_ret.value;
};
B
108
S
26
G
267
Posts: 4,455
Reputation: 149,745

Post » Fri May 29, 2015 5:14 pm

@rexrainbow - very nice! I came up with the same solution last night. Thank you for your help, and thanks again for posting stuff on Endless Loop. It is super handy.
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,153

Post » Mon May 02, 2016 8:09 pm

@rexrainbow - oh no! I tried to access the links you provided ad they are down :( (angular torque).


I'm currently trying to figure out how to access another object's behavior (I'm trying to make it so I can have a behavior access itself on another object for an inventory system)

is it something like this:

cr.behaviors_.Custom.prototype.acts.ActionName.call(someother.inst, i, j);
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,153

Post » Wed May 04, 2016 2:58 am

@ruskul

The someother.inst is "the instance of the behavio"in inst.behavior_insts array, see this sample.
B
108
S
26
G
267
Posts: 4,455
Reputation: 149,745

Previous

Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests