Difference between revisions of "How to Load External Scripts Into Visionaire Studio (CMS)"
From The Official Visionaire Studio: Adventure Game Engine Wiki
m (Tag: Visual edit) |
|||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
− | This script was written by '''Divo''' & allows you to load (include) external scripts & functions into Visionaire Studio. This script is really useful as it allows you to write scripts on the fly inside of a text editor of your choice & instantly check the results of your script without having to copy/paste the script you are working on into Visionaire Studio | + | This script was written by '''Divo''' & allows you to load (include) external scripts & functions into Visionaire Studio. This script is really useful as it allows you to write scripts on the fly inside of a text editor of your choice & instantly check the results of your script without having to copy/paste the script you are working on into the Visionaire Studio script editor. Nor do you have to save the project each time you make a slight edit to the script. |
I would recommend copy/pasting your final script into Visionaire Studio & removing this script, once you are finished. | I would recommend copy/pasting your final script into Visionaire Studio & removing this script, once you are finished. | ||
Line 5: | Line 5: | ||
'''Script type: Definition''' | '''Script type: Definition''' | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang="lua"> |
-- * load an external script file if the file exists! * -- | -- * load an external script file if the file exists! * -- | ||
function loadScripts() | function loadScripts() |
Latest revision as of 15:23, 19 October 2021
This script was written by Divo & allows you to load (include) external scripts & functions into Visionaire Studio. This script is really useful as it allows you to write scripts on the fly inside of a text editor of your choice & instantly check the results of your script without having to copy/paste the script you are working on into the Visionaire Studio script editor. Nor do you have to save the project each time you make a slight edit to the script.
I would recommend copy/pasting your final script into Visionaire Studio & removing this script, once you are finished.
Script type: Definition
-- * load an external script file if the file exists! * --
function loadScripts()
local f, cerror
--[[ replace folder_name & script_name with whatever you called your folders & script!
folder_name should be created inside of the project/game root folder! --]]
f, cerror = loadfile('./folder_name/script_name.lua')
if f == nil then -- checks if file exists!
print('cerror: ' .. cerror) -- prints error reason to the log file!
else
print('External script(s) have been successfully loaded!')
f()
end
end