Post by hedge on Mar 1, 2021 15:22:53 GMT
I want to split my code in multiple files using require to combine them.
Both code files below are compiled with
Everytime I start the compiled test.luac file I get the following error:
What am I doing wrong?
main.lua
util.lua
Both code files below are compiled with
luac -s -o bin/test.luac ./main.lua ./util.lua
Everytime I start the compiled test.luac file I get the following error:
What am I doing wrong?
main.lua
local util = require("util")
function otherdialog()
removePreference("cbValue")
dialogInit()
addCheckBox("cbValue", "Check Box", false)
newRow()
spinnerItems = {"item 1", "item 2", "item 3", "item 4", "item 5", "item 6", "item 7"}
addTextView("Spinner: ")
addSpinner("spValue", spinnerItems, "item 3")
newRow()
spinnerItems = {"Indexitem 1", "Indexitem 2", "Indexitem 3", "Indexitem 4", "Indexitem 5", "Indexitem 6", "Indexitem 7"}
addTextView("Spinner Index: ")
addSpinnerIndex("spValueIndex", spinnerItems, "Indexitem 3")
newRow()
addTextView("Text End")
dialogShow("Dialog Test")
print(etValue)
if (cbValue) then
print ("CheckBox true")
else
print("CheckBox false")
end
print ("spValue = " .. spValue)
print ("spValueIndex = " .. spValueIndex)
end
function main()
util.showDialog()
otherdialog()
end
main()
util.lua
local util = {}
function util.showDialog()
removePreference("cbValue")
dialogInit()
addTextView("TextViewMessage")
addEditText("etValue", "Input EditText value:")
newRow()
addCheckBox("cbValue", "Check Box", false)
addRadioGroup("rgIndex", 1)
addRadioButton("Button 1", 1)
addRadioButton("Button 10", 10)
addRadioButton("Button 11", 11)
newRow()
addTextView("Text End")
dialogShow("Dialog Test")
print(etValue)
if (cbValue) then
print ("CheckBox true")
else
print("CheckBox false")
end
toast ("Selected Button = "..rgIndex)
print ("Selected Button = "..rgIndex)
end
return util