Substring Explanation?

Killerphill

New Member
Reaction score
1
hello all.

I need someone to throughly explain "Substrings" for me. I dont have a clue what they do and i dont understand the whole "Substring(String,1,5). What is the 1,5 anyway? lol

anyway please help me :)

thanks in advance.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
(I believe) 1 is where it starts, and 5 is where it ends.
So "HelloThere" would become "Hello".

[del]I may be wrong though :eek: ![/del]

EDIT: Seems I'm right ;) !
 

Ryuu

I am back with Chocolate (:
Reaction score
64
It is basically a portion of a string.
So

Trigger:
  • Substring(Game,2,3)


gives you 'am'.
Why?

Because the second and third letters of 'Game' are:
'am'.

Need more xplanation?
Here goes.

Code:
1-2-3-4
[b]G-A-M-E[/b]

Now do you get it?
Right.

In more complicated situations.

Trigger:
  • Trigger
    • Events
      • Player - Player 1 (Red) types a chat message containing game as An exact match
    • Conditions
      • (Substring((Entered chat string),2,3)) Equals to "am"
    • Actions
      • Player - Victory (Triggering player)


More complicated:

Trigger:
  • Trigger
    • Events
      • Player - Player 1 (Red) types a chat message containing game as A substring
    • Conditions
      • (Substring((Entered chat string),6,7)) Equals to "20"
    • Actions
      • Player - Victory (Triggering player)


The above code detects if the player types 'game 20'.
Now you don't get it?

What the heck.

Code:
1-2-3-4-5-6-7-8-9-...
[b]G-A-M-E- -?-?-?-?-...[/b]
        ^ A space

The '...' represents that the string could contain more stuff, but we don't care.
So this code:

Trigger:
  • Trigger
    • Events
      • Player - Player 1 (Red) types a chat message containing game as A substring
    • Conditions
      • (Substring((Entered chat string),6,7)) Equals to "20"
    • Actions
      • Player - Victory (Triggering player)


Checks if '6,7' of 'game"..."' is '20'.
Hence:

Code:
1-2-3-4-5-[COLOR="Red"]6-7[/COLOR]-8-9-...
[b]G-A-M-E- -[COLOR="Red"]?-?[/COLOR]-?-?-...[/b]
        ^ A space

We fill in the values up with:

Code:
1-2-3-4-5-[COLOR="Red"]6-7[/COLOR]-8-9-...
[b]G-A-M-E- -[COLOR="Red"]2-0[/COLOR]-?-?-...[/b]
        ^ A space

Remove the hyphens, you will get

Code:
12345[COLOR="Red"]67[/COLOR]89...
[b]GAME [COLOR="Red"]20[/COLOR]??...[/b]
    ^ A space

Just a few more examples.
This code:

Trigger:
  • Trigger
    • Events
      • Player - Player 1 (Red) types a chat message containing game as A substring
    • Conditions
      • (Substring((Entered chat string),6,9)) Equals to "blal"
    • Actions
      • Player - Victory (Triggering player)


Represents this:

Code:
1-2-3-4-5-6-7-8-9-...
[b]G-A-M-E- -?-?-?-?-...[/b]
        ^ A space

Code:
1-2-3-4-5-6-7-8-9-...
[b]G-A-M-E- -B-L-A-L-...[/b]
        ^ A space

Code:
1-2-3-4-5-[COLOR="Red"]6-7-8-9[/COLOR]-...
[b]G-A-M-E- -[COLOR="Red"]B-L-A-L[/COLOR]-...[/b]
        ^ A space

Code:
12345[COLOR="Red"]6789[/COLOR]...
[b]GAME [COLOR="Red"]BLAL[/COLOR]...[/b]
    ^ A space

Does that clears up anything?
No?
Please ask.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top