What's New in LUA Modding: Difference between revisions

From SkyCorp Global
Jump to navigation Jump to search
No edit summary
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
This page documents the changes modders should be aware of in LUA modding in the new engine versus the old Flash/AS3 based engine:
== Inputting LUA ==
== Inputting LUA ==
You no longer need to manually compile LUA into bytecode and then base64 it!  Now you simply escape the lua source code and drop it in.
You no longer need to manually compile LUA into bytecode and then base64 it!  Now you simply [https://www.freeformatter.com/json-escape.html escape] the lua source code and drop it in.


Note the field changed from 'luac' (compiled lua) to just 'lua'
Note the field changed from 'luac' (compiled lua) to just 'lua'


=== Example ===
=== Example ===
Previously in AS3:
Previously mod json in AS3:


xxx
<syntaxhighlight lang="json" highlight="11">
{
"type": "ENTITY",
"name":
{
"literalString" : "Shinier Gem"
},
"description":
{
"programString": true
},
"luac": "G0x1YVEAAQQEBAgAEAAAAEBzaGluaWVyR2VtLmx1YQAAAAAAAAAAAAAAAgIDAAAAJAAAAAcAAAAeAIAAAQAAAAQMAAAAZGVzY3JpcHRpb24AAQAAAAAAAAAFAAAADQAAAAAAAAIDAAAAAQAAAB4AAAEeAIAAAQAAAAQyAAAAVGhlIGdlbSBzaGluZXMgcHJvZ3JhbWF0aWNhbGx5IGFzIHlvdSBsb29rIGF0IGl0LgAAAAAAAwAAAAgAAAALAAAADQAAAAEAAAAQAAAAZGVzY3JpcHRpdmVUZXh0AAEAAAACAAAAAAAAAAMAAAANAAAABQAAAA0AAAAAAAAAAAAAAA=="
}
</syntaxhighlight>


And now:
And now mod json in new engine:


yyy
<syntaxhighlight lang="json" highlight="11">
{
"type": "ENTITY",
"name":
{
"literalString" : "Shinier Gem"
},
"description":
{
"programString": true
},
"lua": "-- Description is called when an object's description is shown to the\r\n-- player or otherwise requested.  The object should return a string\r\n-- containing the description.\r\n\r\nfunction description()\r\n\r\n  -- Create a descriptive string\r\n  local descriptiveText = \"The gem shines programatically as you look at it.\";\r\n\r\n  -- Return it\r\n  return descriptiveText;\r\n\r\nend"
}
</syntaxhighlight>Because of this change, I've disabled the lua field in the mod upload/edit page to avoid needless duplication. 


== Access to more utility functions/classes ==
== Access to more utility functions/classes ==
A number of new classes are available, check out the [[:Category:LUA Class Reference|API reference]].
== Optional parameters ==
A few functions have since been updated to support optional parameters, like silent TFs.

Latest revision as of 05:14, 18 July 2023

This page documents the changes modders should be aware of in LUA modding in the new engine versus the old Flash/AS3 based engine:

Inputting LUA

You no longer need to manually compile LUA into bytecode and then base64 it! Now you simply escape the lua source code and drop it in.

Note the field changed from 'luac' (compiled lua) to just 'lua'

Example

Previously mod json in AS3:

{
	"type": "ENTITY",
	"name":
	{
		"literalString" : "Shinier Gem"
	},
	"description":
	{
		"programString": true
	},
	"luac": "G0x1YVEAAQQEBAgAEAAAAEBzaGluaWVyR2VtLmx1YQAAAAAAAAAAAAAAAgIDAAAAJAAAAAcAAAAeAIAAAQAAAAQMAAAAZGVzY3JpcHRpb24AAQAAAAAAAAAFAAAADQAAAAAAAAIDAAAAAQAAAB4AAAEeAIAAAQAAAAQyAAAAVGhlIGdlbSBzaGluZXMgcHJvZ3JhbWF0aWNhbGx5IGFzIHlvdSBsb29rIGF0IGl0LgAAAAAAAwAAAAgAAAALAAAADQAAAAEAAAAQAAAAZGVzY3JpcHRpdmVUZXh0AAEAAAACAAAAAAAAAAMAAAANAAAABQAAAA0AAAAAAAAAAAAAAA=="
}

And now mod json in new engine:

{
	"type": "ENTITY",
	"name":
	{
		"literalString" : "Shinier Gem"
	},
	"description":
	{
		"programString": true
	},
	"lua": "-- Description is called when an object's description is shown to the\r\n-- player or otherwise requested.  The object should return a string\r\n-- containing the description.\r\n\r\nfunction description()\r\n\r\n   -- Create a descriptive string\r\n   local descriptiveText = \"The gem shines programatically as you look at it.\";\r\n\r\n   -- Return it\r\n   return descriptiveText;\r\n\r\nend"
}

Because of this change, I've disabled the lua field in the mod upload/edit page to avoid needless duplication.

Access to more utility functions/classes

A number of new classes are available, check out the API reference.

Optional parameters

A few functions have since been updated to support optional parameters, like silent TFs.