Skip to content
Greg Tourville edited this page Mar 27, 2015 · 5 revisions

Welcome to the duck-lang wiki!

Some notes on the command reference.

Root

int(value)

Returns the integer value of a type.

float(value)

Returns the floating-point value of a type.

len(array)

Returns the length of an array or dictionary type.

Type(object)

Returns a string indicating the type of an object. Either "NIL", "INT", "FLOAT", "STRING", "REFERENCE", "FUNCTION", or "DICTIONARY".

quit()

Terminates the program.

time()

Returns the current time in seconds.

Duck

eval(source)

Evaluates a duck program as source code.

duck.parses(source)

Reports whether a snippet of code is valid duck source code.

duck.print(string)

Prints a string without a newline.

duck.println(string)

Prints a string with a newline.

duck.prompt([string])

Optionally prints a string and returns input from the command line.

duck.newline

A constant string for the newline character.

Math

math.sin(angle)

Returns the sine of an angle as a ratio of the opposite side to the hypotenuse of a right triangle.

math.cos(angle)

Returns the cosine of an angle as a ratio of the adjacent side to the hypotenuse of a right triangle.

math.tan(angle)

Returns the tangent of an angle as a ratio of the opposite side to the adjacent side of a right triangle.

math.asin(num)

Returns the function inverse of the sine of an angle as a value between [-Pi/2, Pi/2].

math.acos(num)

Returns the function inverse of the cosine of an angle as a value between [0, Pi].

math.atan(num)

Returns the function inverse of the tangent of an angle as a value between (-Pi/2, Pi/2).

math.pi

The mathematical constant Pi.

math.exp(num)

Returns the value of e^num where e is the base of the natural logarithm.

math.log(num)

Returns the natural logarithm of num.

math.log10(num)

Returns the base 10 logarithm of num.

math.pow(base, exponent)

Returns base^exponent or base raised to the exponent-th power.

math.sqrt(num)

Returns the square root of a number.

math.ceil(num)

Returns the value of a number rounded up to the nearest whole value.

math.floor(num)

Returns the value of a number rounded down to the nearest whole value.

math.abs(num)

Returns the absolute value of a number.

Random

rand.seed([value])

Initializes the random number generator with the seed value provided or the current system time.

rand.randint(a, b)

Generates a random number between [a, b] if a range is provided or a random integer if a range is not provided.

rand.randfloat(a, b)

Generates a random floating-point number between [a, b].

SDL

SDL.MakeWindow(width, height, title, [fullscreen])

Creates an SDL window of size width by height with the matching title. If fullscreen is specified, it will be created as a fullscreen window.

SDL.flip()

Flips the current framebuffer.

SDL.event()

Handles the SDL event queue.

SDL.clearScreen()

Clears the current screen.

SDL.running()

Returns true if the window has not been closed or escape has not been pressed.

SDL.waitkey()

Halts the program and waits for a keypress.

SDL.quit()

Quits the application.

OpenGL

SDL.glLoadIdentity()

Loads the identity matrix.

SDL.glTranslatef(x, y, z)

Translates the current matrix by [x, y, z].

SDL.glRotatef(deg, x, y, z)

Rotates the current matrix by an angle specified by degree along the [x, y, z] axis.

SDL.glScalef(x, y, z)

Scales the current matrix by each dimension x, y, z.

SDL.glBegin(primitive)

Begins displaying a mesh of type primitive. The only valid primitive type is SDL.GL_TRIANGLES.

SDL.glColor3f(r, g, b)

Specifies the rgb color of a triangle vertex.

SDL.glVertex3f(x, y, z)

Specifies the xyz coordinate of a triangle vertex.

SDL.glNormal3f(x, y, z)

Specifies the xyz normal of a triangle vertex.

SDL.glEnd()

Ends a mesh display list.