Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Public files, factory and code battle
#3
A public function is a function declared with keyword "public". It has to be loaded into one bot so other bots can use it. You probably saved a program as public, but this is different. This makes program available to all player profiles in Colobot, but this program is not loaded by default in any bot, which is why you can't use functions defined inside. An example of public function defined inside empty program:

Code:
extern void object::RechargeLib()
{
   
}

public void object::Recharge()
{
   object o = radar(PowerStation);
   goto(o.position);
   while(energyCell.energyLevel < 1)
   {
       wait(0.1);
   }
}

You can define as many public functions as you want in one program source, thus creating a kind of library. After you load the program inside any bot, you can use those functions in other programs.

factory() lets you use one of three ways of specifying program to run:
1. Name of a public function to run
2. Name of a file containing source code of the program to run
3. Complete source code of the program to run

You can check in-game CBot manual or online manual for more information.
"After three days without programming, life becomes meaningless."
~The Tao of Programming


Messages In This Thread
Public files, factory and code battle - by nknk - 12-22-2016, 01:34 PM
RE: Public files, factory and code battle - by tomaszkax86 - 12-22-2016, 02:52 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)