How to Load External Scripts Into Visionaire Studio (CMS)

From The Official Visionaire Studio: Adventure Game Engine Wiki
Revision as of 18:38, 8 February 2014 by AFRLme (talk) (Created page with "This script was written by '''Divo''' & allows you to load (include) external scripts & functions into Visionaire Studio. I only recommend using this script to save time, whil...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This script was written by Divo & allows you to load (include) external scripts & functions into Visionaire Studio. I only recommend using this script to save time, while writing your script(s), if you are planning on writing your scripts in a third party text editor instead of the script/text editor that comes with the Visionaire Studio editor. You should copy/paste the final script into Visionaire Studio once you have finished working on it & then remove this script.

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