Phun - 2D physics sandbox - forum

Official Forum

You are not logged in.

#1 2009-02-21 03:15:17

gradfitz
Post Manic
From: Australia
Registered: 2008-10-05
Posts: 823

[Tutorial]Thyme - With full explanations at every step

Well, I've had a few people ask me about Thyme, so, I thought I'd make a tutorial, with explanations of what variables and such are (because people ask when you are teaching them).

PDF of This Tutorial - Updated 12th of April 2009

Tutorial 1: Creating a variable
Tutorial 2: Creating an array
Tutorial 3: Actions and Pointers
Tutorial 4: Action Array
Tutorial 5: Variable Modification
Tutorial 6: Key Binding
Tutorial 7: Actions, Arrays, Timers
Tutorial 8: Final: Actions, Arrays, Timers, Keys
Examples - All Tutorials
Beta 5.25
- Tutorial 9: General differences in Thyme
- Tutorial 10: .this .other
- Tutorial 11: Scene.my.
- Tutorial 12: Argumentative functions
- Tutorial 13: Infix
- Tutorial 14: if structures
- Tutorial 15: OnCollide
- Tutorial 16: .phn editing



Tutorial 1: Creating a variable
What is a variable?
A variable is something that holds a value, alphanumeric in general, used to store information, and vital in programming languages (otherwise your programming language wouldn't work very well, or would have to use another to help).

How would I go about making a variable?
You would follow these steps:
1.Bring down the console by pressing F11
2.Type a variable name, like Xvar or TX3 or Bvz
3.Type an equal sign (=)
4.Type a value, like 100 or 200 or 48 or 28 or 4.2
5.Check that you haven't made any mistakes, it should look something like: TX3 = 48
6.Press Enter

NOTE: if you are putting a variable in code, it is advisable to include a semi-colon at the end (;).


What are the input types for variables?
There are 3 input types for variables: floats, integers and strings

What's a float?
A float is a floating point number, one that has or can have a decimal point and numbers to the right of the decimal point.

What's an integer?
An integer is a number that does not have a decimal place a "whole number".

What's a string
A string is basically text, "Bam", is a string, in C++ it would be imputed like: "array Arr1 [4] = ["B","A","M",/0]" or so (I don't remember if those are the right symbols, but, essentially you get the idea), in Thyme, you don't need a terminating character, or the size of the array, strings are text, and that is how it is handled in Thyme.






Tutorial 2: Creating an array
What is an array?
An array is a set of values (more than 1 variable), in some programming languages, arrays are used to store strings (like C++ for example), Thyme has strings stored in single variables, so arrays don't handle it like that, in a few languages, arrays require their size to be declared, in Thyme, arrays do not require their size to be declared, or even their type (in C++ for example, the underlined parts would be removed if transferred into Thyme: array Arr1 [4] = ["B","A","M",/0"];)

How would I go about creating an array?
1.Bring down the console by pressing F11
2.Type a name for your array, it can be anything, like, Pink or Yellow, or Zing or Towel
3.Type an equal sign (=)
4.Start a square bracket ([)
5.Think of some numbers to put in, like, 7,9,2,5 or 1.7, 2.9, 6.6, 4.4
6.Input the values separated by commas, like 7,2,8,"A"
7.End your square brackets (])
8.Check that you haven't made any mistakes, it should look something like: Zing = [7,2,8,"A"]
9.Press Enter


NOTE: if you are putting an array in code, it is advisable to include a semi-colon at the end (;).

I heard arrays had to be homogeneous (all of the same data type), is this true?
Lists do not have to be homogeneous (in Thyme), but it can be a good idea, depending on what you are doing.

Why would I want to use an array?
Arrays can be useful for organizing variables into a useful section, also, they can be used in execution orders, to switch to the next step, without much problem

I can't get into my array, help?
You can access certain areas of your array by typing the address of the element (the specific number), for example, arr = [1.0,1.1,1.2], if I wanted to go
to the third one I'd type arr 2 and press enter, if I wanted the first one, I'd type arr 0 and press enter.







Tutorial 3: Tutorial 3: Actions and Pointers
Whats an action?
An action is something to do, a function, such as assignation

What is a pointer?
A pointer is something that points to another variable, array, array position, or a modified variable, array or array position, a pointer is constantly updating itself to the value (modified/unmodified variable, array or array position).

How would I go about creating a pointer?
1.Bring down the console by pressing F11
2.Type a name for your pointer, like, John
3.Type an equal sign (=)
4.Start a curly bracket ({)
5.Type the name of another of your variables that you have made, like, TX3 or Zing or Zing 1
6.End your curly brackets (})
7.Check that you haven't made any mistakes, it should look something like: John = {TX3}
8.Press Enter


NOTE: if you are putting a pointer in code, it is advisable to include a semi-colon at the end (;).
NOTE2: you can't attach a pointer to a variable/array that does not exist

How would I go about creating an action?
1.Bring down the console by pressing F11
2.Type a name for your action, like, JI2MTTX3 (if you are curious about it, it means John is 2 more than TX3)
3.Type an equal sign (=)
4.Start a curly bracket ({)
5.Start with the variable you want to change, like, John
6.Type an equal sign (=)
7.Type the name of another of your variables that you have made, like, TX3 or Zing or Zing 1
8.If you want to do a modification (like add 2 to the variable), add that in after, like, + 2
9.End your curly brackets (})
10.Check that you haven't made any mistakes, it should look something like: JI2MTTX3 = {John = TX3 + 2}
11.Press Enter


NOTE: John will not be changed until you type "JI2MTTX3" and press enter
NOTE2: If you are including an action in a code, it is advisable to include a semi-colon at the end (;).
NOTE3: You can't attach an action to a pointer/variable/array that does not exist
NOTE4: Arrays don't want to be changed by element, you are required to set Arrays to a pointer array (put curly brackets ({}) around the array and put some variables in it)






Tutorial 4: Action Array
What is an Action Array?
An action array is an array of actions, that will execute when they are called, they are currently one of the best methods of organizing commands in thyme, and also one of the best ways to sequence in thyme

How would I go about making an action array?
1.Bring down the console by pressing F11
2.Create a name for a new array, like, Actions, type it
3.Type an equal sign (=)
4.Start a square bracket ([)
5.Add your first action, you can either put it in like: "{Ji2}", and call Ji2 to do the work, or add the action directly into the array like: "{John = 2}"
6.Type a comma (,)
7.Add your second action, it can be added just like the first, you can add more commands separating each one by a comma if you want.
8.End your square brackets (])
9.Check that you haven't made any mistakes, it should look something like: Actions = [{John = 2},{John = 3}]
10.Press Enter


NOTE: If you are including an action array in a code, it is advisable to include a semi-colon at the end (;).

I can put commands in my normal array, whats different about using this kind of array?
Using an non-action style array means that the entire array will be accessed, and it will only show you the array you requested, but every action will have been activated. When you use an action-style array, you wont have all of your actions run at the same time, whereas if you use a non-action style array all your commands will run at the same time






Tutorial 5: Variable Modification
What's variable modification
Variable modification is basically changing values, although, some variables refuse to change unless under certain conditions, one of those conditions is that they are under a structure, not noticing how to put them in structures was the hardest thing in variable modification, even though it is easy now, it was difficult until we figured out how to do it.

Whats a structure?
A structure is something that contains more variables and functions, like: Scene. and App.

How would I go about variable modification?
Variable modification is more how I explain variables that can be modified by actions and keys (next Tutorial is how to use keys to modify values).
1.Bring down the console by pressing F11
2.Enter into a structure by typing the name of it, like, Scene. (I put my scene related commands and variables in there)
3.Create a name for a new variable, like, Zuu
4.Type an equal sign (=)
5.Input the data type you would like (the process becomes the same as a variable/array/action array/pointer at this point).
6.Check that you haven't made any mistakes, it should look something like: Scene.Zuu = 8
7.Press enter


NOTE: If you are including a variable in a code, it is advisable to include a semi-colon at the end (;).

What is the point of this classing/structuring?
It allows variables to be changed by functions and keys






Tutorial 6: Key Binding
What is Key Binding?
It is allowing people to press keys to do functions, like, add 3 to a variable, or subtract 6, or change a string, things like that

How would I go about Key binding?
1.Bring down the console by pressing F11
2.Type Keys.bind
3.Start a bracket (()
4.Type the key you want to do in quotation marks, as this is a string, like, "a"
5.Type a comma (,)
6.Start a curly bracket ({)
7.Add your action, like, John = 9 (if you want to add more than one action, separate with a semi-colon (;))
8,End your curly bracket (})
9.End your bracket ())
10.Check that you haven't made any mistakes, it should look something like: Keys.bind("a",{John = 9; TX3 = 72})
11.Press enter


NOTE: If you are including a variable in a code, it is advisable to include a semi-colon at the end (;).

Can I have more than 1 action on my key?
You can only have more than 1 action on one key if you enter it at the time of your creation, otherwise your second input will override the first

How would I go about getting rid of this Key binding?
1.Bring down the console by pressing F11
2.Type Keys.unbind
3.Start a bracket (()
4.Type the key you want to remove in quotation marks, as this is a string, like, "a"
5.Type a comma (,)
6.Start another bracket (()
8,End your bracket ())
9.End your bracket ())
10.Check that you haven't made any mistakes, it should look something like: Keys.unbind("a",())
11.Press enter








Tutorial 7: Actions, Arrays, Timers
I thought I already learned how to use Actions and arrays
But this section involves those skills, and also the new skill, timers

What's a timer?
A timer is basically a clock, that ticks, when it reaches each step the next action happens for example: We will take a watch as an example, a watch ticks for 60 seconds, the second hand moves each second, then after 60 seconds, the minute hand moves one, the hour hand also moves 1/60th of the way to the next hour every time

How would I go about making a Timer?
1.Bring down the console by pressing F11
2.Create a modifiable variable, for counting, like, Scene.count
3.Assign your new variable to 0, like, Scene.count = 0
4.Create a variable (modifiable or not, I like modifiable better), like, Scene.step
5.Assign your new variable to the amount of ticks you want it to do, 500 ticks is about 7 seconds, like, Scene.step = 500
6.Create an action array, with each step having some way of increasing your first variable, (Scene.count), like {Scene.count = Scene.count + 1}.
7.Assign Sim.timeFactor to a pointer type of view, which includes, your actions, your first variable / your second variable (if you don't know what / means, its divided), a call operator (()) and a reset back to 1, like, Sim.timeFactor = {Scene.Actions (Scene.count / Scene.step)();1;}
8.Your action should happen every tick.


That was difficult
It will get easier when you learn how to do everything involved better







Tutorial 8: Final: Actions, Arrays, Timers, Keys
I've learned all those things now, what is this tutorial for?
You may have learned the tutorials, but you haven't  put everything together yet.

What do we plan to do here?
We plan to turn on and off a timer using the key "a"
BAH, but how can we do that?
We are going to make a homemade toggle I created (its most likely been around for ages but nonetheless, I figured it out myself, so....) Var = ((Var * -1) + 1) this will make Var = 1 if its 0, and 0 if its 1

I think I know how its all going to go about, but can you show me anyway?
Get the code from your previous timer, and put it in, but this time, we are going to do it a little differently.
1.Bring down the console by pressing F11
2.Create a modifiable variable, for counting, like, Scene.count
3.Assign your new variable to 0, like, Scene.count = 0
4.Create a variable (modifiable or not, I like modifiable better), like, Scene.step
5.Assign your new variable to the amount of ticks you want it to do, 500 ticks is about 7 seconds, like, Scene.step = 500
6.Create an action array, with each step having some way of increasing your first variable, (Scene.count), like {Scene.count = Scene.count + 1}.
7.Create a new modifiable variable, like, Scene.ToggleTimer
8.Create a new array, like, Scene.timeFactorA = [{1;}, {Scene.Actions (Scene.count / Scene.step)();1;}]
8.Assign Sim.timeFactor to an action pointer, which includes, your actions, your first variable / your second variable (if you don't know what / means, its divided), a call operator (()) and a reset back to 1, also in a 2 element array like, Sim.timeFactor = {Scene.timeFactorA Scene.ToggleTimer}
9.Bind a key to toggle (using Var = ((Var * -1) + 1) ), like, Keys.bind("a",{Scene.ToggleTimer = ((Scene.toggle * -1) + 1);})
10.Check all the codes aren't visibly wrong. the toggle timer should be set up.


Any examples?
Yeah, there's a ragdoll battle (KAGE made it)

Name: Coded ragdoll battle V2
File Size: 234.7KB
http://www.phunbox.net/img/downloadBarRed.gifhttp://www.phunbox.net/img/downloadBarBlue.gif

This kind of coding is very original, I don't really see it around, why is that
Not too many people take the time to learn.... Thyme, when scenes use Thyme efficiently, and include measures that automatically clean up the problems they cause (perhaps in another scene), people are amazed at it, a large number of those who download scenes with Thyme elements in them are lazy, and rate the scene down because either: A) they don't know how it works or B) they don't bother to ask before they rate (or look around for the fix).

I hope you enjoyed my tutorial, I also hope that you find it useful, there is a little more to Thyme than I have posted, but it's pretty easy, and involves the easier of the skills that are shown here (mainly just assigning).

If you find an error, tell me, I will try to fix it.

- By Grady (took a long time to write, hope you read it).

EDIT: Fixed the download Link

Last edited by gradfitz (2009-07-06 19:31:14)


http://miniprofile.xfire.com/bg/sf/type/2/gradyfitz.png
Thyme: Tutorial - Beta 5 Command List
I made a typo in my username, it's meant to be gradyfitz.

Offline

 

#2 2009-02-21 03:29:34

kilebantick
Post Addict
From: I haz house?
Registered: 2008-07-06
Posts: 693
Website

Re: [Tutorial]Thyme - With full explanations at every step

Gradym that thing is insane!!!! man, im a quarter way dow n it,, and i already knwo alot more about Thyme, the only thing i find annoying about it, is that it seemd to be written for people that have SOME knowledge of thyme, wich makes it (for me) kinda Hard to learn.

Last edited by kilebantick (2009-02-21 03:59:34)


http://miniprofile.xfire.com/bg/sh/type/0/kilebantick.pngphun xfire clan www.xfire.com/clans/thephunclan http://www.signaturebar.com/uploads/images/18441.gif Unnoficial  Phun chat room http://xat.com/Algodoo_Phun
http://img200.imageshack.us/img200/4564/kaged.jpg

Offline

 

#3 2009-02-21 05:00:11

gradfitz
Post Manic
From: Australia
Registered: 2008-10-05
Posts: 823

Re: [Tutorial]Thyme - With full explanations at every step

kilebantick wrote:

Gradym that thing is insane!!!! man, im a quarter way dow n it,, and i already knwo alot more about Thyme, the only thing i find annoying about it, is that it seemd to be written for people that have SOME knowledge of thyme, wich makes it (for me) kinda Hard to learn.

It was written with those with no thyme knowledge at all in mind, it can only really be explained better in real life, it is certainly the best Thyme tutorial I've seen (they are very uncommon though....). This is certainly a lot easier to link to and show. I hope some people learn Thyme from it.

Last edited by gradfitz (2009-02-21 22:58:37)


http://miniprofile.xfire.com/bg/sf/type/2/gradyfitz.png
Thyme: Tutorial - Beta 5 Command List
I made a typo in my username, it's meant to be gradyfitz.

Offline

 

#4 2009-02-21 09:21:46

doffen
Seasoned Member
From: Norway!
Registered: 2008-10-14
Posts: 81
Website

Re: [Tutorial]Thyme - With full explanations at every step

W-O-W!

Nice tutorial, easy to understand even for a guy who has no experience with thyme(like me).
Very easy and useful, sticky this thread!


http://i.neoseeker.com/ca/mario_party_8_conceptart_Gan91_thumb.jpg
http://dragcave.net/image/N1v8.gifhttp://dragcave.net/image/NbYi.gifhttp://dragcave.net/image/PArL.gif
Click them please! smile

Offline

 

#5 2009-02-22 00:11:17

gradfitz
Post Manic
From: Australia
Registered: 2008-10-05
Posts: 823

Re: [Tutorial]Thyme - With full explanations at every step

I've just tested how big the tutorial is:
2573 words
14414 characters (5.6020209871745044694908666925768 avg characters per word)
At 10pt Times New Roman, on pages, 21.00cm (w) x 29.70cm(h), Left to Right : 6 pages long.
At 12pt Times New Roman, on pages, 21.00cm (w) x 29.70cm(h), Left to Right : 7 pages long.
At 14pt Times New Roman, on pages, 21.00cm (w) x 29.70cm(h), Left to Right : 9 pages long.
At 16pt Times New Roman, on pages, 21.00cm (w) x 29.70cm(h), Left to Right : 11 pages long.
At 18pt Times New Roman, on pages, 21.00cm (w) x 29.70cm(h), Left to Right : 12 pages long.
At 20pt Times New Roman, on pages, 21.00cm (w) x 29.70cm(h), Left to Right : 14 pages long.
At 22pt Times New Roman, on pages, 21.00cm (w) x 29.70cm(h), Left to Right : 17 pages long.
At 24pt Times New Roman, on pages, 21.00cm (w) x 29.70cm(h), Left to Right : 19 pages long (5 pages more than half size (doubled), isn't that interesting).
smile

I'm also glad that people liked the tutorial, I was aiming for an easy to read tutorial (a large amount of the people who read tutorials don't understand them even if there well presented, but anyway, I tried hard and could probably have improved).

Last edited by gradfitz (2009-02-22 00:13:16)


http://miniprofile.xfire.com/bg/sf/type/2/gradyfitz.png
Thyme: Tutorial - Beta 5 Command List
I made a typo in my username, it's meant to be gradyfitz.

Offline

 

#6 2009-02-22 00:16:34

Skillkills
Senior Member
From: Hiding in your closet
Registered: 2008-08-14
Posts: 281

Re: [Tutorial]Thyme - With full explanations at every step

holy crap this is a big tut.... ill be reading so..


http://i540.photobucket.com/albums/gg327/ioncann0ns/ubd9085-1.pngGet Pumped 
☻/
/▌  this is bob. copy and paste bob and he will soon take over the forums
/ \

Offline

 

#7 2009-02-24 15:20:44

Blue Herring
Seasoned Member
Registered: 2008-11-26
Posts: 66

Re: [Tutorial]Thyme - With full explanations at every step

Well done gradfitz.


-The Mildly Infamous Blue Herring

http://www.bherring.cotse.net/img/userbar722162ry8.gif

Offline

 

#8 2009-02-25 05:11:38

gradfitz
Post Manic
From: Australia
Registered: 2008-10-05
Posts: 823

Re: [Tutorial]Thyme - With full explanations at every step

Thought I'd include some examples (maybe it'll make things easier):
EXAMPLES:
Tutorial 1: Creating a variable
VarA = 2;
TestB = 3;
AmazingX = 2;
LaLaLa = 99;
DaDeDo = 42.5;
LaLa = "LaLa";
LaLaLaLa = "l";

Tutorial 2: Creating an array
ArrA = [1,2,3];
Barr = [1,2.3];
Crab = [6.7,2.9,7.43,2.9];
Tab = ["A","L","I","S","T"];
Tab2 = ["AL","IS","T"];
Carb = ["ALI","TS", 1, 1.62, VarB];
Sarb = {["ALI","TS", 1, 1.62, VarB]};

Tutorial 3: Actions and Pointers
STF2M = {Sim.timeFactor = Sim.timeFactor + 2};
FrequencyUp = {Sim.timeDelta = Sim.timeDelta + 2};
FrequencyDown = {Sim.timeDelta = Sim.timeDelta - 2};
Skip2 = {LaLa};
VarB = {VarA};
VarC = {VarA * 2};

Tutorial 4: Action Array
Actions = [{Scene.John = 2},{Scene.John = 3}];
Lolahaha = [{Scene.addBox{size = [4,2];}},{Scene.addBox{size = [8,6];}},{Scene.addBox{size = [7,9.3];}},{Scene.addBox{size = [2,0.5];}}];
PataPata = [{Sim.timeDelta = 0.01;Sim.timeFactor = 0.1;},{Sim.timeDelta = 0.001;Sim.timeFactor = 0.001;}];
PataPataPata = [{Scene.addBox{size = [4,2];}}, {Scene.Var2 = Scene.Var2 + 1}];

Tutorial 5: Variable Modification
Scene.Variable1 = 2;
Scene.Happiness = 7.2;
Scene.Cap = [7,3,2.4,"a", VarC];
Sim.Tap = {[VarC, VarB, Skip2]}

Tutorial 6: Key Binding
Keys.bind("a",{Scene.count = Scene.count + 1});
Keys.bind("x",{Scene.ALXE = 72});
Keys.bind("l",{Sim.timeDelta = Sim.timeDelta / 10});
Keys.bind("m",{Sim.timeDelta = Sim.timeDelta * 10});
Keys.bind("n",{Sim.timeDelta = Scene.TDArr 1});
Keys.bind("o",{Scene.TDArr2 1()});
Keys.bind("p",{Scene.addBox{size = [1,1];}});

Tutorial 7: Actions, Arrays, Timers
Scene.Actions = [{Scene.addBox{size = [4,2];}'Scene.count = Scene.count + 1;},{Scene.addBox{size = [8,6];};Scene.count = Scene.count + 1;},{Scene.addBox{size = [7,9.3];};Scene.count = Scene.count + 1;},{Scene.addBox{size = [2,0.5];};Scene.count = Scene.count + 1;},{Scene.count = 0];
Scene.step = 500;
Scene.count = 0;
Sim.timeFactor = {Scene.Actions (Scene.count / Scene.step)();1;};

Scene.Actions = [{Sim.timeDelta = 0.01;Sim.timeFactor = 0.1;Scene.count = Scene.count + 1;},{Sim.timeDelta = 0.001;Sim.timeFactor = 0.001;Scene.count = Scene.count + 1;},{Scene.count = 0;}];
Scene.step = 250;
Scene.count = 0;
Sim.timeFactor = {Scene.Actions (Scene.count / Scene.step)();1;};

Tutorial 8: Final: Actions, Arrays, Timers, Keys
(Taken from KAGE Ragdoll battle)

Code:

Keys.bind("space", {Scene.SpaceToggleSimV = ((Scene.SpaceToggleSimV * -1) + 1); Scene.SpaceToggleSim Scene.SpaceToggleSimV()});
MATB = {Scene.addBox {
    pos = [76.5175018, 11.611475];
    body = 0;
    collideSet = 0;
    color = [0.0649999976, 1.0, 0.270000011, 1.0];
    size = [10.9785061, 10.9785061];
};};
TETB = {Scene.addBox {
    pos = [76.5175018, 0.100096703];
    body = 0;
    collideSet = 0;
    color = [0.0649999976, 1.0, 0.270000011, 1.0];
    size = [10.9785061, 10.9785061];
    buttonDestroy = "space";
};};
RPSATB = {Scene.addBox {
    pos = [76.3214569, 23.7662468];
    body = 0;
    collideSet = 0;
    color = [0.0649999976, 1.0, 0.270000011, 1.0];
    size = [10.9785061, 10.9785061];
    buttonDestroy = "p";
};};
LPSATB = {Scene.addBox {
    pos = [76.3214569, 35.7249756];
    body = 0;
    collideSet = 0;
    color = [0.0649999976, 1.0, 0.270000011, 1.0];
    size = [10.9785061, 10.9785061];
    buttonDestroy = "z";
};};
Scene.SpaceToggleSim = [{Sim.timeFactor = 1;}, 
    {Sim.timeFactor = 
      { 
        Scene.SpecialMoveC1 (Scene.Count1/Scene.Step)();
        Scene.SpecialMoveC2 (Scene.Count2/Scene.Step)();
        Scene.PMove (Scene.Count3/Scene.Step)();
        1; 
      };TETB;}];
Scene.SpaceToggleSimV = 0;
Scene.SpecialMoveC2 = [{Scene.Count2 = Scene.Count2 + 1;}, {Scene.SpecialMoveV2 = 1;LPSATB;Scene.Count2 = 1000;}, {Scene.Count2 = Scene.Count2 + 1;}, {Scene.Reverse_axis1x = 0;Scene.Count2 = 0;}];
Scene.SpecialMoveV2 = 0;
Scene.SpecialMoveA2 = [{Scene.SpecialUV = 2;}, {Scene.Reverse_axis1x = 1;Scene.Count2 = 1500;Scene.SpecialMoveV2 = 0;}];
Scene.SpecialMove2 = Keys.bind("z", {Scene.SpecialMoveA2  Scene.SpecialMoveV2();});
Scene.SpecialMoveC1 = [{Scene.Count1 = Scene.Count1 + 1;}, {Scene.SpecialMoveV1 = 1;RPSATB;Scene.Count1 = 1000;}, {Scene.SpecialUV = 2;}, {Scene.Count1 = Scene.Count1 + 1;}, {Scene.Reverse_axis2x = 0;Scene.Count1 = 0;}];
Scene.SpecialMoveV1 = 0;
Scene.SpecialMoveA1 = [{Scene.SpecialUV = 2;}, {Scene.Reverse_axis2x = 1;Scene.Count1 = 1500;Scene.SpecialMoveV1 = 0;}];
Scene.SpecialMove1 = Keys.bind("p", {Scene.SpecialMoveA1  Scene.SpecialMoveV1();});
Scene.PMove = [{Scene.Count3 = Scene.Count3 + 1;}, {Scene.Count3 = 1000;MATB;}, {Scene.PMoveT2 = 20.00;Scene.PMoveT = 18.833334;}];
Scene.PMoveT2 = 0;
Scene.PMoveT = 0;
Scene.SpecialUV = 0;
Scene.Count3 = 0;
Scene.Count2 = 0;
Scene.Count1 = 0;
Scene.Step = 500;
Keys.unbind("space",());
Keys.unbind("x",());
Keys.unbind("p",());
Keys.unbind("z",());
Keys.unbind("a",());
Scene.Reverse_axis2x = 0;
Scene.Reverse_axis2 = [false,true];
Scene.Reverse_axis1x = 0;
Scene.Reverse_axis1 = [false,true];

^^ This code is in reverse order, entering it in in the order shown will mess it up, the scene is one of the links in the original post (both of the links in fact). The above code, if entered without the original scene, only the green boxes will appear (cleanup scene is in response to the original scene).

OFFTOPIC: Anyone notice how close this section is to its 1337th post


http://miniprofile.xfire.com/bg/sf/type/2/gradyfitz.png
Thyme: Tutorial - Beta 5 Command List
I made a typo in my username, it's meant to be gradyfitz.

Offline

 

#9 2009-02-28 03:32:23

kilebantick
Post Addict
From: I haz house?
Registered: 2008-07-06
Posts: 693
Website

Re: [Tutorial]Thyme - With full explanations at every step

XD good examples grady, it taught me a little bit more than i thought it would


http://miniprofile.xfire.com/bg/sh/type/0/kilebantick.pngphun xfire clan www.xfire.com/clans/thephunclan http://www.signaturebar.com/uploads/images/18441.gif Unnoficial  Phun chat room http://xat.com/Algodoo_Phun
http://img200.imageshack.us/img200/4564/kaged.jpg

Offline

 

#10 2009-02-28 09:31:51

BBZS
B-Boy Zach Smith, yoyo in da hous! Word!
From: ALERT! BULLSHIT AT 2'O'CLOCK!
Registered: 2008-09-12
Posts: 742
Website

Re: [Tutorial]Thyme - With full explanations at every step

O.O Leave it to Grady to make a novel out of a tutorial.

I think I might be too lazy to read it tongue


Considering quitting;
-insert dramatic sound effect here-

Offline

 

#11 2009-02-28 16:14:17

gradfitz
Post Manic
From: Australia
Registered: 2008-10-05
Posts: 823

Re: [Tutorial]Thyme - With full explanations at every step

BBZS wrote:

O.O Leave it to Grady to make a novel out of a tutorial.

I think I might be too lazy to read it tongue

Well, its only for those who are interested.

Off-topic: 1337'th post for this forum smile


http://miniprofile.xfire.com/bg/sf/type/2/gradyfitz.png
Thyme: Tutorial - Beta 5 Command List
I made a typo in my username, it's meant to be gradyfitz.

Offline

 

#12 2009-02-28 22:53:18

Skillkills
Senior Member
From: Hiding in your closet
Registered: 2008-08-14
Posts: 281

Re: [Tutorial]Thyme - With full explanations at every step

gradfitz wrote:

Off-topic: 1337'th post for this forum smile

haha... nice catch, if ida done that i neva wouldve noticed


http://i540.photobucket.com/albums/gg327/ioncann0ns/ubd9085-1.pngGet Pumped 
☻/
/▌  this is bob. copy and paste bob and he will soon take over the forums
/ \

Offline

 

#13 2009-03-12 15:32:40

phunHunger
Member
Registered: 2009-03-06
Posts: 27

Re: [Tutorial]Thyme - With full explanations at every step

negate(var) can also be used instead of the algebra you used. It has to be a boolean*.

Last edited by phunHunger (2009-03-12 18:03:53)


--------------------------
P-H-U-N H-U-N-G-E-R
--------------------------
http://www.phunland.com/forum/img/avatars/2705.png

Offline

 

#14 2009-03-21 01:18:53

Blair
Respected Member
From: Nova Scotia, Canada
Registered: 2009-03-21
Posts: 117

Re: [Tutorial]Thyme - With full explanations at every step

WOW! I learned sometin.... now my head hurts...

You should add a warning label that states, "Not liable if readers brain explodes/melts" tongue


-=-Blair-=-

Offline

 

#15 2009-03-21 18:13:04

gradfitz
Post Manic
From: Australia
Registered: 2008-10-05
Posts: 823

Re: [Tutorial]Thyme - With full explanations at every step

Beta 5.25:
Big one eh.
Beta 5 Introduction
I finally finished reading that tutorial, what now?
Well, the new beta of Phun/Algodoo has been released, and there are so many new functions.

Beta 5 Index:
Tutorial 9: General differences in Thyme
Tutorial 10: .this .other
Tutorial 11: Scene.my.
Tutorial 12: Argumentative functions
Tutorial 13: Infix (small one here, don't know much about it)
Tutorial 14: if structures
Tutorial 15: OnCollide
Tutorial 16: .phn editing

Tutorial 9: General differences in Thyme
What are some of the differences that are in thyme this version?
This version, Thyme is no longer case sensitive, meaning AZXX is the same as azxx, or aZxX, etc. a scripting menu (which shows all the properties of a geometry, fixate, hinge, spring, plane or tracer), variables not requiring structures to be modified and most the topics in the Index.

What about ways to represent things?
Ah, yes, in beta 5, the way scenes are saved has changed, you will find out more in the .phn editing section. := is the assignment operator, I find it easier to just use = but still, its something you can note, and possibly use some day.

Can I make things appear in the console?
Yes, you can, if you want the long way:
1.Open the console("~" or "F11")
2.Type Console.print
3.Then start a bracket (()
4.Then type what you want it to print, if its a variable, type the name, if its a string (word/letter), type it in quotation marks ("here"), you can add more by using "+" and then adding your next part
5. It should look something like Console.print("here" + aZxX)

Instead of Console.print, emil has also included a print function out of any structures, you can access it using "print" instead of "Console.print", either way will give you the same result.




Tutorial 10: .this, .other
What is .this?
.this is a structure when working with OnCollide (shown in Tutorial 15), this is basically going to be a short introduction.

Where would I use .this?
You would use .this in OnCollide functions, so you can modify the variables of what you are working with, from my experience, e.this is used for working with building a shape, so you can add verticies while you are creating the shape.

What is .other?
.other is a structure when working with OnCollide (tutorial 15), just like .this, its going to be a short introduction, as the use is all in OnCollide, so it will be explained there in more depth.

Where would I use .other?
Just like .this, you'd use .other in OnCollide, to modify the other object in the collisions properties (such as attraction, color, density or some others), or fetch a property, like other.pos (position of other object in collision).








Tutorial 11: Scene.my.
What is Scene.my. ?
Scene.my. is a structure, new to beta 5, that allows users to create variables that will save into the scene's file, and go into people who use the scenes configuration files, then delete when you close the scene (New Scene/Load Scene), and wont leak in to the configuration file (very good for those of us who use a lot of thyme)

Why would I want to use Scene.my. ?
Scene.my. means that you are able to put variables in and they wont leak into those who use the file's configuration files, which means that you are going to have a lot less of people yelling at you saying things like: "This messed up my version of Phun", although you may provide a fix for it, you can't expect people to even read the instructions (if they bought a $1000 TV, they might press the on button, say it doesn't work, because they haven't plugged it in, they'll post thousands of reviews saying how bad it is, call the company, yell at them a bunch, then the company will say, "Plug it in", and it will work). Scene.my. means there is minimal requirement for editing scenes.

How would I use the Scene.my. structure?
1. Bring down the console using "~" or "F11"
2. Type Scene.
3. Type My.
4. Type a variable/function/array/action array like Vairinviatia
5. Type an equal sign =
6. Type a value like 7.663
7. It should look something like Scene.My.Vairinviatia remember, case doesn't matter, thyme in beta 5 is case insensitive.








Tutorial 12: Argumentative functions
What's an argumentative function?
An argumentative function is a function that takes arguments, these arguments are declared constants, and sent into the function as what they are declared as.

You said it was declared as a constant, what does that mean again?
A constant is a type of variable, which is unable to be changed, constant variables (aren't oxymorons funny), are used in a few places in Programming languages, to multiply variables, add an amount to a variable, or use as a factor in a simulation, or even just keep a value that isn't going to change any time soon (like pi, its not going to be able to get any bigger as arbitrary precision isn't going to be implemented into phun any time soon("Orders of magnitude slower")).

What's an argument?
An argument is a value that is taken into account when executing an action, possibly just as a check, to make sure something isn't dangerously high, or abnormally low

How would I go about implementing an argument taking function?
1.Open the console (F11/~)
2.Type your name for your argument taking function, like APlusBnC
3.Add an equal sign.
4.Add the number of arguments you are going to take into the function, and the names of them (declare them) like (a,b,c)
5.Add an equal sign and a ">" sign
6.The rest is like an action, add a curly bracket ("{")
7.Create a function, like print(a + b + c)
8.End your curly bracket ("}")
9.It should look something like: APlusBnC = (a,b,c)=>{print(a + b + c)}


Why would I want to use an argumentative function (a function that takes arguments/variables)
A lot of programming languages use functions that use arguments, as it means that you don't have to make variable change after variable change, and you can just send something in, one thousand times, and it will not take you 1000 different functions, or variable changes, it will take you just one variable function, and you can perhaps tell it to repeat itself 10 times in a row (using the for function emil has included), and you can grab the result each time, and it will take you 100 function CALLS, instead of 1000 functions, the difference between function calls and functions is that 1000 function calls uses one function, 1000 functions use 1000 functions. It can also be used to use functions such as logarithms, or values that may require large refinement, these values can be more useful than things like windows calculator, as they will be able to be modified to get exactly what you want, and to test if formulas work when you want to test one.







Tutorial 13: Infix
What's an infix?
Infix is a function that will let you set an operator to send a few variables to a function, instead of having to write "Scene.my.ExcessivelyLongFunctionNameForDemonstrationOfUsefullness(x,y)" you may only have to write x+-y this does mean that you may save a lot of time, and descriptive variable names being too long to write wont be a problem.

Well reading what the infix function does, I want to make one, how?
1.Open the console (~/F11)
2.Type infix (note: case sensitive)
3.Type the number of arguments, like 2 (after a space)
4.Type the order to read from, like right (after another space) (note: case sensitive)
5.Type a colon(:)
6.Type an underscore(_) for where you are going to get values from
7.Put operators where you require them for the function to be carried out
8.Type "=>" to pass the variables to the argumentative function
9.The Infix function should look something like: Infix 2 Right: _+-_ => AnB

I don't know how to use infix well, I don't know how to remove infix's so until I do, don't ask me (I will update it here when I find out)


Why would I want to use an infix operator?
It may increase speed, or you could use it for things that you are repeating a lot, like perhaps generating radians using .$. or something like that, or an RGB value in colours instead of HSV (or, if you have it on instead) HSL.







Tutorial 14: if structures
What's an if structure?
An if structure is a structure that can be used to determine whether a condition has been fulfilled, if it has, it will switch to the then action, if it isn't, it will switch to the else action.

Then, else?
Then is the function to be executed if the variable satisfies a certain function, else is the function to be executed if the variable doesn't satisfy it.

How do I use an if structure?
1.Open the console (~/F11)
2.Create a function, like CheckLargest
3.Add your arguments and sending operator, like = (Val1,Val2)=>
4.Start a curly bracket ({)
5.Type your first variable that you want to check if it satisfies the condition, like Val1.
6.Type the operator for the comparison, (!= - Not Equal to, == - Equal to, >= - More than or equal to, <= - Less than or equal to, < - Less than, > - More than), like =>
7.Add your variable you want to check against, like Val2
7.Add a space and a question mark  ?
8.Add your action to be taken if it is true, in curly brackets, like {Val1 == Val2 ? {print "They are Equal"} : {print (Val1 + " is bigger than " + Val2)}}
9.Add a colon a space, and your action to be taken if its false, in curly brackets like {print (Val2 + " is bigger than " + Val1)}
10.End your curly bracket (})
11.Your function should look something like: CheckLargest = (Val1,Val2)=>{Val1 => Val2 ? {Val1 == Val2 ? {print "They are Equal"} : {print (Val1 + " is bigger than " + Val2}} : {print (Val2 + " is bigger than " + Val1)}}


Why would I want to use an if structure?
If structures are useful because they use logical gates to determine if something satisfies a condition, they can be used to do things such as creating an efficient logic gate that doesn't use any complex collisions, and may have a system where something is pushed over one side, and if you were to transfer that force in a mechanical system, then it has a chance to break, whereas with Thyme gates, you could have a system that was perfectly reliable, and would be able to work perfectly across excessive distances, whereas, if you replicated it with a mechanical transfer system, it could get very very laggy, with a lot of cogs moving, also, Thyme code weighs nothing, which means that its not going to influence the weight of a system, meaning you can store a thyme logic gate on an aeroplane in a stack of 9 million, and it would take up a fraction of the weight that a mechanical logic gate would take.






Tutorial 15: OnCollide
What is OnCollide?
OnCollide is a function that calls a command to happen when an object touches it, action can be taken only under certain conditions using "if" structures, if the object it touches is a certain colour, or under a certain shade or hue

Where is OnCollide?
In the scripting menu.

Where's the scripting menu?
In the context menu for a geometry/plane/hinge/spring/fixate, if its not there, go into options and select Advanced mode.

How would I go about creating an OnCollide command?
1.Open the Context Menu for that object
2.Go to the scripting window, and drag the top of that window, as that will make it so if you accidentally move your mouse over a different option it wont remove the window from the view.
3.In the onCollide section, there will be: e=>{}, in the {} you put your command for when there is a collision, like Scene.addBox({size = [1,1]; pos = [(e.pos 0), (e.pos 1 + 1)]})
4.Your code should look something like: (e)=>{
   Scene.addBox({size = [1, 1];pos = [(e.pos 0), (e.pos 1 + 1)]}) }
Note: that code will make a fountain of boxes to the left

You can do the same thing, but only if the object is hit by red by putting this in the brackets
3.e.other.color 0 > 0.89999998 ? {Scene.addBox({pos = [(e.pos(0)), (e.pos(1) + 1)];size = [1, 1]})} : {} }
4. Make sure you have (e)=>{ at the start and } at the end

With these in mind, you are going to be able to create some pretty fun things.


Why would I want to use OnCollide?
You might want to build a logic gate, a lightswitch (I've done it before), a wall sensing car, infinite fuel/ammunition for vehicle/weapon, the possibilities go on.








Tutorial 16: .phn editing
What's a .phn file?
A .phn file is a file that contains all the data that a scene carries from save to save.

I thought .phn's didn't exist anymore, do they?
Yes they do, they are just in .phz files, a zip file, localized to phun, they can still be edited in notepad

I also thought that everything in a scene was there already, because of Scene.my.
Scene.my. doesn't cover Key bindings, thats about all that you would need to manually add variables for.

I opened the .phz in a text editor, and it doesn't look like it has anything I can edit, have I done something wrong?
Nope, you just need to open the file in a zip opening program, as .phz is a zip file, open it with a program like WinRAR then open the .phn file with a text editor like notepad.

Last edited by gradfitz (2009-03-21 18:14:18)


http://miniprofile.xfire.com/bg/sf/type/2/gradyfitz.png
Thyme: Tutorial - Beta 5 Command List
I made a typo in my username, it's meant to be gradyfitz.

Offline

 

#16 2009-03-21 18:58:08

Paradigm 29
Spoonman!
From: Houston, Texas
Registered: 2008-07-22
Posts: 1565

Re: [Tutorial]Thyme - With full explanations at every step

Thankyou Grady!


http://i42.tinypic.com/24y8sax.png

Offline

 

#17 2009-03-21 19:19:01

guyboy
Phunky Munkey
From: Zürich, Switzerland
Registered: 2008-04-02
Posts: 1866

Re: [Tutorial]Thyme - With full explanations at every step

ummm, grady, can you write the console instructions as plane code plz?


http://i38.tinypic.com/s474pl.jpg
Human horse pasture expansion OpenGL Book Hall
Kwon owned Version (C) 2002-2008

Offline

 

#18 2009-03-21 19:20:12

RBS
Post Addict
From: State of Denial
Registered: 2008-08-27
Posts: 733

Re: [Tutorial]Thyme - With full explanations at every step

Very nice!


It's hard to remember to live before you die.

Offline

 

#19 2009-03-21 19:48:06

DaffyGKH
Respected Member
Registered: 2008-07-18
Posts: 162

Re: [Tutorial]Thyme - With full explanations at every step

How do I do an oncollide to make a textured phunlet go to the right?

Offline

 

#20 2009-03-21 22:30:06

kilebantick
Post Addict
From: I haz house?
Registered: 2008-07-06
Posts: 693
Website

Re: [Tutorial]Thyme - With full explanations at every step

O.O BWAAAH, that B5 thing was relativly easy to understand. good job Grady.


http://miniprofile.xfire.com/bg/sh/type/0/kilebantick.pngphun xfire clan www.xfire.com/clans/thephunclan http://www.signaturebar.com/uploads/images/18441.gif Unnoficial  Phun chat room http://xat.com/Algodoo_Phun
http://img200.imageshack.us/img200/4564/kaged.jpg

Offline

 

#21 2009-03-21 23:46:15

DaffyGKH
Respected Member
Registered: 2008-07-18
Posts: 162

Re: [Tutorial]Thyme - With full explanations at every step

...Peoples?
(sad)

Offline

 

#22 2009-03-22 01:45:42

gradfitz
Post Manic
From: Australia
Registered: 2008-10-05
Posts: 823

Re: [Tutorial]Thyme - With full explanations at every step

DaffyGKH wrote:

...Peoples?
(sad)

Please explain smile

But, I assume you mean that other post, I didn't quite understand it, so I will assume it is how I read it.

"How do I make oncollide generate a textured geometry (I assume you meant geometry, if not, please refine your question) appear to the right."

Code:

OnCollide = (e)=>{Scene.addBox({size := [1, 1];texture := "<TEXTURE HERE>";pos := [(e.pos(0) + 5), (e.pos(1))]}) }

Fix the code up the way you want, and edit things so they are the way you want for what you are doing.


http://miniprofile.xfire.com/bg/sf/type/2/gradyfitz.png
Thyme: Tutorial - Beta 5 Command List
I made a typo in my username, it's meant to be gradyfitz.

Offline

 

#23 2009-03-22 17:49:03

Blair
Respected Member
From: Nova Scotia, Canada
Registered: 2009-03-21
Posts: 117

Re: [Tutorial]Thyme - With full explanations at every step

I was messing around with the onColide tutorial code (which is awesome by the way) and changed one thing:

Code:

onColide=>{Scene.addBox({size = [1, 1];pos = [(e.pos (0)), (e.pos(2))]  }) }
                                                                                                         
                                                                  ^
                                                                  |

I made myself a box cannon! big_smile


Thx for the great tutorials!

Last edited by Blair (2009-03-22 17:53:42)


-=-Blair-=-

Offline

 

#24 2009-03-22 18:03:45

KaLul
admiral awesome!
From: Germany
Registered: 2008-04-02
Posts: 767

Re: [Tutorial]Thyme - With full explanations at every step

u are awesome!!!! thx for those great tutorial!!!!


http://tiny.cc/Rg8Io
http://tiny.cc/OrVvWhttp://tiny.cc/act464
emilk sayd -->  Soft/breakable objects: Will need a lot of work, but I really want this feature in Phun, so expect it at some (distant) point in time.
[please add this to ur sig if u want it] http://www.youtube.com/watch?v=-9NJzXwZChQ

Offline

 

#25 2009-03-23 17:15:03

DaffyGKH
Respected Member
Registered: 2008-07-18
Posts: 162

Re: [Tutorial]Thyme - With full explanations at every step

No, a phunlet, a 3 part fixated together phunlet, appear horizontal, not a geometry. I'll use one for circles now though, with pens.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson

Phun and Phunland.com is copyright of Algoryx