How does mafia handle void xxxx()

holatuwol

Developer
I have no idea what you're asking?

Every function needs a return type. Void is one such return type. Like all return types, it may be used for any function. There's nothing that can store a void value, though.

If the above statements don't answer the question you were trying to ask, can you clarify your question?
 
void main() is the main function within a script. It is not required.

void xxx() would be a function you are creating. In a way it's like a goto statement.

why would you want to create a function? Well maybe you have a group of commands which you will execute multiple times an example:

Code:
if(item_amount($item[knob sausage]) > 1)
  {
  eat(1, $item[knob sausage]);
  }
if(item_amount($item[bat wing]) > 1)
  {
  eat(1, $item[bat wing]);
  }

could be simplified to:
Code:
void try_to_eat(int quant, item it)
  {
  if(item_amount(it) > quant)
    {
    eat(quant, it);
    }
  }

try_to_eat(1, $item[knob sausage]);
try_to_eat(1, $item[bat wing]);

Now the usefulness isn't really obvious there, but consider if you were going to try 50 different items. the code is much easier to write this way.

Void is a return type of nothing. You cannot assign a value to void. you can also have a return type.

Code:
int increase(int number, int increaseby)
  {
  return number + increaseby;
  }

int a;
a = increase(1, 2);

Ok so that is a useless function since you could do the same without calling it, but it does show how to have a return type.
 
efilnikufecin said exactly what I wanted to know.

Thank you very much.

I know it wasn't a clear question but I had no idea what a "void" was...

I've seen it in many scripts but never used them.
 
Top