Checking for two separate words in a text field

This forum is currently in read-only mode.
From the Asset Store
This pack has plenty of options to help your game background & ambience sound come to life.
  • I'm trying to implement a command input window in my game (pretty much like debug console functions in certain PC games) and I'm currently having trouble regarding a certain function.

    Say I want to spawn a coin worth 5 gold, I'd create an event where if when you press "RETURN" and the text displayed is ".spawncoin5g" then it'll spawn one of that object, that's all working fine.

    But if I want to spawn 10 of those with just one command like ".spawncoin5g 10" how can I code it so that the system checks for two separate words?

    Any help is much appreciated.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 1) Start by isolating the string beginning with ".spawncoin5g":

    substring = Right(theOriginalString, Len(theOriginalString)+ 1 - Find(".spawncoin5g", theOriginalString))

    2) Now look at the second token, if any:

    + NumTokens(substring, " ") > 1

    -> spawnnumber = int(GetToken(substring, 2, " "))

    + Else

    -> spawnnumber = 1

    substring and spawnnumber are variables, of course.

  • Much thanks for the help tulamide, I suspected it had to do with substrings but I didn't know how exactly to use them.

    I'll try and play around with it later with your guide and hopefully I'll be able to get it to work. <img src="smileys/smiley4.gif" border="0" align="middle" />

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