I'm not sure about this, the functions s3rius posted deal with x and y values rather than points. Its usefulness can come in handy when you're playing with dialog positioning. As for the power functions, the function posted earlier "powerOfTwo" checks if a number x is odd or even(?) rather than calculating the result of x². I could be wrong, and I'm typin this in sort of haste so please inform me if im mistaken.
In other words, I guess we could say the XY functions s3rius posted are multi-paradigm? (They work for more than one thing, dialogs, portraits, points)
powerOfTwo checks if the number is a power of two (2,4,8,16,32,...), not if it's odd/even :)
That'd be:
boolIntIsOdd(inti){returni%2==1;}
PowerOfTwo uses the fact that all numbers which are a power of two only have one 1 when written in binary. So you subtact 1 and do a bitwise AND with the original number and, if it's a power of two, the result is 0.
Someone should really make a few functions to make string building easier. Perhaps...
Takes string in format "Blah blah %s blah", replaces %s with parameters.
string sprintf1( string inFormat, string inParam1 );
string sprintf2( string inFormat, string inParam1, string inParam2 );
The solution isn't pretty thanks to Galaxy's lack of overriding, but still, it'd be nice.
Maybe change "%s" to {0}, {1}, etc, since Galaxy can't do anything smart with the parameters but strings really.
In any case, it'd be a much more elegant solution for FuzzYD's string building problems. :P
I'd work something like that up now, but I'm a bit busy with a side project atm.
stringStringFormat(strings,stringp0,stringp1,stringp2){inti;intc=0;string[3]param;param[0]=p0;param[1]=p1;param[2]=p2;while(c<3){i=StringFind(s,"%"+IntToString(c),true);if(i!=-1){s=StringReplace(s,param[c],i,i+1);}c+=1;}returns;}Example:StringFormat("Hello, %0, how are %1 doing%2","Motive","you","?")Output:"Hello, Motive, how are you doing?"
@MTops: Go
I'm not sure about this, the functions s3rius posted deal with x and y values rather than points. Its usefulness can come in handy when you're playing with dialog positioning. As for the power functions, the function posted earlier "powerOfTwo" checks if a number x is odd or even(?) rather than calculating the result of x². I could be wrong, and I'm typin this in sort of haste so please inform me if im mistaken.
In other words, I guess we could say the XY functions s3rius posted are multi-paradigm? (They work for more than one thing, dialogs, portraits, points)
Woops... Apologies about that, you are completely right. :)
But using X and Y or a Point works exactly the same for me. :)
powerOfTwo checks if the number is a power of two (2,4,8,16,32,...), not if it's odd/even :)
That'd be:
PowerOfTwo uses the fact that all numbers which are a power of two only have one 1 when written in binary. So you subtact 1 and do a bitwise AND with the original number and, if it's a power of two, the result is 0.
@s3rius: Go
whoops lol. I must say, everytime you make a post I learn something new :P anyway, heres another one i totally forgot about, image tagging
@FuzzYD: Go
Someone should really make a few functions to make string building easier. Perhaps...
Takes string in format "Blah blah %s blah", replaces %s with parameters.
string sprintf1( string inFormat, string inParam1 );
string sprintf2( string inFormat, string inParam1, string inParam2 );
The solution isn't pretty thanks to Galaxy's lack of overriding, but still, it'd be nice.
Maybe change "%s" to {0}, {1}, etc, since Galaxy can't do anything smart with the parameters but strings really.
In any case, it'd be a much more elegant solution for FuzzYD's string building problems. :P
I'd work something like that up now, but I'm a bit busy with a side project atm.
ugh wish i knew what all this was ive tried learning no succsess
Same.
I doubt anyone could be on the level of S3rius though. He seems too adept:/
Oh, you flatter me :3
@s3rius: Go
Urgh, why I'm not participating in this.. the GUI lover :(
const string STR_FORMAT_BEGIN = "<";
const string STR_FORMAT_END = ">";
string StringFormat1(string toFormat, string arg0){
return StringReplaceWord(toFormat, STR_FORMAT_BEGIN + "1" + STR_FORMAT_END, arg0, 1, true);
}
string StringFormat2(string toFormat, string arg0, string arg1){
string format1 = StringFormat1(toFormat, arg0);
return StringReplaceWord(format1, STR_FORMAT_BEGIN + "2" + STR_FORMAT_END, arg1, 1, true);
}
string StringFormat3(string toFormat, string arg0, string arg1, string arg2){
string format2 = StringFormat2(toFormat, arg0, arg1);
return StringReplaceWord(format2, STR_FORMAT_BEGIN + "3" + STR_FORMAT_END, arg2, 1, true);
}
string StringCleans(string toCleans, string cleansOf){
return StringReplaceWord(toCleans, cleansOf, "", c_stringReplaceAll, true);
}
string StringJoin2(string glue, string piece0, string piece1){
return piece0 + glue + piece1;
}
string StringJoin3(string glue, string piece0, string piece1, string piece2){
return piece0 + glue + piece1 + glue + piece2;
}
string StringJoin4(string glue, string piece0, string piece1, string piece2, string piece3){
return piece0 + glue + piece1 + glue + piece2 + glue + piece3;
}
string StringJoin5(string glue, string piece0, string piece1, string piece2, string piece3, string piece4){
return piece0 + glue + piece1 + glue + piece2 + glue + piece3 + glue + piece4;
}
const string STR_COLOR_BASE = "<c val=\"<1>\"><2></c>";
const string COLOR_RED = "FF0000";
const string COLOR_BLUE = "151B8D";
const string COLOR_GREEN = "00FF00";
const string COLOR_YELLOW = "FFFF00";
const string COLOR_ORANGE = "fe8a0e";
const string COLOR_TEAL = "00FFFF";
const string COLOR_PURPLE = "842DCE";
const string COLOR_GRAY = "808080";
string StringColor(string colored, string colorCode){
return StringFormat2(STR_COLOR_BASE, colorCode, colored);
}