This repository was archived by the owner on May 29, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Scripting introduction
SDraw edited this page May 25, 2023
·
16 revisions
- Download
CVRLua_Editor.unitypackage
(from repository root or latest release) - Import into your world project
- Add
LuaScript
component to your GameObject(s)
LuaScript
has some lists:
- Scripts list: This list contains
TextAsset
s that will be executed as Lua scripts uponLuaScript
component awakening. Remember that all attachedTextAsset
scripts are executed in same Lua state, meaning that last executed script can override variables of sciprts executed before it. - Variable names and game objects list: Those lists define game objects that will be assigned as global variables in current Lua state.
Better editor GUI for LuaScript
component will be added soon.
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!
- All Unity's enumetators are treated as strings inside Lua state.
- All unknow properties of binded classes return
nil
. - All failed methods calls of binded classes return
false
and logged into MelonLoader console. - All static properties are accesses as
<ClassName>.<propertyName>
- All static methods are accesses as
<ClassName>.<MethodName>(...)
- All instance properties are accesses as
<ClassObject>.<propertyName>
- All instance methods are accesses as
<ClassObject>:<MethodName>(...)
- Class constructors (if present) are accessed as
<ClassName>(...)