How do I modify a Text object's Text property in my plugin?

Get help using Construct 2

Post » Fri Jun 05, 2015 4:17 pm

I'm working on a game that will have tiles with words on them. There are algorithms (plural) for the number and placement of the tiles. I have written a plugin that implements the first of the algorithms. It creates the objects and places them into the layout. Everything is good up to that point.

The challenge I have is that I don't see how to set the Text property of a Text object from my JavaScript code. Here is my code that creates the object:

Code: Select all
function createObject( type, x, y ) {
  var layer = runtime.running_layout.layers[type.default_layerindex];
  var object = runtime.createInstance(type,layer);
  object.x = x;
  object.y = y;
  return object;
}


The placement algorithm uses this function to put the text objects on the layout. Works like a charm. But the object does not have a Text property, so I cannot set the object text. In the debugger the object's constructor is shown as pluginProto.Instance and the text properties (Text, Font, Color, etc.) are not available.

So how do I modify the Text-specific object properties?

Also, is this kind of information in the documentation somewhere? I haven't been able to find a good reference for creating and manipulating objects from a plugin. Maybe I'm using the wrong search terms?
B
6
S
1
Posts: 10
Reputation: 420

Post » Fri Jun 05, 2015 9:43 pm

Is there a .text property?
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,418
Reputation: 4,830

Post » Fri Jun 05, 2015 9:50 pm

@gumshoe: no, there is no text property, nor color, nor font, etc.
B
6
S
1
Posts: 10
Reputation: 420

Post » Fri Jun 05, 2015 9:57 pm

Most text-based JavaScript objects have a .text property.

So, assuming your Object is a text-based object, you should just be able to do "object.text". Other than, that, idk.
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,418
Reputation: 4,830


Post » Mon Jun 08, 2015 6:52 pm

@gumshoe my mistake. I had a brain burp. I was looking at the wrong object in the debugger. You are right, the Text object has a text property accessible from the JavaScript plugin (and font property as well).
B
6
S
1
Posts: 10
Reputation: 420

Post » Tue Jun 09, 2015 3:03 pm

Yea, I kind of figured, since I don't think there is any other way of accessing the object text.
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,418
Reputation: 4,830


Return to How do I....?

Who is online

Users browsing this forum: FabianB, totoe and 15 guests