Jump to content

BSL:Snippets: Difference between revisions

adding lede, multiplication hack
(moving in from main BSL page; made some comment corrections and tweaks)
 
(adding lede, multiplication hack)
 
Line 1: Line 1:
===Character setup===
Various useful snippets of BSL that can be useful for modders.
 
==Character setup==
  # an old but useful character setup function by geyser
  # an old but useful character setup function by geyser
  func '''SpawnNameFlagHealthReset'''(string n, int f, int h, int r)
  func '''SpawnNameFlagHealthReset'''(string n, int f, int h, int r)
Line 18: Line 20:
  }
  }


===Follow me===
==Follow me==
  var bool follow_me = 1;
  var bool follow_me = 1;
   
   
Line 85: Line 87:
     sleep 60
     sleep 60
     fork dont_follow_me
     fork dont_follow_me
}
==Multiplication hack==
var int multiplicand;
var int multiplier;
var int mult_progress;
var int product;
func void '''multiply'''(int a, int b)
{
    product = 0;
    multiplicand = a;
    multiplier = b;
    mult_progress = 0;
    fork do_mult();
}
func void do_mult(void)
{
    product = product + multiplicand;
    mult_progress = mult_progress + 1;
    if (mult_progress < multiplier)
    {
      sleep(1);
      fork do_mult();
    }
  }
  }


[[Category:Modding tutorials]]
[[Category:Modding tutorials]]