whats bj in jasscraft? i see alot of commands on the native list with bj and without bj like
SubString
SubStringBJ
whats the diffrence?
[JASS] bj?!
Moderator: Cheaters
-
- Super Moderator
- Posts: 3198
- Joined: February 24th, 2009, 1:31 pm
- Location: JEW LAND
- Been thanked: 1 time
-
- Senior Member
- Posts: 195
- Joined: February 13th, 2008, 5:30 pm
Re: [JASS] bj?!
BJ means the command is not a native function, but actualy it's own function.
example: SetHeroLevelBJ and SetHeroLvl
SetHeroLevelBJ:
Meaning, with SetHeroLevelBJ u can add or substract lvls, while SetHeroLevel is only able to add lvls (because u need UnitStripHeroLevel to substract levels)
So, basicly, commands with BJ have a hidden function, which usualy makes it more usefull.
Altough, sometimes the BJ command uses unneeded code, which would make the trigger slower then it needs to be (like, there is no need to use SetHeroLevelBJ and run the entire block of code everytime, if you aren't going to substract levels with that trigger.)
example: SetHeroLevelBJ and SetHeroLvl
SetHeroLevelBJ:
Code: Select all
function SetHeroLevelBJ takes unit whichHero, integer newLevel, boolean showEyeCandy returns nothing
local integer oldLevel = GetHeroLevel(whichHero)
if (newLevel > oldLevel) then
call SetHeroLevel(whichHero, newLevel, showEyeCandy)
elseif (newLevel < oldLevel) then
call UnitStripHeroLevel(whichHero, oldLevel - newLevel)
else
// No change in level - ignore the request.
endif
endfunction
So, basicly, commands with BJ have a hidden function, which usualy makes it more usefull.
Altough, sometimes the BJ command uses unneeded code, which would make the trigger slower then it needs to be (like, there is no need to use SetHeroLevelBJ and run the entire block of code everytime, if you aren't going to substract levels with that trigger.)
-
- Junior Member
- Posts: 44
- Joined: April 12th, 2007, 2:43 am
- Location: STALKER!!!
Re: [JASS] bj?!
The difference between SubString and SubStringBJ is:
SubStringBJ starts one character before because in GUI (where SubStringBJ is used), if you wanted to select something from....
And the characters you want are abcd, you would put in SubStringBJ(Alphabet, 1, 4) and it would do:
Here's why, with SubStringBJ, you choose the first integer as which numbered character you want to start at. So, 1 corresponds to "a", 2 to "b", 3 to "c" etc etc. SubString, however, is set between letters. So 0 would correspond to the space between "" (there is nothing before "a") and "a" and if you wanted to select only "a", you'd put in 0, 1.
|a|b|c|d|
Each | is a spot in SubString starting from 0. If you wanted to select abc, 0, 3. ab? 0, 2. etc etc etc.
Code: Select all
function SubStringBJ takes string source, integer start, integer end returns string
return SubString(source, start-1, end)
endfunction
Code: Select all
string Alphabet = abcdefghijklmnopqrstuvwxyz
Code: Select all
SubString(Alphabet, 0, 4)
|a|b|c|d|
Each | is a spot in SubString starting from 0. If you wanted to select abc, 0, 3. ab? 0, 2. etc etc etc.
"Sticks and stones may break my bones, but words will never hurt me!" Ouch! MY ARM!! YOU BROKE MY ARM!!