sábado, 28 de septiembre de 2013

Custom Variables, Key binds,If Statements, and Mouse Control

Custom Variables, Key binds,If Statements, and Mouse Control

Postby niffirg1 » Fri Sep 04, 2009 3:23 am
Custom Variables
Brief Explaination 
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). (Gradfitz Explanation)
Creating a Variable 
1. First open up the console by pressing ~ or the tilde key 
2.Type in Scene.my.Var = 0
3.0 is the value of which the variable is set to 
4.Doesnt have to scene.my.var, Can be scene.my.hasdfl. Can be anything as long as it is scene.my.
5.Use that Variable to do any thing (Not Literally of course)
6. Use it to Control MotorSpeed, Spring length, counters, etc.
Here is a Video Tutorial on Custom Variable and Key binding

[youtube]UQBBse72DAY[/youtube]
If Statements
Explaination
An if statement is if this happens than this will happen as a result
Creating an If statement
1.Create a Fast colliding Object like a probe 
2.Type {scene.my.var == 10} ? {scene.my.hasdfl = 129} : {} in the oncollide menu of the Probe
3.This Says that is Scene.my.var gets to the value ten then as a result scene.my.hasdfl is set equal to the value 129
4. Use this in what ever way you want 
Mouse Control
Mouse Controlled Hinge
Mouse Control can be helpful in many ways. Like Video Games
Creating a Mouse Controlled Hinge
1.Go into the Console and type scene.my.pos = [0,0] and hit enter 
2.Create a Probe or fast colliding object 
3.In the oncollide of that probe type scene.my.pos = e.pos
4.Create a simple Car and put the Probe on the car 
5.In the script menu of the Car hinges type in th motorspeed space -{app.mousepos(0) - scene.my.pos(0)}
6. The car will now Follow the Mouse
Last edited by niffirg1 on Mon Sep 07, 2009 4:46 am, edited 4 times in total.
User avatar
niffirg1
 
Posts: 376
Joined: Mon Aug 31, 2009 10:31 pm
Location: The Great American South!

La cámara sigue al objeto

the script (e)=>{scene.camera.pos=e.pos}

Tutoriales de Kasper Hviid

Quick & Easy Timer!

Quick & Easy Timer!

Postby Dare » Sat May 07, 2011 10:47 am
How to make a quick and easy timer. Works for Phun and Algodoo.

Steps:
Step 1) Make a box.
Step 2) Open up the "Script menu".
Step 3) Type the following code into the "text" section:
CODE: SELECT ALL
{sim.time + ""}

Crear y posicionar un cuadrado

scene.my.boxPos := [1,1];
scene.addBox({pos := scene.my.boxPos})

By Kilinich

Control del ratón

Scene.addLaserPen {
    geom := 0;
    relPoint := [-0.20744929, 0.19884428];
    velocity := +inf;
    fadeDist := 0.1;
    maxRays := 1;
    cutter := false;
    opaqueBorders := true;
    showLaserBodyAttrib := true;
    size := 0.1;
    collideSet := 127;
    collideWater := true;
    color := [1.0, 1.0, 1.0, 2.0];
    activationButton := "mouse_left"
}


By Mystery


Sonidos en algodoo

viernes, 20 de septiembre de 2013

Completo tutorial de programación de scripts, thyme


Tutorial
http://es.scribd.com/doc/49755166/Thyme-Tutorial-The-basic-and-advanced-techniques

Tutorial que puedes bajarte

Acciones, temporizadores, matrices, teclas

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

Acciones, temporizadores

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

Control de teclas

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

Matriz de acciones. Action array

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

Acciones y punteros

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)

Creando una matriz

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.

Creando una variable

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.

Creación de scipts y variables

Script para crear agua


Programación. Introducción 1


Estructura if