Trying to set a Text object to a private variable, returns 0

This forum is currently in read-only mode.
From the Asset Store
OpenAI TTS
$10 USD
Text-to-Speech plugin.Allows your Construct 3 project to convert written text into spoken words
  • Basically, what I'm trying to do is set it up so the name of the room the player is in is displayed on the HUD. I have several tiled background objects that act as floors, and they all have a private variable named RoomName.

    I want to make it so that when the player overlaps the floor, the variable RoomName for that object is displayed on the HUD, but for some reason no matter what I do, it always displays 0, even when I set the default text for it to something else.

    Any idea what I'm doing wrong?

  • Hard to say. You should post your .cap so someone can take a look.

  • I have a Text object with the default text set to Lobby

    Then, I have a tiled background object, with the RoomName varable set to Storage Room

    And then, on the "On overlapping object" event for the player with the tiled background, I have it setting the value of the Text object to the RoomName of the tiled background.

    If that doesn't help, I'll post the .cap

  • Setting the value? Or setting the text? They're two different things.

    Anyway, it's working for me:

    http://files.getdropbox.com/u/529356/rooms.cap

    If you can't figure out what's wrong from that .cap then you should post yours.

  • use the set text action.

    set it to object('roomname') without string "quotes"

    should work fine

  • Here's the cap file.

    http://www.mediafire.com/?kykye2zjizm

    And yes, sorry. It's setting the text, not the value.

    Also, your .cap file says it was made in a later version of Construct, even though I'm using the most up to date version from the website. Is there a beta out or something?

  • Also, your .cap file says it was made in a later version of Construct, even though I'm using the most up to date version from the website. Is there a beta out or something?

    Oops! Sorry about that

    Yes, there is a new unstable release out:

    But even though it's labeled "unstable" it's actually pretty stable.

    Anyway, here's your problem:

    <img src="http://i42.tinypic.com/e7h2j8.png">

    Your variable type is "Number." Set that to "Text" and you'll be good to go.

  • Hmm, I changed it to text, but it still only returns 0. I wonder what else I'm doing wrong.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • it works fine for me, although I had to change it to text, and add a default value

    <img src="http://files.getdropbox.com/u/1013446/New%20Folder/CustomKeys/CaptureRoom.PNG">

    I just changed roomname to text and typed "hello" next to roomname and it worked fine

  • Ah, I just figured out why It wasn't working.

    2 things, the variable was set to number rather than text, and I was checking the collisions for the purely visual animated part of the player, rather than the square mask I'm using for collisions.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)