-
Notifications
You must be signed in to change notification settings - Fork 1
Scripting introduction
SDraw edited this page Jun 5, 2023
·
16 revisions
- Learn Lua
- Download
CVRLua_Editor.unitypackage
from latest release - Import into your world project
- Add
LuaScript
component to your GameObject(s)
LuaScript
has three lists:
- Variables list: Contains entries that will be executed as single line of Lua code as
<Variable Name> = <Variable Value>
. - VariableObjects list: Contains entries where object will be assigned to global variable with specified name.
- WARNING: Do not add objects of types that don't have implemented Lua bindings.
- Scripts list: This list contains
TextAsset
s that will be executed as Lua scripts in specified order uponLuaScript
component awakening. Scripts can contain Lua code in plain text or binary compiled through luac.
Example of filled LuaScript
component:
Let's create simple script:
function Start()
Log("Hello, "..localPlayer.name.."!")
end
Since Unity accepts specific file types to be reconginzed as TextAsset
, let's save our script as HelloWorld.lua.txt
anywhere in project. Now add it into scripts list of your LuaScript
component, upload your world and you're done.
Enjoy not yet fully completed but working scripting!