-
Notifications
You must be signed in to change notification settings - Fork 293
Programming with Lua
Nicholas Wang edited this page Jul 4, 2016
·
6 revisions
node.restart()
file.open("yourFile.lua","w+") -- if the file is not exist, create one
file.write("Input your content here")
--file.writeline("Your content here") -- write a line
file.close()
file.open("yourFile.lua","r")
file.read() -- Use file.read(n) to read the first n characters of the file
--file.readline() -- read a line
file.close()
file.open("yourFile.lua","a")
file.write("Your content here")
file.close()
file.remove("yourFile.lua")
encodeString = cjson.encode({key1=value1, key2=value2})
print(encodeString) -- {'key1':'value1', 'key2':'value2'}
decodeResult = cjson.decode(encodeString)
The utils
module contains some useful tools, such as base64, date tool, etc. More useful tools will be added to this module, then user can invoke them from this module.
str = "hello world";
encrypt = utils.base64_encode(str);
decrypt = utils.base64_decode(encrypt);
The template module is a sample to show users how to create their own module. Invoke the start
and stop
method to test.
template.start()
template.stop()