Posts
86
Respect
34Add +1
Forum Rank
Rotting Walker
Primary Group
Community Mapper
Login Issues
Forgot password?Activate Issues
Account activation email not received? Wrong account activation email used?Other Problems?
Contact Support - Help Center Get help on the UGX Discord. Join it now!Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager. |
my_variable = WHAT_IM_SETTING_IT_TO;and in this tutorial I'm gonna go over the various things we can set it to and how we can manipulate the variables
jblundell_quote = "fog rolling in";now because we've stored the string inside that variable, we can use that variable in place of where we would normally use a string. for example in the IPrintLnBold() function:
jblundell_quote = "fog rolling in";note this is the same as:
IPrintLnBold(jblundell_quote);
IPrintLnBold("fog rolling in");
push_ups_performed = 0;if we want to do math operations on a variable, we can do it like this:
push_ups_performed = push_ups_performed += 3; //adds 3notice we have to type it twice, because we want to define it as itself (whatever it used to be) plus the 3, not just as 3.
push_ups_performed = push_ups_performed -= 3; //subtracts 3
push_ups_performed = push_ups_performed * 3; //multiplies by 3
push_ups_performed = push_ups_performed / 3; //divides by 3
push_ups_performed ++; //adds 1POP QUIZ: What number will this print to the screen?
push_ups_performed --; //subtracts 1
push_ups_performed = 5;if you said
push_ups_performed --;
push_ups_performed = push_ups_performed * 4;
push_ups_performed = push_ups_performed - 7;
push_ups_performed = push_ups_performed / 3;
push_ups_performed ++;
IPrintLnBold(push_ups_performed);
entity GetEnt(,,[ignore spawners])notice how when we look up the engine functions in the Modme ScriptDocs, the word entity appears before it. This means that using this function will return us an entity, which we can store in a variable. So using this function would look like this:
watermelon_model = GetEnt("watermelon","targetname");assuming that in radiant we have a script_model with the KVP of targetname: watermelon. And preferably it looks like a watermelon.
ur_gay = true;please note that true and false do not go inside quotation marks "", or else you would be setting it equal to a string that simply is the word "true".
entity GetEnt(,,[ignore spawners])the first parameter is required and it is the name you gave the key of the entity in radiant. The second is also required and it is the key you are using of the entity in radiant.
value = "watermelon";notice that I don't have to give the arguments the same exact names as the parameters being asked for.
key = "targetname";
include_spawners = false;
watermelon_model = GetEnt( value, key, include_spawners);
function calculate_bmi( weight, height )In this example the function is asking for two parameters: a weight, and a height.
{
bmi = weight / height / height;
IPrintLnBold("your BMI is " + bmi);
}
calculate_bmi( 70, 1.8 ); //weight is in kg and height is in m
watermelon_model thread fly_away();provided we've already defined the watermelon model above, most likely using GetEnt() as I talked about before.
function fly_away()this will make the watermelon fly upward by 1000 units in 10 seconds.
{
self MoveZ(1000, 10, 5);
}
function calculate_bmi( weight, height )it's as simple as putting the word return before the value we want to return. Now when calling this function, in order to receive the bmi value we must set a variable for it to be stored in:
{
bmi = weight / height / height;
return bmi;
}
my_bmi = calculate_bmi( 60, 1.5);now we can use the variable my_bmi which should have stored in it the calculated value using the data 60 for the weight and 1.5 for the height.