HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Help with an Math Script

11-07-2005, 02:09 AM#1
MSTR
I'm not much a JASS pro, i understand it when looking at it, but when it comes to writing one i dont know crap.

I have this script...


Im really good with php, this code is in php, because its the best way i can show it. with a few made up mark ups

function DoAdd ( string $a, string $b )
{
// MAKE SURE STRING A IS THE BIGGER ONE
if( length( $b ) >= length( $a ) )
{
$temp_change = $b;
$b = $a;
$a = $temp_change;
}

// ADD ZEROS IN FRONT OF B TO MATCH LENGTH OF A
for( $i = 1; $1 <= ( length( $a ) - length( $b ) ); $i++ )
{
$b = "0" + $b;
}

// TURN STRING TO INT
for( $i = 1; $i <= length( a); $i++ )
{
$temp_a[$i] = string_to_int( substring( $a, $i, $i ) );
$temp_b[$i] = string_to_int( substring( $b, $i, $i ) );
$count = $i;
}

// ADD THEM UP
for( $i = 1; $i <= $count; $i++ )
{
$temp_c[$i] = $temp_a[$1] + $temp_b[$i] + $carried;

if( $temp_c >= 10 )
{
$temp_c[$i] = substring( $temp_c[$i], 2, 2 );
$carried = substring( $temp_c[$i], 1, 1 );
}
else
{
$carried = 0;
}
}

for( $i = 1; $i <= $count; $i++ )
{
$c = INT_TO_STRING( $temp_c[$i] ) + $c;
}

$c = INT_TO_STRING( $carried ) + $c;

return c
}



ALSOOOOOOOOOOOOOOOOOOOOOOO
this is to add really big ass numbers.
Purpose, for encrypting a save_code, and compressing save_code
11-08-2005, 06:19 PM#2
Anitarf
Well, I would try to help, but I don't know php, so I can't really tell what you want. But, if you need a save code, you can just use Lord Vexorian's codemaker engine :)
11-09-2005, 12:21 AM#3
MSTR
i know he has a code maker, but doesnt fit my standards. I want my encryption code compressed.
That in can store username, gold, lumber, level or exp, items, items in chest, strength, agility, intelligence, points, quest completed, kills, deaths.

Now tell me if his code system can do that?
11-09-2005, 03:31 PM#4
iNfraNe
I know php, but really.. its 2 much code to read if you dont explain what it does in detail.

So, either do that, or just tell me where you dont know what the jass variant is..

its all rather simple

Your function would look like this:
Collapse JASS:
function DoAdd takes string a, string b returns integer
    //code
endfunction

loops are made like this:
Collapse JASS:
loop
    exitwhen (condition, f.e. i > StringLength(a)-StringLength(b) )
    //code
endloop
no, jass doesnt have for loops, but who cares to much about that anyway, all loops act the same.

in jass you cannot declare a variable by setting it, like in php, and you can neither change its type.

to declare variables inside a variable use the syntax:
Collapse JASS:
local type name

for searching for the basic commands like int2string, its all very easy in jass, I2S = integer 2 string, S2I = string to integer. R2I = real to integer etc etc.

for other commands and types I suggest you download jassshoppro from www.wc3sear.ch . Its a GREAT program.

Btw, goodluck getting that code done while still being userfriendly. If you get it under 30 chars then goodjob.
11-10-2005, 10:21 PM#5
MSTR
Well it simple adds 2 big numbers. that normal int cant hold. Integers have a limit in value. So the number would be stored as a string and not a int, it adds two int values.

Ill make a new topic with how my encryption code will work. If someone wants to use the method. Because it think ill stop working on it for a while. Till i learn more JASS. I can read, but not write