alternative 'action-editor'

  • #1, by petertermanhansenFriday, 07. December 2018, 20:15 A year 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

    40 Posts


  • #2, by afrlmeFriday, 07. December 2018, 21:13 A year 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

    6764 Posts

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

    Key Killer

    520 Posts

  • #4, by afrlmeSaturday, 08. December 2018, 11:52 A year 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
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12

    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")
    1

    Imperator

    6764 Posts

  • #5, by NigecSaturday, 08. December 2018, 12:53 A year 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

    520 Posts

  • #6, by afrlmeSaturday, 08. December 2018, 13:58 A year 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)
    1
    2

    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

    6764 Posts

  • #7, by sebastianSaturday, 08. December 2018, 17:28 A year 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)
    1
    2

    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

    2331 Posts

  • #8, by afrlmeSaturday, 08. December 2018, 18:07 A year 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

    6764 Posts

  • #9, by sebastianSaturday, 08. December 2018, 18:18 A year 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

    2331 Posts

Write post