Josh Posted March 16, 2018 Share Posted March 16, 2018 I am considering an extendable Virtual Machine in Leadwerks 5 with official support for one language and the ability to add your own (Python, etc.) The two contenders are Lua and Squirrel. The features we need are the following: Autocompletion with knowledge of Leadwerks API and Leadwerks C++ types. Debugging. Exposing C++ classes to script with support for smart pointers. We may use an external IDE this time, or we may use our own built-in one. Visual Studio Code might be a good option, and it is available for all platforms. We need to dig into the details of this stuff and see how we can accomplish what we want. Any input you have on this is appreciated. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted March 16, 2018 Author Share Posted March 16, 2018 Another thing to consider is we have an amazing shader editor and no external IDE will be able to match it. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Rick Posted March 16, 2018 Share Posted March 16, 2018 I would think the majority of the time spent is coding gameplay with Lua vs shader coding. Wouldn't want to gimp the majority one for the minority one. At first glance a virtual machine of your own starts going down rabbit holes that seems dangerous. On the other hand if you supported languages like Python, C#, etc I bet sales would increase. Coders are picky about their language and like what they like. If they have the option to use their language as officially supported vs community supported people would like that. I don't personally like Python (white space as meaning? f that) but it's the fastest growing language currently so a lot of people know it and like it. Squirrel is interesting. I've never used it but most anything that has the class keyword I like and feel comfortable with. Quote Link to comment Share on other sites More sharing options...
Josh Posted March 16, 2018 Author Share Posted March 16, 2018 I will only support one script language. I don't mind leaving the door open for other languages, if I can do it without hurting the official supported one. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted March 16, 2018 Author Share Posted March 16, 2018 This is interesting. Maybe it could be modified for us: https://atom.io/packages/language-gmod-lua Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted March 16, 2018 Author Share Posted March 16, 2018 You can add this into your Lua.json file and it sort of give you autocompletion: { "Entity:SetPosition": { "prefix": "SetPosition", "body": ["SetPosition($x,$y,$z,$global)"], "description": "Entity\nSets an entity's position in 3D space" }, "Entity:SetRotation": { "prefix": "SetRotation", "body": ["SetRotation($pitch,$yaw,$roll,$global)"], "description": "Entity\nSets an entity's rotation in 3D space" }, "Window:Create": { "prefix": "Window:Create", "body": [ "Window:Create($title,$x,$y,$width,$height,$style)"], "description": "Window\nCreates a new Window object" }, "Window.Titlebar": { "prefix": "Window.Titlebar", "body": ["Window.Titlebar"] } } Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted March 16, 2018 Author Share Posted March 16, 2018 At this time I am leaning towards this solution: Lua Custom binding code implemented for smart pointers. No built-in IDE VS Code as official script IDE. A single Leadwerks tools plugin for VS Code that installs everything you need. New debugger that runs in VS Code, based on our existing Lua debugging system. Shader files separated into vert, frag, geom, etc. files. New VS Code plugin that validates and links shaders for testing. Autocomplete based on snippets, as shown above. 2 1 2 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
AggrorJorn Posted March 16, 2018 Share Posted March 16, 2018 I will post my extension for vs code this evening. Quote Link to comment Share on other sites More sharing options...
Josh Posted March 16, 2018 Author Share Posted March 16, 2018 2 hours ago, AggrorJorn said: I will post my extension for vs code this evening. What does it do? Here is some improved Lua autocomplete. It would be totally possible to auto-generate the entire API by pulling the data from the XML files the docs are stored in: { "Window:Create": { "prefix": "Window:Create", "body": "Window:Create($title,$x,$y,$width,$height,$style)", "description": "Window Function\nCreates a new Window object" }, "Window.Titlebar": { "prefix": "Window.Titlebar", "body": "Window.Titlebar", "description": "Constant" }, "Entity:SetPosition": { "prefix": "SetPosition", "body": "SetPosition($x,$y,$z,$global)", "description": "Entity Method\nSets the position of an entity in 3-dimensional space, using local or global coordinates." }, "Entity:SetPosition (2)": { "prefix": "SetPosition", "body": "SetPosition($position,$global)", "description": "Entity Method\nSets the position of an entity in 3-dimensional space, using local or global coordinates." }, "Entity:SetRotation": { "prefix": "SetRotation", "body": "SetRotation($pitch,$yaw,$roll,$global)", "description": "Entity Method\nSets the rotation of an entity in 3-dimensional space, using local or global coordinates." }, "Source:SetPosition": { "prefix": "SetPosition", "body": "SetPosition($position)", "description": "Source Method\nSets the position of a source in 3-dimensional space, using global coordinates." }, } It's not perfect. There is still no knowledge of what class methods can be used on what variable, but I think it is within the realm of acceptable support: Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted March 16, 2018 Author Share Posted March 16, 2018 I would also like to attach fields and functions directly to the C++ object instead of having self.entity and entity.script: window = Window:Create() context = Context:Create(window) world = World:Create() model = Model:Box() child = Model:Cylinder() child.health = 100 child:SetParent(model) function child:TakeDamage(damage) self.health = self.health-damage end componenttable[child]=child child = nil collectgarbage(collect) thing = model:GetChild(0) thing:SetPosition(1,2,3) thing:TakeDamage(10) print(thing.health) It will take some work to figure out the memory collection issues. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted March 16, 2018 Author Share Posted March 16, 2018 I'm sold pretty well on the snippets. This is great stuff. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
AggrorJorn Posted March 16, 2018 Share Posted March 16, 2018 Okay josh. Go to extensions and search Leadwerks. Or here: https://marketplace.visualstudio.com/items?itemName=aggror.Leadwerks Then just type in propstring or collision, followed by a tab. With the snippets you can easily identify tabbing positions which makes adding properties really easy. 1 Quote Link to comment Share on other sites More sharing options...
Josh Posted March 16, 2018 Author Share Posted March 16, 2018 Ah cool, you know how to make an extension. You can also do hints / default values like this (You might have to remove the quotation marks though: Script.$varname = "$value" --string "$label" Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted March 16, 2018 Author Share Posted March 16, 2018 I was looking at the debugger options and it looks like you can add an intermediate EXE that talks to both VSCode and the Leadwerks game and passes the debug info back and forth: https://code.visualstudio.com/Docs/editor/debugging Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
AggrorJorn Posted March 16, 2018 Share Posted March 16, 2018 I knew you would fall in love with it eventually. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted March 16, 2018 Share Posted March 16, 2018 2 hours ago, Josh said: It would be totally possible to auto-generate the entire API by pulling the data from the XML files the docs are stored in: You could generate it and store it inside the extension and additionally let the extension look for the online version every time you start VS code. That way you have an offline version of the API at your disposal and when you go online, you get the latest documentation. Quote Link to comment Share on other sites More sharing options...
aiaf Posted March 17, 2018 Share Posted March 17, 2018 Bonus , c++ debugger in visual code is decent replaced visual studio in windows with no problems. Quote I made this with Leadwerks/UAK: Structura | Stacky Desktop Edition Website: Binary Station Link to comment Share on other sites More sharing options...
josk Posted March 17, 2018 Share Posted March 17, 2018 Lua, I think it is wise to stick with this scripting language unless something major intervenes. Autocomplete is a must. Quote Elite Cobra Squad Link to comment Share on other sites More sharing options...
Josh Posted March 17, 2018 Author Share Posted March 17, 2018 Okay, so you are in the Leadwerks 5 editor. You want to run the current map that is open in the editor, in debug mode. You press F5. How does Leadwerks Editor tell VS Code to run the Lua debugger and launch the current map? ? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted March 17, 2018 Author Share Posted March 17, 2018 I found you can add a space at the end of a snippet name to make it unique, and it will still look the same (for function overloads): { "table.insert": { "prefix": "table.insert", "body": "table.insert($table,$value)", "description": "Inserts a value into a table at the end of the table." }, "table.insert ": { "prefix": "table.insert", "body": "table.insert($table,$position,$value)", "description": "Inserts a value into a table at the given position." } } Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted March 17, 2018 Author Share Posted March 17, 2018 CLI Options: https://code.visualstudio.com/docs/editor/command-line This will open main.lua and add your project folders to the workspace: "C:\Program Files\Microsoft VS Code\Code.exe" -r "%UserProfile%\Documents\Leadwerks\Projects\MyGame\Scripts\Main.lua" "%UserProfile%\Documents\Leadwerks\Projects\MyGame\Scripts" "%UserProfile%\Documents\Leadwerks\Projects\MyGame\Shaders" "%UserProfile%\Documents\Leadwerks\Projects\MyGame\Source" pause Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Rick Posted March 17, 2018 Share Posted March 17, 2018 2 hours ago, Josh said: Okay, so you are in the Leadwerks 5 editor. You want to run the current map that is open in the editor, in debug mode. You press F5. How does Leadwerks Editor tell VS Code to run the Lua debugger and launch the current map? ? If you make an LE extension maybe the extension will always create a local server from VS Code to do the communicating between? Quote Link to comment Share on other sites More sharing options...
Josh Posted March 17, 2018 Author Share Posted March 17, 2018 So we are looking at something like this? Not simple. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Rick Posted March 17, 2018 Share Posted March 17, 2018 What is the VS Code Controller? Quote Link to comment Share on other sites More sharing options...
Josh Posted March 17, 2018 Author Share Posted March 17, 2018 3 minutes ago, Rick said: What is the VS Code Controller? The extension that allows LE to tell VS Code when to run a game. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.