Difference between revisions of "How to Load External Scripts Into Visionaire Studio (CMS)"

From The Official Visionaire Studio: Adventure Game Engine Wiki
(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...")
 
(2 intermediate revisions 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. 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.
+
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.
  
Script type: Definition.
+
I would recommend copy/pasting your final script into Visionaire Studio & removing this script, once you are finished.
 +
 
 +
'''Script type: Definition'''
  
 
<syntaxhighlight>
 
<syntaxhighlight>

Revision as of 18:50, 8 February 2014

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