Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bots, Everywhere
#3
Hey, I got some advice on how to start. Don't do "missions" just yet, check the "exercises" - they show you very simple example programs that you can run, follow and modify. Second thing: There's a tool that allows you to track the program execution in real time, when program is working, open the program edit window on the bot and check the buttons. When you feel ok with it you may want to write your first simple programs in "exercises". Also here are some basic rules that may help you:

Programs are going from top to bottom, line by line. Don't forget to put in semicolons after almost everything.
there are commands - the functions, that tell robot what to do. - like 'move(5);', 'fire(1);', 'turn(90);'. - these end with semicolons. And have a pair of brackets with stuff in them!
there are also causes that tell robot on when and how to do the aforementioned commands, like 'while(true)', 'if(LotteryNumber==5)' - these have brackets too, but no semicolons after them.
and there are some things that hold information, like in mathematics, 'x = 20;', 'color = "blue";', etc. They have semicolons too.

the commands - functions - may have some parametres - arguments in brackets. So move(20) will mean move front 20 metres, while move(-20) means move back 20 metres. turn() takes degrees as argument. fire() uses seconds.

One of first levels in 'exercises' will make you kill three spiders by only turning and shooting. I highly recommend it.

then you will learn stuff like

while(true)
{
turn(90);
wait(5);
}

this will make robot turn around and wait in a loop that goes on forever. Then you might want to check out other loops.

then you might want to check out the conditional clause, if()

example:

int a =1
int b =2
if(a+b==3)
{
move(10);
}

or

int a =5;
int b =7;
if(a+b==3)
{
move(10);
}


one of these will move the robot, while the other won't. About what is "int" you might want to read -
'int a = 20;' means 'make a integer number X, and make it equal 20' and stuff like 'string Name = "John"; ' means 'make a string of letters, named Name, and make them hold the letters J, o , h and n.' When you get it, you may want to check out the rest of types in the manual, and then learn individual functions like grab(), direction(), radar() and more, or look them up as you need in the handbook.
in colobot, if you type
x=2;
y=3;
z=x+y;
it wont work, because it does not figure out by itself that x, y and z are numbers, and you need to declare it, it's just how it is.
instead try,
int x;
int y;
int z;
x=2;
y=3;
z=x+y;
and it will go without errors. However you won't get too see the result, and program will simply add the numbers, won't show them, and will end.

Also, check these lines of code - copy-paste them:
turn(rand()*360);

will turn to random direction (0 to 360 degrees).

move(rand()*100);

will move random between 0 and 100 metres

try to put this inside
while(true)
{

}

and guess the effectsSmile

PS:
The first program I've ever written was in colobot, in exercise with three spiders around 15 years ago. I wrote "Kill three spiders" in my native language. I was like "hell why not try this, if it works, programming will be a piece of cake and I won't have to learn a thing!". Guess what - It did not run. Sad

It's sad whenever i memorize it - on the other hand, today, thanks to this I'm an engineer of automatics and roboticsSmile

For Colobot: Gold Edition check out my TrueLevels level pack, UI Texture replacement pack and Sound Effect replacement pack.
Trailer for TrueLevels and my youtube channel here. Cheers!


Messages In This Thread
Bots, Everywhere - by RedRover - 10-09-2016, 08:33 PM
RE: Bots, Everywhere - by Simbax - 10-09-2016, 10:22 PM
RE: Bots, Everywhere - by True Destroyer - 10-10-2016, 01:27 AM
RE: Bots, Everywhere - by RedRover - 10-10-2016, 02:10 AM
RE: Bots, Everywhere - by tomaszkax86 - 10-10-2016, 12:14 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)