TRMG's Forum Posts

  • Hey there, I've been trying to use some grid based pathfinding plugins, but I was not able to wrap my head around them...

    Is there a way to do this within C2 simply? If not, are there any simple to use ones?

    I'd need it only to do the moving, no fancy rotations/ corner cutting etc.

  • Global text foo="123456"

    System: compare variable foo=str(int(foo))

    Thank you very much!

  • ...Another way would be to convert the text to an int then back to text and compare it with the original text.

    I think the second option is much easier =D

    Do I just make a "number" variable and set it to my text or is there a better way of converting text into int?

    Edit: Actually, that doesn't work, it outputs "NaN" to the int var...

    You might try regex.

    Thanks, but I think I'll go with R0J0's solution.

    Edit: Oh sorry, I thought regex was a plugin =D

    How do I use regex?

  • Hey, I've got a text variable that could contain letters, but I would like to check if it contains only numbers in order to trigger an event.

    How can I check for this?

    Thanks!

  • Like from the end?

    set text to left(text, len(text)-1)

    R0J0 to the rescue =D

    Thank you!

  • Hello,

    I've seen that it is common practice to place objects which will be used later (aka "they will be spawned dynamically") outside the Layout.

    This is somewhat weird to me... Objects with bullet behaviour are flying off screen as soon as the layout starts etc, so you have to place them at the "correct" border of the layout so they not come into the players view during the start while they're flying off.. or place them on a "scrap layout" altogether.

    Is this really the "normal" way of handling the "unused" objects? Or is there a better one?

    You can add a "Destroy outside layout" behaviour on the objects that you want destroyed and that saves you some lines of code.

  • /\</p>

  • Add it to all the others.

    Oh, as a "System" - "compare two values".

    Thank you!

  • When Alt is pressed, Keyboard.StringFromKeyCode(Keyboard.LastKeyCode) will actually return the string alt, so you'd need to also check for that. So add something like:

    Keyboard.StringFromKeyCode(Keyboard.LastKeyCode) <> "alt"

    Where should I add it?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Add the function and browser objects to your project. Add a function and call it "on alt pressed". Next add a "on start of layout" event and add a "browser->execute javascript" action with this:

    "document.addEventListener('keydown', function(e){if(e.altKey)c2_callFunction('on alt pressed',[]);});"[/code:3elnakfb]
    

    I'm trying to check when the player presses a key if Alt is pressed and if it isn't, the key's code is added to the variable "Text"...

    (This was the easiest way that I could come up with to register key codes from only certain keys and not from other. Do let me know if there is a simpler way =D)

    Do you want to post the .capx?

    There's an alternate method here:

    I haven't understood it very well, could you explain it in more detail?

  • How can I detect the "Alt" key when it's pressed?

    I tried doing it with the "Keyboard" - "key is down" condition, but it does not let me choose the "Alt" key (not even in the undetected keys drop-down).

    Then I tried with the "Keyboard" - "key code is down", but I haven't found the key code for "Alt" anywhere...

    Do you guys know the key code for it or another way of doing this?

    Thanks!

  • Here are the posts I was thinking of:

    Those ways give more control than tokenat, but the way to get indavidual words seperated by spaces is the same as the one to get lines except " " is used instead of newline.

    I also know regex could possibly be used somehow.

    Great, thank you very much!

  • ...Beyond that you could use tokenat again to get individual words if you seperate everything with spaces or something. What that's called is a parser and there are also lots of other ways to do it. You could do a forum search for parser to see various examples to maybe get some ideas.

    Hey, I have searched for parser on the forum, but I haven't found anything about them...

    Could you show me how to use tokenat for individual words?

  • To get a certain line from some text you can use the tokenat() expression:

    tokenat(TextBox.text, 0, newline)

    The 0 means get the first line, 1 the second, and so on.

    Beyond that you could use tokenat again to get individual words if you seperate everything with spaces or something. What that's called is a parser and there are also lots of other ways to do it. You could do a forum search for parser to see various examples to maybe get some ideas.

    Awesome, thank you!

  • bump...