Understanding Integer A & Substring Functions

Mr.Tutorial

Hard in the Paint.
Reaction score
42
Alright, so I kind of understand integer A but I don't understand substring at all. I want a better knowledge of these to help make smaller triggers.

1: Explain Substring and how the "2,4" stuff works... (Detail Please)

What I understand of this: None

2: Please also explain integer A and different options in which it can be used.
What I understand of this: I know you can loop integer a from 1-10 and allow it to be used by using (Integer A) function, but what else can you use it for?

If you can't explain, and you know of any tutorials or such please post, thanks! Good explanation gets reputation!
 
1) Substring (x, y) takes the (x)th and (y)th term in your given string (spaces included) and forms a new string from that.

Example:
Main string = Warcraft
Substring (1, 3) = War
Substring (2, 5) = arcr
Substring (4, 8) = craft

What I understand of this: I know you can loop integer a from 1-10 and allow it to be used by using (Integer A) function, but what else can you use it for?

You can use it for looping through players (let's say if you want to check which players have more than 1000 gold, just do an integer loop and check Player (integer A)'s current gold.

Can also be used for looping through arrays (if you want to cycle through X units in an array [assuming their array values are consecutive numbers, its hard to skip numerous values with an integer loop], but those X units aren't in a single group)
 
1) Substring (x, y) takes the (x)th and (y)th term in your given string (spaces included) and forms a new string from that.

Example:
Main string = Warcraft
Substring (1, 3) = War
Substring (2, 5) = arcr
Substring (4, 8) = craft



You can use it for looping through players (let's say if you want to check which players have more than 1000 gold, just do an integer loop and check Player (integer A)'s current gold.

Can also be used for looping through arrays (if you want to cycle through X units in an array [assuming their array values are consecutive numbers, its hard to skip numerous values with an integer loop], but those X units aren't in a single group)

I still don't understand how substring works. So if the main substring is Warcraft why would "War" be (1, 3)?
 
For Loops are the best thing ever once you learn to use them here is a trigger I use for Spawning in TD's. It uses For loop with Int A.

First off I Set An Array Regions like this...

Set Spawn_Region[1] = 1 <gen>
Set Spawn_Region[2] = 2 <gen>
And so forth


Then when i want to spawn...
instead of typing alot of code i Just use one simple For Loop


For each (Integer B) from 1 to 20, do (Actions)
Loop - Actions
-------- Spawn Units --------
For each (Integer A) from 1 to 8, do (Actions)
Loop - Actions
Set Temp_Point = (Center of Spawn_Region[(Integer A)])
Unit - Create 1 Level_Unit_Type[(Level)] for Player 12 (Brown) at Temp_Point facing Default building facing degrees
Custom script: call RemoveLocation(udg_Temp_Point)


That Make Sense?
 
it is because war is the 1st aph to the 3rd aph in the word "warcraft"

the number (x,y) is for u decide from which aph to which aph u want to taken out from the main string


technically i used this to detect how many kills you want to have in my map
eg: you type -km200

i use the substring to take out 200 by using (4,6)

Code:
off topic:
then i convert the string to integer to set max kills
 
If you put substring(1, 3) you take letter number 1, 2 and 3 from the string.

Substring(1, n) takes letter number 1, 2, 3, 4, ...n.

Example:

Warcraft

Substring (1, 3)

1st letter: W
2nd letter: a
3d letter: r

Substring(1, 3) = W+a+r = War.
 
Let me take another approach.

12345678
warcraft

Each letter corresponds with the number above it.

(1, 3)

Same as saying "From 1 to 3"
Well, which letter is 1?

12345678
warcraft

Looks like "w"

So, which one is 3 (the end)?

Looks like "r"

Include any in between and give that back to you.

"war"

There you go. Pretty easy, no?
 
[SIZE="+1"]For Loop Integer[/SIZE],
basically the limit to the usage can only be stopped by your imagination.

-> Mostly it is used with Arrays to make repetitive task simple, as the example provided above regarding spawning creeps.
-> You can used it with regards to player functions to since all players come with a player number (as mentioned above)
-> It is also used in multiboards to set all necessary cells to certain color, and/or to display icons

Or you can do something more interesting like: :nuts:
Code:
Running Explosion
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Run Explosion
    Actions
        For each (Integer B) from 1 to 1000, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Active[(Integer B)] Equal to False
                    Then - Actions
                        -------- Initialization --------
                        Set Active[(Integer B)] = True

                        -------- These attributes are unique to each casting --------
                        (Triggering unit)
                        (Target point of ability being cast)
                        (Target unit of ability being cast)

                        -------- Run Spell Effect --------
[COLOR="Red"]                        For each (Integer A) from 1 to 10, do (Actions)
                           Loop - Actions 
                              Create a Goblin Land Mine at (Position of (Triggering unit))
                              Explode (Last Created Unit)
                              Wait 0.5 second[/COLOR]

                        -------- Free-Up the Space you are using --------
                        Set Active[(Integer B)] = False
                        Skip remaining actions
                    Else - Actions
                        Do nothing
        Game - Display to (All players matching ((Owner of (Triggering unit)) Equal to (Matching player))) the text: Spell Fizzle As there are already 1000 instance happening

I think I am the only person using Loops in this way, but as mentioned, their uses are only limited by your imagination. :thup:

With the above code, you can have up to 1000 units doing the same spell at the same time. Personally, I think you computer would lag itself to death before you need to get more instances.... :D

Anyway, I didn't remove leaks, so if you intend to use it, remove the leaks first. :p
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top