Browse Source

Fixed lua_script and lua_utils pages

master
Christopher 8 years ago
parent
commit
5da0f884f6
  1. 9
      Docs/fungus_lua/lua_script.md
  2. 17
      Docs/fungus_lua/lua_utils.md

9
Docs/fungus_lua/lua_script.md

@ -2,7 +2,7 @@
The LuaScript component provides an easy way to run Lua scripts in your scene. You can create a LuaScript object via (Tools > Fungus > Create > LuaScript).
![LuaScript](images/lua_script.png)
![LuaScript](fungus_lua/lua_script.png)
# ExecuteHandler component
@ -18,7 +18,7 @@ You can also use both options at the same time. In this case, the Lua File conte
# Lua modules and require()
The Lua module system allows you to create reusable packages of Lua code and include these in your Lua scripts. [This tutorial](http://www.tutorialspoint.com/lua/lua_modules.htm) explains how to write Lua modules. Module files in FungusLua need to be put into a special folder structure so that the Lua require() function is able to locate them.
The Lua module system allows you to create reusable packages of Lua code and include these in your Lua scripts. [This tutorial] explains how to write Lua modules. Module files in FungusLua need to be put into a special folder structure so that the Lua require() function is able to locate them.
To use a Lua module:
@ -68,7 +68,7 @@ To resolve this type of error, carefully check that the variable you want to acc
For runtime errors, a useful technique is to add print() calls in your code just before where the error occurs, and run it again. This way you can print out information to the console to help track down the cause of the error.
MoonSharp includes a remote debugger tool which you can use to step through Lua code and inspect variables. See the [LuaEnvironment documentation](lua_environment.md) for more information.
MoonSharp includes a remote debugger tool which you can use to step through Lua code and inspect variables. See the @ref lua_environment for more information.
# Setting the LuaEnvironment
@ -77,3 +77,6 @@ By default the LuaScript component will use the first LuaEnvironment it finds in
# RunAsCoroutine option
This option will run the Lua script as a Lua coroutine which is useful for writing asynchronous code via the coroutine.yield() function in Lua. If you don't need to execute your Lua script asynchronously, deselecting this option will avoid the overhead of running as a coroutine. Recommended for advanced users only!
[This tutorial]: http://www.tutorialspoint.com/lua/lua_modules.htm

17
Docs/fungus_lua/lua_utils.md

@ -45,7 +45,7 @@ The most important function of the LuaUtils component is registering C# types so
In order to access the members of a C# type from Lua, the type first has to be registered with MoonSharp. Note that for objects added using the LuaBindings component, the relevant types are registered automatically.
In some cases however, you will need to register a type explicitly. The easiest way to do this is by adding the type's name to the FungusTypes.txt or UnityTypes.txt JSON files referenced by the LuaUtils component. You can also create your own JSON files to register additional types. Note that types that are not contained in the main application DLL will need to use the [namespace qualified type name](https://msdn.microsoft.com/en-us/library/system.type.assemblyqualifiedname(v=vs.110).aspx) in the JSON file.
In some cases however, you will need to register a type explicitly. The easiest way to do this is by adding the type's name to the FungusTypes.txt or UnityTypes.txt JSON files referenced by the LuaUtils component. You can also create your own JSON files to register additional types. Note that types that are not contained in the main application DLL will need to use the [namespace qualified type name] in the JSON file.
# Example JSON Type File
@ -71,14 +71,14 @@ LuaUtils creates bindings for several useful C# classes and components so that y
| Binding name | Description |
| ----------------- | ----------- |
| time | The [Unity Time class](http://docs.unity3d.com/ScriptReference/Time.html). e.g. 'time.deltaTime' returns the delta time for this frame |
| playerprefs | The [Unity PlayerPrefs](preferences.md#playerprefs) class. Used for saving data to disk. |
| prefs | The [FungusPrefs class](preferences.md#fungusprefs), our own wrapper around PlayerPrefs that adds a slots systems. |
| factory | The [PODTypeFactory](lua_utils.md#podfactory) class for creating common plain-old-data types |
| time | The [Unity Time class]. e.g. 'time.deltaTime' returns the delta time for this frame |
| playerprefs | The @ref lua_preferences "Lua Preferences" class. Used for saving data to disk. |
| prefs | The @ref lua_preferences "Fungus Prefs" class, our own wrapper around PlayerPrefs that adds a slots systems. |
| factory | The @ref lua_utils "PODTypeFactory" class for creating common plain-old-data types |
| luaenvironment | The LuaEnvironment component used to execute Lua scripts |
| luautils | A reference to the LuaUtils component itself |
| test | Support for [Unity Test Tools](unity_test_tools.md) (if installed) |
| stringtable | The FungusLua localisation [string table](string_table.md) |
| test | Support for @ref unity_test_tools (if installed) |
| stringtable | The FungusLua localisation @ref string_table |
# PODFactory
@ -105,3 +105,6 @@ local q = luautils.factory.quaternion(float x, float y, float z) -- Rotation in
-- Returns a new Rect object
local r = luautils.factory.rect(float x, float y, float width, float height)
```
[namespace qualified type name]: https://msdn.microsoft.com/en-us/library/system.type.assemblyqualifiedname(v=vs.110).aspx
[Unity Time class]: http://docs.unity3d.com/ScriptReference/Time.html
Loading…
Cancel
Save