alternative 'action-editor'

  • #1, by petertermanhansenFriday, 07. December 2018, 20:15 6 years ago
    Hi

    I wonder - is it possible to use an 'alternative action editor' ?
    I know I could use Lua-scripting to get at more clear descission-flow. 
    But if I could use a text-editor of my own choice, I think I could have a better overwiev.

    Regards
    Peter

    Newbie

    82 Posts


  • #2, by afrlmeFriday, 07. December 2018, 21:13 6 years ago
    I use sublime text 3 to write my large scripts. If I'm just writing a small bit of code for an execute a script action part then I'll probably just write it inside of Visionaire instead.

    There's nothing much different really in VS5 now compared to Sublime Text or Atom - minus a few features here & there. VS now has color syntax, some kind of auto-complete (not exactly auto-complete, but it displays tooltips while you are typing), & a basic debugging system.

    Imperator

    7285 Posts

  • #3, by NigecSaturday, 08. December 2018, 08:58 6 years ago
    I use VSCode, very consistant across all platforms
    you might find this interesting:

    Key Killer

    640 Posts

  • #4, by afrlmeSaturday, 08. December 2018, 11:52 6 years ago
    I use VSCode, very consistant across all platforms
    you might find this interesting:

    I actually just rewrote that script slightly.

    -- * load an external script file if the file exists! * --
    
    function loadScript(n)
    
       local f, cerror
    
       f, cerror = loadfile("./data/lua/" .. n)
    
       -- + --
    
       if f == nil then -- checks if file exists!
    
          print("cerror: " .. cerror) -- prints error reason to the log file!
    
      else
    
          print(n, "has been successfully loaded.")
    
       f()
    
       end
    
    end 

    the path part will probably need editing though as that's the folder structure I use.
    project root > data > sub-folders.

    I just edited the function so that you can pass a script name into the function when you call it.

    To use it you would call a script inside of an execute a script action or inside of another script somewhere with...

    loadScript("file_name.lua")

    Imperator

    7285 Posts

  • #5, by NigecSaturday, 08. December 2018, 12:53 6 years ago
    I kind of do the same but I call the folder graphics, then sub folders, data makes more sense, I was thinking "only I see it!" but I often share so maybe its time for change wink

    the script makes more sense smile

    Key Killer

    640 Posts

  • #6, by afrlmeSaturday, 08. December 2018, 13:58 6 years ago
    I don't understand how it works exactly - well I understand the loading part of the script, but I don't understand the cerror bit works, but it does seem to work.

    Normally when you declare variables, you have to manually add the data to each one...
    local test1, test2 = "some data", "some data"
    
    print(test1, test2)

    otherwise the other variables will return nil, but for some reason cerror returns information if you link to an incorrect file/path.

    cerror: cannot open ./data/lua/bleh.lua: No such file or directory

    Imperator

    7285 Posts

  • #7, by sebastianSaturday, 08. December 2018, 17:28 6 years ago
    I don't understand how it works exactly - well I understand the loading part of the script, but I don't understand the cerror bit works, but it does seem to work.

    Normally when you declare variables, you have to manually add the data to each one...
    local test1, test2 = "some data", "some data"
    
    print(test1, test2)

    otherwise the other variables will return nil, but for some reason cerror returns information if you link to an incorrect file/path.

    cerror: cannot open ./data/lua/bleh.lua: No such file or directory

    its because you previously set it to "loadfile()"..:
       f, cerror = loadfile("./data/lua/" .. n)
    This function returns two parameters. The needed data and/or a message regarding fail

    Thread Captain

    2346 Posts

  • #8, by afrlmeSaturday, 08. December 2018, 18:07 6 years ago
    I think technically it's only setting f as loadFile("path")


    ah wait, I think I understand how it works. cerror is nil unless the loadfile function returns an error, because that returning an error would get inserted into the cerror variable.

    Imperator

    7285 Posts

  • #9, by sebastianSaturday, 08. December 2018, 18:18 6 years ago
    f is the returned data (if success) as a function but will not get executed.
    regarding the cerror variable in the script:
    "In case of errors, loadfile returns nil plus the error message, which allows us to handle the error in customized ways. "
    https://www.lua.org/pil/8.html
    "If there is an error in the loading process, for example the file is not found, or it is found but has a syntax error, then f will be nil and err will be the nature of the error."
    https://www.gammon.com.au/scripts/doc.php?lua=loadfile

    wink

    Thread Captain

    2346 Posts