test: Use a better error message when code.lua doesn't exist (#1722)
This commit is contained in:
parent
fda7bf63af
commit
5ba35e42b1
2 changed files with 17 additions and 1 deletions
|
@ -1286,6 +1286,10 @@
|
|||
[entry]
|
||||
name = "Luiz Fernando de Faria Pereira (lfernando)"
|
||||
[/entry]
|
||||
[entry]
|
||||
name = "Luther Thompson"
|
||||
email = "lutheroto_AT_gmail.com"
|
||||
[/entry]
|
||||
[entry]
|
||||
name = "lv-zheng"
|
||||
[/entry]
|
||||
|
|
|
@ -1397,7 +1397,19 @@ My best advancement costs $next_cost gold and I’m $experience|% there."
|
|||
# The file is not in the repository to allow adding custom stuff to it.
|
||||
[command]
|
||||
[lua]
|
||||
code=<< wesnoth.dofile("lua/code.lua").main() >>
|
||||
code=<<
|
||||
local codeFile = "lua/code.lua"
|
||||
if wesnoth.have_file(codeFile) then
|
||||
local code = wesnoth.dofile(codeFile)
|
||||
if type(code) == "table" and type(code.main) == "function" then
|
||||
code.main()
|
||||
else
|
||||
wesnoth.message(codeFile.." must return a table with a 'main' function.")
|
||||
end
|
||||
else
|
||||
wesnoth.message("To use this command, create a file 'data/lua/code.lua' in the wesnoth source directory that returns a table with a 'main' function.")
|
||||
end
|
||||
>>
|
||||
[/lua]
|
||||
[/command]
|
||||
[/set_menu_item]
|
||||
|
|
Loading…
Add table
Reference in a new issue