Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trivia about everything related to Colobot
Short description:
There's a mysterious try...catch block statement in CBot that allows you to interrupt normally non-interruptible instructions, like move() and goto().

Long description:
The statement looks similar to try...catch blocks found in many high-level programming languages like C++ and Java. However, in catch() you can put a condition that will be checked every in-game tick. If this condition becomes true, code in try block will be interrupted and control will be returned to the catch block. This allows you to interrupt your program if something extraordinary happens. For example, you can check if an ant is nearby and return back to base to escape the danger.

   object item = radar(TitaniumOre);
   // take ore to converter
catch(radar(AlienAnt, 0, 360, 0, 40) != null)
   message("Ant is attacking me! Returning to base.");
   object item = radar(SpaceShip);

There is no information about it in CBot manual. It was found in one of the documents EPSITEC gave us together with source code of Colobot.
"After three days without programming, life becomes meaningless."
~The Tao of Programming

Messages In This Thread
RE: Trivia about everything related to Colobot - by tomaszkax86 - 01-20-2015, 11:03 PM

Forum Jump:

Users browsing this thread: 1 Guest(s)