HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

NEW! JASS function pack, please contribute

07-28-2003, 05:02 PM#1
dataangel
I'm basically looking to compile a bunch of new functions that people can include in their maps by copying and pasting them into the top of the .j file (in the trigger editor click the filename of your map -- it's at the very top of the categories -- to see where to do this).

What this thread is basically for is for people to debug the functions I've completed already, and to contribute their own functions. The only requirement is that no globals must be used -- these must be self contained functions.

Without further adu, here's the code so far:


MEH -- code shows up too crappily in window, look to next post for attachment.
07-30-2003, 05:25 PM#2
dataangel
Updated: Added the functions I didn't understand, and the rest of AIAndy's functions (whoops)
07-30-2003, 07:53 PM#3
Aiursrage2k
I put them in a text file as well, because it was stretching the form. Added three functions rewrote two of the other ones.
07-31-2003, 12:41 AM#4
Scio
data you're not keeping me updated about changes :////
07-31-2003, 07:49 AM#5
Jatz
I'm just curious as to how you'd use one of these functions? Let's say I wanted to store the result of factorial(2) in a variable called temp.

I'd create a variable called temp of type integer.

and I'd probably run the Action: Custom Script: 'call factorial(2)'....right?

But how can I use the value the function returns?
07-31-2003, 09:08 AM#6
AIAndy
@Jatz: If you created that variable in GUI, then use this:
Custom Script: 'set udg_temp = factorial(2)'

I'd like to contribute some functions to that pack, attached them as a text file.
An exp function for integers, an encode and a decode function for using integers as arrays of boolean and a function to sync any integers (for example to retrieve camera information).
07-31-2003, 02:37 PM#7
Peppar
Felt like contributing with a bunch of string functions. I have
tested them to a certain degree but they aren't foolproof.
Includes some other functions of varying quality.

GetSubString, PositionCameraIfInRangeForPlayer, ByteToHex,
ColorToString, ToLower, ToUpper, InsertHotkey,
InsertHotkeyColor.

EDIT: Made some more string functions and some fluff functions
to make the life of a programmer easier.

LeftTrim, RightTrim, Trim, LeftString, RightString, MidString,
MidStringLength.

EDIT: Last upload is on page 2
08-02-2003, 06:35 AM#8
dataangel
whoa, sudden function influx! I'll get straight to adding these =)
08-02-2003, 06:52 AM#9
dataangel
Quote:
Originally posted by AIAndy
@Jatz: If you created that variable in GUI, then use this:
Custom Script: 'set udg_temp = factorial(2)'

I'd like to contribute some functions to that pack, attached them as a text file.
An exp function for integers, an encode and a decode function for using integers as arrays of boolean and a function to sync any integers (for example to retrieve camera information).


Whoa, sync integer is much cleaner than what I was using -- although I'm having trouble digesting parts.

The part where you set source_int[0] to 0 or 1, I get that you're just signing the integer so it's negative or positive. What I don't understand is how the operation for converting the rest of it works:

Code:
  loop
    exitwhen i >= bits_number
    set source_int[i] = ModuloInteger(sum, 2)
    set sum = sum / 2
    set i = i + 1
  endloop

You store whether or not the number is odd or even, then you halve it -- why?

Also -- why doesn't it use the encode/decode functions you just defined?
08-02-2003, 07:07 AM#10
dataangel
Quote:
Originally posted by Peppar
Felt like contributing with a bunch of string functions. I have
tested them to a certain degree but they aren't foolproof.
Includes some other functions of varying quality.

GetSubString, PositionCameraIfInRangeForPlayer, ByteToHex,
ColorToString, ToLower, ToUpper, InsertHotkey,
InsertHotkeyColor.

EDIT: Made some more string functions and some fluff functions
to make the life of a programmer easier.

LeftTrim, RightTrim, Trim, LeftString, RightString, MidString,
MidStringLength.


It maybe that it's 1AM, but I'm having the damndest time trying to figure out what your GetSubString function does. Could you explain?

I also feel very stupid at this moment for not realizing that "exitwhen true" could be used for a break;

:P

EDIT: I've added most of your functions, except GetSubString (need clarification so I can add a comment(s)), and the MidString, functions, because I don't really see what their usefulness is in wake of the SubString function. Feel free to enlighten me though =)
08-02-2003, 07:12 AM#11
Panto
Greets. Thought I'd make a recommendation.
I was confounded that they don't have a "Player Group is Empty" condition, like the "Unit Group is Empty" one. Is that something that someone could create?
08-02-2003, 07:16 AM#12
dataangel
Quote:
Originally posted by Panto
Greets. Thought I'd make a recommendation.
I was confounded that they don't have a "Player Group is Empty" condition, like the "Unit Group is Empty" one. Is that something that someone could create?


Yes, infact, that'd be ridiculously easy, I'll add it. :)

if numplayers in playergroup == 0, return true
08-02-2003, 07:28 AM#13
dataangel
Quote:
Originally posted by Aiursrage2k
I put them in a text file as well, because it was stretching the form. Added three functions rewrote two of the other ones.


Could you explain what the function ibox2 does?

Also, I recoded charIsNumber to be even simpler:

Code:
function CharIsNumber takes string whichChar returns boolean
    local integer i = 0

    loop
        exitwhen i >= 10
        if whichChar == I2S(i) then
            return true
        endif 
        set i = i + 1
    endloop

    return false
endfunction

BTW, what's the philosophy/reasoning behind a function only having one return statement? Performance wise it's negligible, especially if you have to declare a local var in order to keep it at 1.
08-02-2003, 07:42 AM#14
Panto
Quote:
if numplayers in playergroup == 0, return true
I'm trying to put this together tonight. What's the format for taking a Player Group?
08-02-2003, 08:13 AM#15
dataangel
Quote:
Originally posted by Panto
I'm trying to put this together tonight. What's the format for taking a Player Group?


Download the pack again, I already added it ;)

But to answer your q: player group's in JASS are of type force