Skip to content

Instantly share code, notes, and snippets.

@beakr
Last active December 31, 2015 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beakr/8041241 to your computer and use it in GitHub Desktop.
Save beakr/8041241 to your computer and use it in GitHub Desktop.
How Dendrite scripting should work.

Dendrite Lua Scripting: How it should work.

This is a simple page meant to be used for documentation-driven design in my Dendrite game engine. This is where I write some simple documentation and use it as a reference for implementing the code.

Linking

To link a script, select an entity in the game editor and click the 'link' dropdown button. Then click the menu item 'lua script'.

If you need to link a script to your scene, simply go to Game > World Settings or use command-shift-W (Mac) cntrl-shift-W (Windows/Linux) to attach a script to the current world.

Anatomy of a Script

Here is a simple Lua file explaining how a script is created:

-- This is our script's start function, it is called when the script is loaded.
function script:start()
  Console.log("Script loaded!")
end

-- This is our update function, this is a function called once per frame in the game.
function script:update()
  if input.key_pressed("x") then
    World.get("Player").rotation += 0.1
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment