Other global

Additional global functions.

Functions

keyprint (str, key) Print text only to debug only if key is being held down.
chars (text) Iterator for characters in a string.
split (text, delim) Iterator for splitting a string using a specified delimiter.
words (text) Iterator for splitting a line of text into words.
getInput () Get the global input controller.
delay (id, interval[, override]) Triggers only once every given interval


Functions

keyprint (str, key)
Print text only to debug only if key is being held down. Useful for debugging parts of code that run every frame without drowning the console window.

Parameters:

  • str string the string to print
  • key string the key to press
chars (text)
Iterator for characters in a string. Credits to Ranguna259.

Parameters:

  • text string the string to split

Returns:

  1. number index
  2. string character

Usage:

     for k, c in chars('hello') do
     	print(k..': '..p)
     end -- prints "1: h", "2: e", "3: l", "4: l", "5: 0" respectively.
split (text, delim)
Iterator for splitting a string using a specified delimiter.

Parameters:

Returns:

  1. number index
  2. string part of string

Usage:

     for k, s in split('january-30-2015', '-') do
     	print(s)
     end -- prints "january", then "30", then "2015"
words (text)
Iterator for splitting a line of text into words. Same as using split with a space as delimiter.

Parameters:

  • text string the string to split

Returns:

  1. number index
  2. string a word in the string

Usage:

     for k, w in words('I love cats') do
     	print(w)
     end -- prints "I", then "love", then "cats"
getInput ()
Get the global input controller.

Returns:

    InputController global input controller

See also:

delay (id, interval[, override])
Triggers only once every given interval

Parameters:

  • id string delay trigger id
  • interval number delay in seconds
  • override bool whether to force triggering this delay (optional)

Returns:

    bool trigger state

Usage:

     if (input:mouseIsDown("l") and delay("fire", 0.4)) then
       fireBullet() -- fire every 0.4 seconds when holding down left mouse
     end
generated by LDoc 1.4.3 Last updated 2015-04-20 03:01:38