Flik: Sphere Central!
Docs!
Sphere Docs
chrono -- I try to teach chrono some JavaScript

<Chrono[Fliks-Skool]> I just want to know the basics .. I have figured out some of it .. and can tear apart other scripts to figure more out
<Flik9x> Okay :D
<Flik9x> Alright then...
<Flik9x> What do you know already? :D
<Chrono[Fliks-Skool]> functions ...
<Chrono[Fliks-Skool]> variables .. sorta
<Flik9x> Lets start with something easy then...
<Flik9x> /* this is a
<Flik9x> multiline comment */
<Flik9x> ;)
<Flik9x> // singleline comment
<Flik9x> if(something) DoStuff();
<Flik9x> is the same as:-
<Flik9x> if(something){
<Flik9x> DoStuff();
<Flik9x> }
<Chrono[Fliks-Skool]> as is:
<Chrono[Fliks-Skool]> if(something){
<Chrono[Fliks-Skool]> DoMore();
<Chrono[Fliks-Skool]> DoMore();
<Chrono[Fliks-Skool]> DoMore();
<Chrono[Fliks-Skool]> }
<Chrono[Fliks-Skool]> right?
<Flik9x> Ok, so you understand blockstatements and statements? :D
<Chrono[Fliks-Skool]> nope .. I don't understand a word you said
<Flik9x> err:-
* Chrono[Fliks-Skool] might .. but doesn't know he does
<Flik9x> statement
<Flik9x> {
<Flik9x> statement
<Flik9x> statement
<Flik9x> statement
<Flik9x> }
<Chrono[Fliks-Skool]> yeah .. I know that
<Flik9x> statement ... is just a one line statement...
<Flik9x> {
<Flik9x> statement
<Flik9x> statement
<Flik9x> statement
<Flik9x> }
<Flik9x> Is a block statement...
<Flik9x> So...
<Flik9x> if(condition) statement;
<Flik9x> That makes sense now? :D
<Chrono[Fliks-Skool]> yeah .. just didn't know what it was called
<Flik9x> Just as long as you know.
<Flik9x> loops then ;)
<Flik9x> while(condition) statement;
<Chrono[Fliks-Skool]> if(condition) statement; .. hmm
<Chrono[Fliks-Skool]> ok .. I see
<Flik9x> var i = 0;
<Flik9x> while(i < 50){
<Flik9x> i = i + 1;
<Flik9x> }
<Flik9x> So...
<Flik9x> That is the same as...
<Chrono[Fliks-Skool]> ok .. so that means:
<Flik9x> That means:-
<Chrono[Fliks-Skool]> i =0 .. but when i is less than 50 i=i_1
<Flik9x> err
<Chrono[Fliks-Skool]> i=i+1 rather
<Chrono[Fliks-Skool]> no?
<Flik9x> That means... continously do i = i + 1... until i is less than 50...
<Flik9x> So
<Flik9x> var i = 0;
<Flik9x> while(i < NumberOfPlayersInParty){
<Flik9x> ShowStats(NumberOfPlayersInParty[i]);
<Flik9x> i = i + 1;
<Flik9x> }
<Flik9x> err
<Flik9x> whoops :P
<Flik9x> while(i < NumberOfPlayersInParty){
<Flik9x> ShowStats(party[i]);
<Flik9x> i = i + 1;
<Flik9x> }
<Flik9x> i = i + 1; // this is the same as:- i += 1; // this is the same as ++i;
<Flik9x> So...
<Flik9x> for(var i = 0; i < NumberOfPlayersInParty; ++i){
<Flik9x> ShowStats(party[i]);
<Flik9x> }
<Chrono[Fliks-Skool]> thats the same as:
<Chrono[Fliks-Skool]> var i = 0;
<Chrono[Fliks-Skool]> <Flik9x> while(i < NumberOfPlayersInParty){
<Chrono[Fliks-Skool]> <Flik9x> ShowStats(NumberOfPlayersInParty[i]);
<Chrono[Fliks-Skool]> right?
<Flik9x> Yes :D
<Chrono[Fliks-Skool]> err .. well .. you know what I mean
<Flik9x> So if party is an array of player objects...
<Flik9x> for(var i = 0; i < party.length; ++i) ShowStats(party[i]);
<Flik9x> Do you know switches? :D
<Chrono[Fliks-Skool]> no
<Flik9x> if(blah){}else if(blah){}else if(blah){} ...
<Flik9x> can become:-
<Flik9x> switch(something){
<Flik9x> case (blah): /* insert code here */; break;
<Flik9x> case (blah): /* insert code here */; break;
<Flik9x> case (blah): /* insert code here */; break;
<Flik9x> }
<Chrono[Fliks-Skool]> ahh ok
<Flik9x> Arrays are the most useful thing though...
<Flik9x> var Stuff = new Array(item1, item2, item3);
<Flik9x> Stuff[Stuff.length] = item4; // adds item4 at Stuff[3]...
<Chrono[Fliks-Skool]> var Stuff = new Array(item1, item2, item3, item4);
<Chrono[Fliks-Skool]> would be the outcome?
<Flik9x> You could do that ;)
<Flik9x> var i = 0;
<Flik9x> var Stuff = new Array();
<Chrono[Fliks-Skool]> wait .. go back to ...
<Flik9x> Stuff[i] = blah;
<Flik9x> Huh?
<Chrono[Fliks-Skool]> var i = 0;
<Chrono[Fliks-Skool]> while(i < 50){
<Chrono[Fliks-Skool]> i = i + 1;
<Chrono[Fliks-Skool]> }
<Chrono[Fliks-Skool]> I don't totally understand that
<Flik9x> Ok
<Chrono[Fliks-Skool]> i would do what until it was < 50
<Flik9x> Yes.
<Flik9x> If i was = 50... it wouldn't be < 50 anymore, so it would stop doing statements ;)
<Chrono[Fliks-Skool]> oh .. so I repeats itself while i<50 ?
<Flik9x> Yes.
<Chrono[Fliks-Skool]> ok .. I understand now
<Flik9x> while(condition)
<Flik9x> condition is i < 50
<Chrono[Fliks-Skool]> ok .. explain i = i +1
<Chrono[Fliks-Skool]> because thats not logical =P
<Flik9x> Shall I run "statements" again? I don't know is i < 50? Yes, it is. Okay then, I'll run "statements" again. ;)
<Flik9x> i = i + 1;
<Flik9x> That is logical.
<Chrono[Fliks-Skool]> how can a variable equal itself +1??
<Flik9x> Why not? :)
<Flik9x> var counter = 500; // 500 hits on my webpage...
<Flik9x> counter = counter + 1; // 1 more hit ;)
<Chrono[Fliks-Skool]> ohhh
<Chrono[Fliks-Skool]> i is NOW equal to i +1
<Flik9x> Yeah ;P
<Flik9x> Is this more logical:-
<Flik9x> var tmp = i;
<Flik9x> i = tmp + 1; // ? :D
<Chrono[Fliks-Skool]> yeah =P
<Flik9x> So whats wrong with i = i + 1 :D
<Flik9x> A variable is like a box ;)
<Flik9x> left = right;
<Flik9x> ;-)
<Flik9x> The left side is SET to the right side.
<Chrono[Fliks-Skool]> lol
<Flik9x> var a = 2;
<Flik9x> var b = 5;
<Flik9x> b = a + 99;
<Flik9x> 5 = 2 + 99; // ? ;)
<Flik9x> Which is why the left hand is almost ignored. :)
<Chrono[Fliks-Skool]> but 5 can't equal 101 is what I am saying
<Flik9x> You are not saying 5 = 2 + 99
<Flik9x> You are saying 'b' = 2 + 99
<Flik9x> Think about it :D
<Chrono[Fliks-Skool]> ohhhhhhhhhh
<Flik9x> The variable shall now be 99...
<Flik9x> It doesn't care what it was ;)
<Chrono[Fliks-Skool]> the variable should be what it was +99 you mean
<Flik9x> No.
<Flik9x> That would be:- a = a + 99
<Chrono[Fliks-Skool]> oh ok
<Flik9x> 'a' is now equal to ((a) + 99)
<Flik9x> It gets the value of a, which is 2...
<Flik9x> And then says:-
<Flik9x> a = (2 + 99)
<Chrono[Fliks-Skool]> a would = 101 .. or would a = 99?
<Chrono[Fliks-Skool]> 101
<Flik9x> if a is 2, and 99 is 99 (duh)
<Flik9x> Then if I did:-
<Flik9x> a = a + 99
<Flik9x> a would then be 101
<Chrono[Fliks-Skool]> yeah
<Chrono[Fliks-Skool]> and if b = a + 99 ... b =101
<Flik9x> a += 99; // heheh ;)
<Flik9x> Yes. :P
<Chrono[Fliks-Skool]> even if b WAS 5
<Flik9x> Yeah :D
<Chrono[Fliks-Skool]> doesn't matter .. thats what it is now =)
<Flik9x> left = right; (I don't care what left is, its not equal to the right...)
<Flik9x> var a = 20;
<Flik9x> var b = 40;
<Flik9x> a += b;
<Flik9x> What is a now? :)
<Chrono[Fliks-Skool]> hmmm
<Chrono[Fliks-Skool]> a = b hehehe
<Flik9x> No.
<Flik9x> :P
<Flik9x> a = a + b; // or a += b;
<Chrono[Fliks-Skool]> ahh ok
<Flik9x> So a would be 60 :P
<Chrono[Fliks-Skool]> yeah
<Chrono[Fliks-Skool]> I didn't understand the A += B
<Flik9x> a += b;
<Chrono[Fliks-Skool]> so that is the same as a =+ b ?
<Flik9x> This means... a is now equal to a + b...
<Flik9x> no
<Chrono[Fliks-Skool]> ahh ok
<Flik9x> a += b
<Flik9x> is the same as:- a = a + b
<Chrono[Fliks-Skool]> ok .. I understand that now
<Flik9x> so a = a + 1
<Flik9x> Can be:-
<Flik9x> a = a + 1;
<Flik9x> a += 1
<Flik9x> ++a
<Chrono> yeah
<Flik9x> Hmmm ? whoa : heh;
<Chrono> what happened to the 1 in ++a ?
<Flik9x> ++a is :- a = a + 1
<Chrono> just a different way of putting it I know .. but I want to know how it got that way
<Flik9x> ++a
<Flik9x> Is called increment...
<Flik9x> We increase a by 1.
<Chrono> oh ok
<Chrono> and +++a is?
<Flik9x> Invalid code ;-)
<Chrono> thought so =)
<Flik9x> :D
<Chrono> ok .. I got it now
<Flik9x> a = a - 1
<Chrono> back to ... arrays and switches
<Flik9x> a -= 1
<Flik9x> --a
<Flik9x> ;)
<Chrono> thats just the opposite
<Flik9x> Yeah :D
<Flik9x> a = a * 1
<Flik9x> a *= 1
<Flik9x> ;D
<Chrono> **a
<Chrono> ?
<Flik9x> nope :P
<Flik9x> ++a and --a are the only ones that exist ;)
<Flik9x> a = a / 1
<Chrono> oh
<Flik9x> a /= 1
<Flik9x> ;D
<Flik9x> ;)
<Flik9x> Arrays and switches! :D
<Flik9x> switch(a){
<Flik9x> case (0): AIsZero(); break;
<Chrono> explain plz
<Flik9x> case(1): case(2): case(3): AIsOneTwoThree(); break;
<Flik9x> }
<Flik9x> err okay...
<Flik9x> switch(a){
<Flik9x> case(0): ...
<Chrono> case(0) means 'when this happens' ?
<Flik9x> <switch> A is 0
<Flik9x> <case> Okay, then run this statement.
<Flik9x> ;D
<Flik9x> So...
<Flik9x> Lets write that in if's and else's :D
<Chrono> ok
<Flik9x> if(a == 0) AIsZero();
<Chrono> AISZero is a function isn't it?
<Flik9x> else if(a == 1 || a == 2 || a == 3) AIsOneTwoThree();
<Flik9x> Yeah :D
<Chrono> ok lol
<Flik9x> I wrote that instead of putting "statement" ;)
<Chrono> so ...
<Flik9x> var current_sword = "Claymore";
<Flik9x> switch(current_sword){
<Chrono> if a=0 then AIsZero()
<Flik9x> ' case ("Claymore"): GetSystemFont().drawText(0,0, "You have a Claymore")
<Flik9x> }
<Flik9x> err
<Flik9x> if a == 0 ;)
<Flik9x> if(a == 0) statement
<Flik9x> if(a == 0) AIsZero();
<Flik9x> whatever ^^
<Flik9x> var a = 0;
<Flik9x> if(a == 0) /* you know its going to be 0 anyway ;) */ AIsZero();
<Flik9x> AIsZero is ran.
<Flik9x> :)
<Chrono> what? AISZero is ran?
<Flik9x> Yeah.
<Flik9x> function Woo(){
<Flik9x> }
<Flik9x> Woo();
<Flik9x> By saying Woo(); you are calling the "Woo" function... =D
<Chrono> yeah
<Flik9x> calling/running whatever? :)
<Chrono> oh .. lol
<Flik9x> Technically, its involking ;)
<Chrono> invoking
* Flik9x can't spell
<Flik9x> ;D
* Chrono must seem stupid
<Chrono> I am getting it tho =)
<Flik9x> I should turn this into a doc :D :D :D
<Chrono> yeah
<Chrono> really
<Flik9x> So:-
<Chrono> cut out the extra text ( smilies and stupid stuff)
<Flik9x> aww :(
<Chrono> ok fine .. keep em =)
<Chrono> ok here .. tell me if this is right
<Flik9x> var chrono = (chrono == "mean" : false : true);
<Flik9x> Okay? :)
<Chrono> hmm .. why False : true);
<Flik9x> k
<Chrono> how can you do both?
<Flik9x> A) THat was bad code :P
<Flik9x> B) false and true are just variable values :P
<Chrono> so you messed up? =)
<Chrono> hehe
<Flik9x> var chrono // as in I'm just creating a chrono variable...
<Chrono> oh ok
<Flik9x> is equal to (chrono == "mean" : false : true)...
<Flik9x> But chrono isn't fully created yet! :P
<Chrono> ok hehe
<Flik9x> var whatever = (a ? b : c);
<Chrono> keep going then
<Flik9x> Whatever is b, if a, else whatever is c.
<Flik9x> This could be written as:-
<Flik9x> var whatever;
<Flik9x> if(a) whatever = b;
<Flik9x> else whatever = c;
<Chrono> ok
<Flik9x> that one doesn't matter too much though ;)
<Flik9x> var MyArray = new Array();
<Chrono> so....... let me try one!
<Flik9x> MyArray[0] = 'blah';
<Flik9x> okay! :D
<Chrono> ok .. go ahead
<Chrono> umm
<Flik9x> I was just going to say that before I did:- MyArray[0] = 'blah'; // MyArray.length was 0.
<Flik9x> But after... MyArray.length is 1.
<Flik9x> Okay, you try one then ;)
<Flik9x> Try to make it rpg related ;)
<Chrono> var sheild = "aegis sheild'
<Chrono> case ("aegis sheild"): ...
* Chrono is thinking
* Flik9x waits before correcting him =D
<Chrono> var sheild = "aegis sheild"; //a correction
<Flik9x> okay
<Flik9x> firstly:-
<Chrono> ok ..
<Flik9x> ar sheild = "aegis sheild'
<Flik9x> There was nothing wrong with that.
<Flik9x> err...
<Chrono> ok
<Flik9x> var sheild.. ;D
<Flik9x> However..
<Chrono> next should be ...
<Chrono> ok
<Flik9x> You really should end lines with a ";"
<Flik9x> Just to be good coding :)
<Chrono> I did .. afterwards =)
<Flik9x> Yes.
<Chrono> var sheild = "aegis sheild"; //a correction
<Chrono> then;
<Flik9x> "" and '' are the same in theory, too ;)
<Chrono> "aegis sheild"[0]: GetSystemFont().drawText(0,0, "You have a Aegis Shield")
<Flik9x> heh
<Chrono> "aegis sheild"[1]: GetSystemFont().drawText(0,0, "You have a Enchanted Aegis Shield")
<Flik9x> switch(shield){
<Chrono> is that right?
<Flik9x> case ("aegis shield"): statement; break;
<Flik9x> case ("bronze shield"): statement; break;
<Flik9x> }
<Chrono> ok
<Chrono> and...
<Chrono> I t wasn'
<Chrono> t a variable ... I fogot
<Chrono> go play in #Sphere a min .. let me go over this
<Flik9x> haha
<Flik9x> Alrighty ^^
<Chrono> hehe ^^
<Chrono> var item = (item == 'herb' : false : true);
<Flik9x> err
<Chrono> SHH
<Flik9x> You made the same mistake I made :D
<Chrono> is that wrong in any way though?
<Chrono> hmm?
<Flik9x> var item = (item == 'herb' : false : true)
<Chrono> can't use false and true?
<Flik9x> item will always be true...
<Flik9x> Because...
<Chrono> oh yeah
<Chrono> go on
<Flik9x> var item... = item (item is undefined so far) == 'herb' (no it doesn't equal to herb...) : don't return false... return true...
<Flik9x> var DoIHaveAHerb = (numberOfHerbs > 0 ? true : false);
<Flik9x> if(DoIHaveAHerb)...
<Flik9x> But then again...
<Chrono> ok ok .. go away now!
<Chrono> I want to figure this out
<Flik9x> if(numberOfHerbs > 0) would be clearer :D
<Chrono> hehe
<Chrono> ^^
* Flik9x ducks away from chrono :D
<Chrono> var HaveHerb = ("Herb" > 0 ? true : false);
<Chrono> if(HaveHerb): GetSystemFont().drawText(0,0, "You have a Herb");
<Chrono> wait
<Chrono> if(HaveHerb=true): GetSystemFont().drawText(0,0, "You have a Herb");
<Chrono> well .. text is wrong .. but its right?
<Chrono> var HaveHerb = ("Herb" > 0 ? true : false);
<Chrono> if(HaveHerb = true): HerbCount = 1
<Chrono> if(haveHerb = false): HerbCount = 0
[23:39] <Chrono> var HaveHerb = ("Herb" > 0 ? true : false);
[23:40] <Chrono> if(HaveHerb): GetSystemFont().drawText(0,0, "You have a Herb");
[23:40] <Chrono> wait
[23:40] <Chrono> if(HaveHerb=true): GetSystemFont().drawText(0,0, "You have a Herb");
[23:41] <Chrono> well .. text is wrong .. but its right?
[23:41] <Chrono> var HaveHerb = ("Herb" > 0 ? true : false);
[23:42] <Chrono> if(HaveHerb = true): HerbCount = 1
[23:42] <Chrono> if(haveHerb = false): HerbCount = 0
[23:44] <Flik9x> heheh
[23:44] <Chrono> whats wrong?
[23:44] <Flik9x> How can a string be greater than 0? :)
[23:44] <Flik9x> "hi there" > 0 ;)
[23:45] <Flik9x> "Herb" > 0 == wrong :D
[23:45] <Chrono> oh lol
[23:45] <Flik9x> if(HaveHerb): ... err, why the colon? o_O
[23:45] <Flik9x> Bad! :D
[23:45] <Flik9x> if(HaveHerb){
[23:45] <Flik9x> GetSystemFont().drawText(0,0, "You have a Herb");
[23:45] <Chrono> yeah .. ok lol
[23:45] <Flik9x> }
[23:46] <Flik9x> also..
[23:46] <Chrono> so .. what that whole thing does is ...
[23:46] <Flik9x> if(HaveHerb = true)... HaveHerb is equal to true, and if its equal to true... Heh.
[23:47] <Flik9x> It should be:-
[23:47] <Flik9x> if(HaveHerb == true)
[23:47] <Flik9x> or just:- if(HaveHerb)
[23:47] <Chrono> {
[23:47] <Flik9x> And no colons! :P
[23:47] <Chrono> ok
[23:48] <Flik9x> So your:- "herb" > 0
[23:48] <Flik9x> Should be:- NumberOfHerbs > 0
[23:48] <Flik9x> variable! not a string ;D
[23:48] <Chrono> ok
[23:48] <Flik9x> err
[23:48] <Flik9x> But I said, earlier...
[23:48] <Chrono> yeah ... it should .. it looked odd
[23:49] <Flik9x> var HaveHerb = (NumberOfHerbs > 0 : true: false);
[23:49] <Flik9x> Is bad coding! :D
[23:49] <Flik9x> You should just do:-
[23:49] <Flik9x> if(NumberOfHerbs > 0){
[23:49] <Flik9x> whatever
[23:49] <Flik9x> }
[23:50] <Flik9x> brb
[23:50] <Chrono> ok .. I understand that
[23:50] <Chrono> ok
[23:51] <Flik9x> ;)
[23:52] <Flik9x> back btw :P
[23:52] <Chrono> what scares me is that coding is prolly 99% of the game =P
[23:52] <Flik9x> heh
[23:52] <Flik9x> Nope... not 99% :P
[23:53] <Chrono> how much then? lol
[23:53] <Flik9x> Try using a switch/case then :D
[23:54] <Flik9x> errr, 30% :D
[23:54] <Chrono> really?
[23:54] <Chrono> wow
[23:54] <Flik9x> Most of the coding is just the basic stuff...
[23:55] <Flik9x> You can make functions for everything you might want to call upon...
[23:55] <Flik9x> Say a Text function... :D
[23:55] <Flik9x> Text("Hi there..");
[23:55] <Flik9x> whatever....
[23:55] <Chrono> ok
[00:00] <Flik9x> Okay, so a switch and case statements? :)
[00:00] <Chrono> want me to do one?
[00:00] <Flik9x> Yeah
[00:02] <Chrono> switch(sword){
[00:03] <Chrono> why do I get stuck here lol
[00:03] <Chrono> one sec
[00:03] <Flik9x> case value: statement; break;
[00:04] <Chrono> switch(sword){
[00:05] <Chrono> case(1): GetSystemFont().drawText(0,0, "You have a Sword"); Break;
[00:05] <Chrono> case(2): GetSystemFont().drawText(0,0, "You have a Big Sword"); Break;
[00:05] <Chrono> }
[00:05] <Chrono> right?
[00:05] <Flik9x> Thats fine :D
[00:05] <Chrono> ok
[00:06] <Flik9x> err
[00:06] <Chrono> not much change .. but that is all up to what you want to do =P
[00:06] <Flik9x> case(1)...
[00:06] <Chrono> hmm?
[00:06] <Flik9x> put a space there! case(1) becomes case (1) :D
[00:06] <Flik9x> Then its okay. :D
[00:06] <Chrono> ok
[00:06] <Chrono> so it should be
[00:07] <Chrono> case (1): GetSystemFont().drawText(0,0, "You have a Sword"); Break;
[00:07] <Flik9x> err
[00:07] <Chrono> thats the only mistake?
[00:07] <Flik9x> Break? break? ;)
[00:07] <Flik9x> case sensitive ;)
[00:07] <Chrono> hmm?
[00:07] <Chrono> oh ok
[00:07] <Flik9x> break, not Break :P
[00:07] <Chrono> break .. there
[00:08] <Flik9x> switch(a){
[00:08] <Flik9x> case (0) : OnlyRunThisFunctionIfAIsZero();
[00:08] <Chrono> case (1): statement; break;
[00:08] <Chrono> ok .. hehe
[00:09] <Flik9x> case (1) : woo(); break;
[00:09] <Chrono> ok
[00:09] <Flik9x> default: DefaultIfAIsNotZeroOrOne();
[00:09] <Chrono> no break if only 1 case yes?
[00:09] <Flik9x> }
[00:09] <Flik9x> You should have a break...
[00:09] <Flik9x> What happens there is...
[00:09] <Chrono> you didnt!
[00:09] <Flik9x> if it is 0...
[00:10] <Flik9x> It will run:- OnlyRunThisFunctionIfAIsZero() and woo()
[00:10] <Chrono> OnlyRunThisFunctionIfAIsZero()
[00:10] <Flik9x> Thats what happens if you don't type break ;P
[00:10] <Chrono> ahh
[00:10] <Flik9x> there is a break after woo(); because... I don't want it to run the default.... ;P
[00:10] <Flik9x> e.g.
[00:11] * Flik9x thinks of an example...
[00:11] <Flik9x> switch(icescream){
[00:12] <Flik9x> case "chocolate": statement;
[00:13] <Chrono> you forgot break
[00:13] <Flik9x> case "stawberry": statement;
[00:13] <Chrono> you forgot break again
[00:13] <Chrono> hehe
[00:13] <Flik9x> I'm doing that on purpose, to show a possible bug :P
[00:13] <Chrono> ok
[00:13] <Flik9x> default: statement;
[00:13] <Flik9x> }
[00:14] <Chrono> it will run all 3
[00:14] <Chrono> right?
[00:14] <Flik9x> IF you have cholocate icescream, it'll run all 3...
[00:14] <Flik9x> stawberry, run 2...
[00:14] <Flik9x> Anything else, run 1 :P
[00:14] <Flik9x> whatever :)
[00:15] <Chrono> ok
[00:15] <Flik9x> so
[00:15] <Chrono> how is that a bug though?
[00:15] <Flik9x> If you had code like this:-
[00:15] <Chrono> is a bad code .. but a bug?
[00:15] <Flik9x> Because its probably supposted to have breaks :P
[00:15] * Flik9x shrugs, okay bad code :P
[00:16] <Chrono> hey ..
[00:16] <Flik9x> if(a == 0) blah();
[00:16] <Flik9x> if(a == 1) woo();
[00:16] <Flik9x> if(a == 2) heh();
[00:16] <Flik9x> ... would be better as a switch... because most probably, you don't want blah, woo, and heh to be ran.
[00:17] <Flik9x> switch(a){
[00:17] <Flik9x> case 0: blah(); break;
[00:17] <Flik9x> case 1: woo(); break;
[00:17] <Flik9x> etc...
[00:17] <Chrono> yeah
[00:17] <Flik9x> for(var i = 0; i < 4; ++i){
[00:17] <Flik9x> DoStuff();
[00:17] <Flik9x> }
[00:18] <Flik9x> DoStuff 4 times :D
[00:18] <Flik9x> for(initilation; condition; increment)
[00:18] <Flik9x> statement
[00:19] <Chrono> ok
[00:19] <Flik9x> so
[00:20] <Flik9x> for(var i = 0; i < 4; ++i)
[00:20] <Flik9x> i is 0. and while i is less than 4, DoStuff() then ++i...
[00:20] <Chrono> look at this...
[00:20] <Chrono> function ShowXY() {
[00:20] <Chrono> GetSystemFont().drawText(16,16, "(" + GetPersonX('main character') + "," + GetPersonY('main character') + ")");}
[00:20] <Chrono> var i = 0;
[00:20] <Chrono> while(i < 100){ RenderMap(); ShowXY(); FlipScreen(); i++;}
[00:21] <Flik9x> That would become:-
[00:21] <Flik9x> for(var i = 0; i < 100; ++i){ RenderMap(); ShowXY(); FlipScreen(); }
[00:21] <Chrono> this would draw the XY cords of a character rendermap() flipscreen() 100 times yes?
[00:21] <Flik9x> Yeah...
[00:22] <Flik9x> but there's no delay... so you might not see it depending on how fast your pc is ;)
[00:22] <Chrono> yeah .. I noticed I had to beef it up to 5000 to see it =P
[00:22] <Flik9x> hahaha
[00:22] <Flik9x> function Delay(ms){
[00:23] <Flik9x> var start = GetTime();
[00:23] <Flik9x> while(GetTime() < start + ms) {} // do nothing...
[00:23] <Flik9x> }
[00:23] <Flik9x> for(var i = 0; i < 100; ++i){ RenderMap(); ShowXY(); FlipScreen(); Delay(100); }
[00:24] <Flik9x> Delay for 1 10th of a second, I think ;D
[00:24] <Chrono> yeah .. something like tha
[00:24] <Chrono> that
[00:25] <Flik9x> Any questions, then? :D
[00:25] <Chrono> nope
[00:26] <Flik9x> ok =P
[00:26] <Flik9x> Weird characters then ;)
[00:26] <Chrono> ok
[00:27] <Flik9x> if(a == b || a == c)
[00:27] <Flik9x> blah
[00:27] <Flik9x> if a is equal to b or a is equal to c... do blah...
[00:27] <Flik9x> || == or :D
[00:27] <Chrono> ok
[00:27] <Flik9x> if(a == b && a == c)
[00:27] <Flik9x> blah
[00:27] <Chrono> if a is equal to b and c do blah
[00:28] <Flik9x> do blah if a is equal to b and a is equal to c :)
[00:28] <Flik9x> e.g.
[00:28] <Flik9x> var a = 1;
[00:28] <Flik9x> var b = a, c = a;
[00:28] <Flik9x> if(a == b && a == c) blah
[00:28] <Flik9x> blah is ran ^^
[00:28] <Chrono> yeah
[00:29] <Flik9x> if(a % b == 0)...
[00:29] <Flik9x> if (a / b) has a remainder of zero...
[00:30] <Flik9x> ... whatever :)
[00:30] <Flik9x> % is called modulas, or something...
[00:31] <Flik9x> err
[00:31] <Flik9x> if(!a){
[00:31] <Flik9x> blah
[00:31] <Flik9x> }
[00:31] <Flik9x> if a is not true...
[00:31] <Flik9x> ! = not
[00:31] <Flik9x> while(!done) is a good example... :)
[00:31] <Flik9x> while not done... ;)
[00:32] <Flik9x> if(a != b) blah();
[00:32] [LiveJournal] Connecting to LiveJournal...
[00:33] <Chrono> ?
[00:33] <Flik9x> if a is not equal to b...
[00:33] <Flik9x> Another way of doing that would be:-
[00:34] <Chrono> yeah.. whats next hehe
[00:34] <Flik9x> if(a == b){}else{ blah(); }
[00:34] <Flik9x> hmm... I'm getting low on random stuff to say... :P
[00:34] <Flik9x> object.member
[00:35] <Chrono> mm
[00:35] <Flik9x> object.method();
[00:35] <Flik9x> function CustomObject(x,y,name){
[00:35] <Flik9x> this.x = x;
[00:35] <Flik9x> this.y = y;
[00:35] <Flik9x> this.name = name;
[00:35] <Flik9x> }
[00:36] <Flik9x> CustomObject.prototype.draw = function(){
[00:36] <Flik9x> GetSystemFont().drawText(this.x, this.y, this.name);
[00:36] <Flik9x> }
[00:36] <Flik9x> var BOB = new CustomObject(50, 50, "Bob");
[00:36] <Flik9x> BOB.draw();
[00:37] <Flik9x> BOB.name = "Jim";
[00:37] <Flik9x> BOB.draw();
[00:37] <Flik9x> :D :D
[00:37] <Flik9x> Objects :)
[00:39] <Flik9x> var party = new Array(BOB);
[00:40] <Flik9x> Make a array of CustomObject's called party...
[00:40] <Flik9x> party[0].draw();
[00:40] <Flik9x> // draws "Jim" to the screen at 50,50
[00:41] <Flik9x> FlipScreen(); Delay(1000); // don't forget to show it and delay for a certain time ^^;
[00:41] <Flik9x> Hmm, you have to reply some time... ;)
[00:41] <Chrono> delay isn't an automatic function .. you ahve to set it right?
[00:41] <Flik9x> Yes.
[00:41] <Flik9x> I wrote out a defination of Delay above...
[00:41] * Flik9x points up...
[00:42] <Chrono> yeah ... so you can use it =)
[00:42] <Flik9x> :P
[00:42] <Chrono> so that all would draw "Jim" at 50,50 for 1 second =)
[00:42] <Flik9x> Correct :D
[00:43] <Flik9x> 1 second... 1000 milliseconds.. same difference :)
[00:43] <Chrono> yeah
[00:43] <Flik9x> =D
[00:43] <Flik9x> Anything else? :)
[00:44] <Chrono> thats enough for me to study over for now
[00:44] <Flik9x> Ok then...
[00:44] <Flik9x> Class dismissed? :)
[00:44] <Chrono> withh write it to a wordpad doc if you want (to put up on your docs page)
[00:44] <Flik9x> I will ;)
[00:44] <Chrono> want me to = withh
[00:44] <Flik9x> I've got that under control :D
[00:45] <Chrono> ok =)
[00:45] * Flik9x sets the class some homework...
[00:45] <Flik9x> j/k :D
[00:45] <Chrono> lol
[00:45] * Flik9x doesn't want to have to mark it ;)
[00:45] <Chrono> haha
[00:46] <Chrono> what will the name of this doc be?
[00:46] <Flik9x> chrono? ;)
[00:46] <Chrono> basic JavaScript? =P
[00:46] <Chrono> ^^
[00:46] * Flik9x shrugs...
[00:46] <Flik9x> Stop talking already! :P
[00:46] <Chrono> ok!
Session Close: Sun Jul 22 00:46:59 2001

And thats the end of that docuement, all those spelling mistakes and smilies...

Made By Flik!