Guides#
This section contains a collection of short guides and tutorials for IOLITE. All guides assume the default data source is available, and that you have loaded the default basic
world.
Writing your first Hello World script in Lua#
This short tutorial serves as a step-by-step guide to writing your first Lua script in IOLITE.
Important
This guide requires the latest version of the Lua plugin for IOLITE to be installed. Please check the section Working with plugins for more details.
Open up your favorite code editor and create a new file. Copy and paste the following Lua script, which logs two strings to the console:
Log.load()
-- Logs each time the script gets (re-)loaded
Log.log_info("Hello world! Script loaded!")
function OnActivate(entity)
-- Logs once the component becomes active
Log.log_info("Hello world! Component active!")
end
After that, continue with the following steps:
Store the script in
default/media/scripts/
and name ithello_world.lua
Open up IOLITE, ensure that the editor is active, and head over to the World Inspector
Create a new entity with a script component attached to it
In the property inspector, set the
Script
property tohello_world
(without the extension)Switch to the game mode by clicking
[Game Mode]
in the menu barPress
[F2]
to open up the console and check if the strings have been logged successfully
Keep IOLITE open and modify the strings passed to the log functions. Every time you save the script, it triggers a hot reload. Notice how the global log call gets executed while the call in OnActivate
is not. This call can be, e.g., triggered by switching back and forth between the game mode and the editor; the editor can be activated using [F3]
.
Importing a flipbook animation from MagicaVoxel#
In this short tutorial, we will load a flipbook animation authored in MagicaVoxel.
Create a flipbook animation in MagicaVoxel and add the VOX file to a data source, like, e.g.,
default/media/voxels
. For testing purposes, you can also use one of the animated voxel assets that are shipped with MagicaVoxel, like the dinosaur or the deerCreate a voxel shape for your asset by dragging it from the Prefab Browser to the viewport
Attach a Flipbook Animation component to the entity you just created
Head to the entity inspector and set the
First Frame
andLast Frame
properties to values matching your animationSet the
Speed
property to a fitting value. 20 frames per second can be a good starting pointEnable the
Loop
andPlay
flags
If everything works out, your animation should be playing.