Hundreds of features to explore
Games made in Construct
Your questions answered
Popular & trusted by schools and Universities world-wide
Construct 3 runs in the browser & works offline
Students do not need accounts with us
Our educational partners
Free education resources to use in the classroom
World class complete documentation
Official and community submitted guides
Learn and share with other game developers
Upload and play games from the Construct community
Game development stories & opinions
Is it possible to do the following from the below event:
If textinput1.text="word" > perform action
My aim is to highlight the 'or' and perform an action based on whether this is true or not. So I need it as a condition.
Is this possible?
What do you mean by "highlight"?
If you want to test if a string contains substring 'or', you need to use find() expression:
System Compare two values -> find(textinput1.text, "or") greater or equal 0 : perform action
So basically I want to check if a player is using a curse word as part of his name at the start of the game. I have a text box where he enters his game name. I know how to highlight entire words such as "curse1" but not words that are hidden in the middle of words, like "Name1Curse1Name2".
I'd like to bring up a message if "Curse1" is hidden in the middle of a name like above.
In Textinput1 check to see if entered text contains the word or string "Curse1"
Textbox1 shows message - word is not permitted.
In this case you need to use find() expression, see my previous comment.
Shoukdn't the comparison be 'equal to'.....'1' - perform action
its nor working for some reason
No, find() returns the position of substring if found, or -1 (minus 1) if not found. That's why you check if it's equal or greater than 0.
find("abcdef", "abc") will return 0
find("abcdef", "cd") will return 2
find("abcdef", "xyz") will return -1
Thanks it works now :)
Instead of typing in the letters to be checked, is it possible to add an array in the field? So that all words in a single array can be checked against the text box entry?
Yes, you can do something like this:
Set variable badWordFound to 0
Array For each element X
Find(Textbox.text, Array.CurValue)>=0 Set badWordFound to 1
Develop games in your browser. Powerful, performant & highly capable.
Seems to be working but only if I have 1 entry in the array.
If I add multiple the textbox shows up empty each time, sometimes shows the last entry I made....not sure why.
I might just use your first example.
It would be much easier to help you if you post screenshots of your code.
Again, your mistake is that you are executing everything on every tick!
Create a button that submits the text and move these events into "On button clicked":
Also, make sure that all cells in the array contain data. If any cell is empty, then find() expression will return 0. Or add another condition - Array.CurValue not equal ""
But if I don't have a second condition to check if a word 'does not exist' how can I change the textbox back to empty (not showing the 'not allowed' message)?
Just try my code and you'll see that it works. Note that the variable is local (defined inside the event). It gets reset to 0 every time the event is executed.
dop2000 you are a genius.