Android 台灣中文網
標題:
(觸摸精靈)如何模組化
[打印本頁]
作者:
ccw3230
時間:
2015-10-2 01:58
標題:
(觸摸精靈)如何模組化
本帖最後由 ccw3230 於 2015-10-2 10:07 編輯
當腳本內容愈來愈多時,模塊化各個功能可以讓腳本更加便於管理。
假設sample.lua存放於/mnt/sdcar/Touchelper/scripts/v2/下面(預設路徑),
內容如下:
function notify()
notifyMessage("i"m peter");
end
想要在main.lua中調用sample.lua中的函數notify(),那麼main.lua可以這樣寫:
package.path=package.path .. ";/mnt/sdcard/Touchelper/scripts/v2/?.lua"
require "sample"
function main()
notify();
end
歡迎光臨 Android 台灣中文網 (https://apk.tw/)
Powered by Discuz! X3.1