Well excuuuuuuse me!Read through the thread. If he wanted to simply copy and paste someone elses work, the thread would've finished on the first page.
The 'QuakeC lessons' thread[prev. help with script teleport]
Moderator: Core Staff
Re: help with script teleport
-
- Core Staff
- Posts: 2030
- Joined: July 24th, 2006, 11:21 am
- Location: Cramped in a small cubicle/making another jump map
Re: help with script teleport
1.) It can be anything, something like a_z_gggg_EGAHEAEHAGWA_LOLrofl = "" would work equally well, you'd just have a really hard time using the variable later on. That's why simple, yet descriptive names are encouraged.Ryan wrote:why is it myVariable or can it be anything actually?
why is it myVariable = ""; what do the "" do there
why is it for(;;) what do the ;; do there
why is it i=0; i<15 what is i?
how do you print out this stuff then? rezil asked to make players able to see this then...
2.) the "" tells the script you want to make myVariable a string(basically letters and numbers, sort of like a sentence). If you were to make myVariable = 0, that would tell the script that it's an integer(a 'whole' number: 0, 1, 2, -5, -6, 54 etc.)
3.) Read drofders tut again, that's an infinite loop.
4.) Again, drofders tut, that's a finite loop that loops for 15 cycles, i is just the name of the variable, anything could've been used but the general practice is to use letters from i onward in finite loops.
5.) The same way you printed it out before, iPrintLn and iPrintLnBold
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.
Re: help with script teleport
and why is it i = 0? and could it have been rezilhelpsscriptinglol = 0 too?
maybe we should move on to easier tasks if there are easier tasks at all
maybe we should move on to easier tasks if there are easier tasks at all
Re: help with script teleport
so if i put myVariable = ""; but later i put i it still works? how does it still know what variable it is related to then?
Rezil i like your exercises but this one was a bit hard for me
Rezil i like your exercises but this one was a bit hard for me
-
- Core Staff
- Posts: 13313
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
Re: help with script teleport
For clarification 'i' is commonly used for INTEGERS. Variables can be anything you choose them to be (although, there are a few exceptions...)
The For Loop
<declaration> = You can declare a variable here. (It is common to declare a integer for counting)
<while> = This section of the loop is what tells the loop when to end. (Most commonly, this will be the a LESS THAN statement)
<statement> = This is performed at the end of EVERY loop. (Usually to increment the counter)
The following two loops, are exactly the same:
With the FOR loop, none of the fields are required, so the following, will also work (although pointless)...
And because no fields are required if you do "for(;;)", you are telling the loop, to not create a variable, to never end and to never perform an action.
The For Loop
Code: Select all
FOR( <declaration> ; <while> ; <statement> )
<while> = This section of the loop is what tells the loop when to end. (Most commonly, this will be the a LESS THAN statement)
<statement> = This is performed at the end of EVERY loop. (Usually to increment the counter)
The following two loops, are exactly the same:
Code: Select all
for( i = 0 ; i < 100 ; i++)
{
  iprintln(i);
}
Â
Â
i = 0; Â Â Â Â Â Â /* <declaration> */
while( i < 100 ) /* <while> */
{
  iprintln(i);
  i++;      /* <statement> */
}
Code: Select all
i = 0; Â Â Â Â Â Â /* <declaration> */
for( ; i < 100 ; ) /* <while> */
{
  iprintln(i);
  i++;       /* <statement> */
}
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010
-
- Core Staff
- Posts: 13313
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
Re: help with script teleport
If you create a variable called "myVariable" and then assign the value of "", you are simply creating a STRING variable with no value. You can then later use this variable to store string data.Ryan wrote:so if i put myVariable = ""; but later i put i it still works? how does it still know what variable it is related to then?
Rezil i like your exercises but this one was a bit hard for me
So if I do
Code: Select all
myVariable = "";
anotherVariable = "This Is One ";
yetAnotherVariable = "Half Of A Variable";
I can then do:
Code: Select all
myVariable = anotherVariable + yetAnotherVariable;
iprintln(myVariable);
Read slow and let us know if you're not following
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010
Re: help with script teleport
but if i put
myVariable = "";
do i have to put later on
for(myVariable = 0; myVariable < 10; myVariabe++)
or can i put
for(i = 0; i < 10; i++)
myVariable = "";
do i have to put later on
for(myVariable = 0; myVariable < 10; myVariabe++)
or can i put
for(i = 0; i < 10; i++)
-
- Core Staff
- Posts: 13313
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
Re: help with script teleport
Well, technically you could do that, but there are limited reasons to do it.
Take for example.
In the above example, you can see that the variable 'i' is given a value of 80.
I then declare a new variable called 'j' that I give the value of 'i' plus 20.
At this point in the script, I no longer need the value of 'i'. It is a variable that no longer has any use.
I can choose to recycle this variable and use it in the loop. Although this will save some (tiny amounts) of memory it will practically not change anything. I could just as easily use another variable in its place in the loop and it would make zero difference.
Now, for the sake of learning, it is safer and easier to simply use a new variable in the loop. This will help you avoid confusion and will also make error handling a lot easier.
To summarise:
No you do NOT have to use existing variables, you can use any variable you wish when creating your loops
Take for example.
Code: Select all
main()
{
  i = 80;
  j = i + 20;
Â
  for(i=0;i<j;i++)
  {
   iprintln(i);
  }
}
I then declare a new variable called 'j' that I give the value of 'i' plus 20.
At this point in the script, I no longer need the value of 'i'. It is a variable that no longer has any use.
I can choose to recycle this variable and use it in the loop. Although this will save some (tiny amounts) of memory it will practically not change anything. I could just as easily use another variable in its place in the loop and it would make zero difference.
Now, for the sake of learning, it is safer and easier to simply use a new variable in the loop. This will help you avoid confusion and will also make error handling a lot easier.
To summarise:
No you do NOT have to use existing variables, you can use any variable you wish when creating your loops
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010
Re: help with script teleport
alright thanks for your help guys... do you mind giving other exercises which i can now try?
Re: help with script teleport
Alright,
This one might be a bit hard for you, but you can always ask for some help:
Run a thread on every player after said player connects (use level waittill("connecting", randomvar); to put the player in the "randomvar") and make it display the distance between where a player starts pushing the use-key and where the player lets go of the use-key.
As said, this might be a bit steep, but practice makes perfect
This one might be a bit hard for you, but you can always ask for some help:
Run a thread on every player after said player connects (use level waittill("connecting", randomvar); to put the player in the "randomvar") and make it display the distance between where a player starts pushing the use-key and where the player lets go of the use-key.
As said, this might be a bit steep, but practice makes perfect
Re: help with script teleport
a little tip:
sElF uSeBuTtOnPrEsSeD()
sElF uSeBuTtOnPrEsSeD()
Re: help with script teleport
how can you make the script print the different values every time? like its not always 5x5 is equal to 25. 5 5 and 25 are variables that change with every round. but how do you let the scirpt know this? i just put what seems most logical to me.. again ive no idea how to do this and just guessed:KillerSam wrote:Ok...how about.......Ryan wrote:alright thanks for your help guys... do you mind giving other exercises which i can now try?
Print to the screen all the square numbers as far as 20x20
it should be displayed as follows to the user:
"5x5 is equal to 25"
"6x6 is equal to 36"
You should use a calculated value, using the loops you've used previously. If you need help or clarification, post back.
Code: Select all
for(i=0;i<21;i++)
{
var = i * i;
iprintln("(i)x(i) is equal to (var)";
if(i>20)
{
wait 1;
break;
}
}
Re: help with script teleport
pretend you know the words "hi" and "my name is". now translate this text for me:IzNoGoD wrote:Alright,
This one might be a bit hard for you, but you can always ask for some help:
Run a thread on every player after said player connects (use level waittill("connecting", randomvar); to put the player in the "randomvar") and make it display the distance between where a player starts pushing the use-key and where the player lets go of the use-key.
As said, this might be a bit steep, but practice makes perfect
Each market has its own regulations and little formality is needed. Contracts are made by verbal agreement. Brokers, who act as intermediaries between buyers and sellers, make notes of the essentials of the transactions made. On the basis of these essentials they issue so-called contract notes, which serve as written confirmations of commodity market transactions.
thats about the level of scripting i range between and the level of scripting required to solve your exercise...
edit: yeah sam i'm following everyhing clear thanks for your help mate, mind giving me more exercises? ig uess ill have to be advanced to do IzNoGod's one
Last edited by Ryan on May 3rd, 2011, 1:30 pm, edited 1 time in total.
-
- Core Staff
- Posts: 2030
- Joined: July 24th, 2006, 11:21 am
- Location: Cramped in a small cubicle/making another jump map
Re: help with script teleport
You can try that one when you've advanced quite a bit.
Also:
is about as optimal as it gets.
By the way Ryan, do you know how to test your code? As in, how to put it in a map script and make it run?
Try this:
Make three functions. The first function, fA(param) should return the square of the parameter <param>. The second one, fB(param) should return a boolean(true/false) on whether the parameter <param> is divisible by 3(use modulus - %). The third one, fC(param1, param2) returns a string is this format: "<param1>:-:<param2>".
This one sounds really fun now that I've made it up, give it a go.
Print all three using iprintln.
Also:
Code: Select all
for(i=0;i<21;i++)
    iprintln(i+"x"+i+" equals "+(i*i));
By the way Ryan, do you know how to test your code? As in, how to put it in a map script and make it run?
Try this:
Make three functions. The first function, fA(param) should return the square of the parameter <param>. The second one, fB(param) should return a boolean(true/false) on whether the parameter <param> is divisible by 3(use modulus - %). The third one, fC(param1, param2) returns a string is this format: "<param1>:-:<param2>".
This one sounds really fun now that I've made it up, give it a go.
Print all three using iprintln.
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.
-
- Core Staff
- Posts: 13313
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
Re: help with script teleport
Most of what I previously typed has been explained, but here is the answer to your question regarding the change of variable and how does it know it has changed. It all lies in the loop.
To read the entire function in Pseudocode would be:
1. Create a loop.
1a. Declare a variable called 'i' and give it value of zero
1b. Tell the loop to continue looping while the value of 'i' is less than 21.
1c. At the end of each loop do action 'i++' (add 1 on to the value of 'i')
2. Start Loop
3. Create a variable called 'var' and assign it the value of 'i' squared. (i = 0, therefore var = 0)
4. Print the message to screen (using current variable values)
5. End Loop - Add 1 to the value of 'i' (i now equals 1) - Repeat from (3).
3. Assign the varaible 'var' a value of 'i' squared (i = 1, therefore var = 1)
4. Print the message to screen (using current variable values)
5. End Loop - Add 1 to the value of 'i' (i now equals 2) - Repeat from (3).
(Many loops later)
3. Assign the varaible 'var' a value of 'i' squared (i = 20, therefore var = 400)
4. Print the message to screen (using current variable values)
5. End Loop - Add 1 to the value of 'i' (i now equals 21) - <While> condition is false! (21 is NOT less than 21)
6. Break Loop
To read the entire function in Pseudocode would be:
1. Create a loop.
1a. Declare a variable called 'i' and give it value of zero
1b. Tell the loop to continue looping while the value of 'i' is less than 21.
1c. At the end of each loop do action 'i++' (add 1 on to the value of 'i')
2. Start Loop
3. Create a variable called 'var' and assign it the value of 'i' squared. (i = 0, therefore var = 0)
4. Print the message to screen (using current variable values)
5. End Loop - Add 1 to the value of 'i' (i now equals 1) - Repeat from (3).
3. Assign the varaible 'var' a value of 'i' squared (i = 1, therefore var = 1)
4. Print the message to screen (using current variable values)
5. End Loop - Add 1 to the value of 'i' (i now equals 2) - Repeat from (3).
(Many loops later)
3. Assign the varaible 'var' a value of 'i' squared (i = 20, therefore var = 400)
4. Print the message to screen (using current variable values)
5. End Loop - Add 1 to the value of 'i' (i now equals 21) - <While> condition is false! (21 is NOT less than 21)
6. Break Loop
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010
Who is online
Users browsing this forum: No registered users and 3 guests