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!
 

Flare

Stops copies me!
Reaction score
662
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)
 

Mr.Tutorial

Hard in the Paint.
Reaction score
42
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)?
 

MerrillPhish

Active Member
Reaction score
10
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?
 

takethat

Active Member
Reaction score
12
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
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
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.
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
889
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?
 

MoonSlinger

I Love using Cheap Tricks... only Results matters
Reaction score
74
[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.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      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