Jump to content

Lua in Leadwerks 5 is Solved

Josh

1,227 views

When considering the script system in Leadwerks 5, I looked at alternatives including Squirrel, which is used by Valve in many games, but these gave me a deeper appreciation for the simplicity of Lua. There are only a handful of rules you need to learn to use the language, it’s fun to use, yet somehow it does everything you could ever need.

These were three big issues I had to solve. First, the Leadwerks 5 API makes extensive use of smart pointers, which our binding library tolua++ does not support. Second, I wanted better auto completion and a better user experience in the IDE in general. Third, if an external IDE is going to be used it needs to be able to interface with the Leadwerks debugging system.

To support smart pointers, I found a new library called sol2 that does everything we need. @Rick and I discussed the idea at great length and I am happy to say we’ve come up with a design that is simple to use and quite a bit easier than Leadwerks 4.x even. The binding code is nowhere near done but at this point I can see that everything will work.

@AggrorJorn suggested using Visual Studio Code as our official script IDE in Leadwerks 5, and after investigating I think it’s a great idea. The auto completion is quite good and the IDE feels more natural then anything I could come up with using a custom text editor made with Scintilla. In fact eliminating the built-in script editor in Leadwerks 5 relieves me of a lot of uncertainty and potential issues when this is written.

Finally, VS Code has support for custom debuggers. I wrote an example command line debugger for Leadwerks and I will use this to show another programmer how to interface with Leadwerks. (I don’t plan on writing the debugger myself.)

With your feedback and ideas are shaping up to make Leadwerks 5 a huge leap forward over our previous designs. The improved simplicity of the new script system is a big cognitive relief. Having fewer things to worry about makes life better in a subtle but definite way.

There’s something else that consumes a lot of mental attention. Social media and the internet have grown and changed over the years and become more efficient at consuming our attention. (Many features of this site are designed the same way.)

The scary thing is that normal non-technical people seem to be more vulnerable than nerds. We’ll fire up the Witcher and play for an hour, but regular people are checking their phones 24/7 for feedback and validation. It’s much much worse than any accusation we got as kids of being “Nintendo zombies” because we spent an afternoon playing games instead of staring passively at broadcast TV. People who play games generally don’t care about posting photographs of their food or collecting followers.

Somewhere along the line the internet went from being a weird thing on your computer to the collective consciousness of humanity. Reality is online and the physical world around us is just a mirage, one possible instance of a million possible individual experiences. Maybe it was around the time they started using AI to optimize clickbait that things got out of hand.

Although my career and the way I live my life are only possible through the internet, I am old enough to remember life before the web, and in many ways it was better. Things were more focused. Even the early web before clickbait ads and online echo chambers was pretty nice. You could go to a record store and hang out talking to people about new music. Printed paper magazines were a thing.

I already removed the link to our Google+ page in the website footer and no one noticed. I think about deleting our Facebook and twitter accounts, or at least not linking to them on our site. Why must every website pay homage to these monopolies? What are they doing for me, besides a limited flow of hits that pale in comparison to what my own email list brings in? I have written about this before but now that it is fashionable to criticize social media I might act on it. I don’t know, we’ll see.

Please like, share, and retweet.

  • Like 8


11 Comments


Recommended Comments

I woke up with a sore throat so I am going to stay home today and hopefully prevent this from becoming a full-blown cold.

What I’m saying about social media is also a function of where we’re at right now. Everyone here has enough experience with Leadwerks 4 that we can discuss how to make the next version have the absolute best user experience ever. Plus I made quite a lot of money on Steam and I can afford to spend some on artwork and other things for version 5 (which will not be called Leadwerks anymore). I want to focus on you guys and give you something really amazing. and not spend any time yelling into the wind on Facebook.

I’ve also been thinking a lot about the need to establish something independent from Steam, which is why I started the $5 subscription service on our site.

The only social network I care about is you guys, right here.

Share this comment


Link to comment

I had some worries about the lua bindings with the new pointer system myself, but glad a new library does the job. I might look into Sol for my personal projects.

The VSCode implementation seems really neat. My only criticism is that it ruins the "All in one package" model you have created for the current version if you decide to not do your own script editor. Regardless, VS Code is really nice, I use it all the time. I just wish it opened as fast as notepad or notepad++. 

I haven't had the time to really play with Leadwerks at all as of late. But I'm always looking forward to what's new in the engine.

Oh yeah, as a kid I got called anti social because I liked to be on the computer a lot while being in the comfort of my home. I went to roller skating at a place last weekend and noticed that mostly everyone there was on their phones most of the time. I on the other hand left my phone in the car so it wouldn't get broken.

The idea that people paid money for admission for a social event, to be on their phone is disgusting.

Anyway, glad everything is working out.

Share this comment


Link to comment
7 hours ago, Josh said:

version 5 (which will not be called Leadwerks anymore)

Really?  I assume you'll want to wait before announcing it but do you already have a name in mind?

Share this comment


Link to comment

surprising you would want to walk away from your brand recognition that you have built up for over a decade by abandoning the Leadwerks name... :huh:

Share this comment


Link to comment

Branding is a difficult thing to achieve.  Companies re-brand themselves many times over the course of company solvency.  The only input I can give on this subject is when there is a core shift in the cultural ideas of said company.  This isn't to Josh, whom is more business oriented actually running one while I still work for one, this is to anybody reading in general.  Successful companies know when they evolve so does its culture and its ideas and that is where re-branding comes in.

Regarding pointers and Lua.  Lua is so highly underrated for a scripting language.  Of all scripting languages it's the closest to C in simplicity.  Combine that with C++, which as an aside by the time C++23 comes out raw pointers are *OUT*.  C++ was always meant to lean towards references but that backward compatibility with C made it what it was; although now you don't hear about pedantic conversations of C/C++ being interchanged.  They are two different languages now and continue to diverge.  

Hate to sound like I am ranting or rambling but I will say this:  Leadwerks is the only proprietary piece of software I am not only willing to shell out my own money for, I actually do with every opportunity...pitching ideas in unrelated circles to Steam or the wanna be game programmer and that whole "speaking with your money" part in the States where I reside this means something.  I have seen many pro's and con's with Josh, Leadwerks, etc. on social media that it made me a late comer to this product and community.  Some things I have not liked but in the end the actual product speaks for itself which is what matters most; even if I disagreed with Josh.

I believe, and I may be wrong, but it is my belief Josh wants a successful business while still having a loyal customer base not because of his company or his product but both and that is something I have subscribed myself to supporting as a customer.

Apologies if this sounds like some pointless rant but I am juggling a family, a successful Principal Engineer/Manager, and ready to work for myself instead of someone else.  I have to finish cooking dinner, get the kids to bed, and then get back to my side project with LeadWerks.  After 25+ years doing this I see a way to break the cycle without being beholden to the hamster wheel.

 

Share this comment


Link to comment

I would not consider a name change unless the new one was very good at making the brand spread faster and telling people what the product does. The name will be revealed when the Kickstarter campaign launches, which will be near the end of development. The point of the Kickstarter campaign is to launch the larger marketing campaign. GDC will come next, with a booth and maybe a lecture.

My first speaking gig at GDC was a nightmare. I had spent threee years writing my first C++ program. Unity had just announced a free mobile version the day before. There was a bad echo in the sound system so all my words were bouncing back to my after a short delay, making it extremely difficult to speak. And there were 600 people in the audience, from Apple, EA, Microsoft, etc., and everyone hated me, thought I was crazy, or didn’t know who I was. But I did it and I am proud of myself for that.

That happened before Leadwerks had any success. It was just an idea and I was an unproven nobody, with no track record of success. This was before Steam and before our first Kickstarter campaign. When Leadwerks 3 was launched I did not have all the contacts in the game industry that I have now. I did not know a dozen people at Valve. I was also broke. There’s a lot more I can do with the launch of 5 but at the core of that has to be a great, not good product.

The feedback I get from you guys is going to make this great, so I am definitely listening.

  • Like 2

Share this comment


Link to comment

It was really interesting to follow along with the lua/C++ discussion with Josh and Rick. I feel like I learned a lot by just reading the comments. 

My money is on Gearhead Engine (a person who pursues mechanical or technological interests (as in automobiles or computers). Fits with the gear logo too. But seriously surprised about the name change.

Either way, I like how you are open to the feedback of the community.

Share this comment


Link to comment
4 hours ago, Josh said:

I would not consider a name change unless the new one was very good at making the brand spread faster and telling people what the product does. The name will be revealed when the Kickstarter campaign launches, which will be near the end of development. The point of the Kickstarter campaign is to launch the larger marketing campaign. GDC will come next, with a booth and maybe a lecture.

My first speaking gig at GDC was a nightmare. I had spent threee years writing my first C++ program. Unity had just announced a free mobile version the day before. There was a bad echo in the sound system so all my words were bouncing back to my after a short delay, making it extremely difficult to speak. And there were 600 people in the audience, from Apple, EA, Microsoft, etc., and everyone hated me, thought I was crazy, or didn’t know who I was. But I did it and I am proud of myself for that.

That happened before Leadwerks had any success. It was just an idea and I was an unproven nobody, with no track record of success. This was before Steam and before our first Kickstarter campaign. When Leadwerks 3 was launched I did not have all the contacts in the game industry that I have now. I did not know a dozen people at Valve. I was also broke. There’s a lot more I can do with the launch of 5 but at the core of that has to be a great, not good product.

The feedback I get from you guys is going to make this great, so I am definitely listening.

Wow I didn’t know those details. Much respect as that took massive courage to do!

Share this comment


Link to comment

@Rick Yep, I was pretty shaky but when I showed them a deferred renderer running on an iPad 2 they **** their pants.

Anyways, my point is that I have enough contacts in the industry that if the product is great it will get a fair chance and won't be ignored. We just need to make sure it's great.

Share this comment


Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Blog Entries

    • By Marcousik in Marcousik's Creations Blog 5
      I updated the moto I was working on and now the physics let having fun with this.
       
    • By Josh in Josh's Dev Blog 7
      A new build is available on the beta branch on Steam.
      Updated to Visual Studio 2019. Updated to latest version of OpenVR and Steamworks SDK. Fixed object tracking with seated VR mode. Note that the way seated VR works now is a little different, you need to use the VR orientation instead of just positioning the camera (see below). Added VR:SetRotation() so you can rotate the world around in VR. The VRPlayer script has rotation added to the left controller. Press the touchpad to turn left and right. Any arbitrary rotation will work, including roll and pitch. Here are the offset commands:
      static void VR::SetOffset(const Vec3& position); static void VR::SetOffset(const float x, const float y, const float z); static void VR::SetOffset(const float x, const float y, const float z, const float pitch, const float yaw, const float roll); static void VR::SetOffset(const Vec3& position, const Vec3& rotation); static void VR::SetOffset(const Vec3& position, const Quat& rotation); static Vec3 VR::GetOffset(); static Vec3 VR::GetRotation(); static Quat VR::GetQuaternion();  
    • By Josh in Josh's Dev Blog 24
      Current generation graphics hardware only supports up to a 32-bit floating point depth buffer, and that isn't adequate for large-scale rendering because there isn't enough precision to make objects appear in the correct order and prevent z-fighting.

      After trying out a few different approaches I found that the best way to support large-scale rendering is to allow the user to create several cameras. The first camera should have a range of 0.1-1000 meters, the second would use the same near / far ratio and start where the first one left off, with a depth range of 1000-10,000 meters. Because the ratio of near to far ranges is what matters, not the actual distance, the numbers can get very big very fast. A third camera could be added with a range out to 100,000 kilometers!
      The trick is to set the new Camera::SetClearMode() command to make it so only the furthest-range camera clears the color buffer. Additional cameras clear the depth buffer and then render on top of the previous draw. You can use the new Camera::SetOrder() command to ensure that they are drawn in the order you want.
      auto camera1 = CreateCamera(world); camera1->SetRange(0.1,1000); camera1->SetClearMode(CLEAR_DEPTH); camera1->SetOrder(1); auto camera2 = CreateCamera(world); camera2->SetRange(1000,10000); camera2->SetClearMode(CLEAR_DEPTH); camera2->SetOrder(2); auto camera3 = CreateCamera(world); camera3->SetRange(10000,100000000); camera3->SetClearMode(CLEAR_COLOR | CLEAR_DEPTH); camera3->SetOrder(3); Using this technique I was able to render the Earth, sun, and moon to-scale. The three objects are actually sized correctly, at the correct distance. You can see that from Earth orbit the sun and moon appear roughly the same size. The sun is much bigger, but also much further away, so this is exactly what we would expect.

      You can also use these features to render several cameras in one pass to show different views. For example, we can create a rear-view mirror easily with a second camera:
      auto mirrorcam = CreateCamera(world); mirrorcam->SetParent(maincamera); mirrorcam->SetRotation(0,180,0); mirrorcam=>SetClearMode(CLEAR_COLOR | CLEAR_DEPTH); //Set the camera viewport to only render to a small rectangle at the top of the screen: mirrorcam->SetViewport(framebuffer->GetSize().x/2-200,10,400,50); This creates a "picture-in-picture" effect like what is shown in the image below:

      Want to render some 3D HUD elements on top of your scene? This can be done with an orthographic camera:
      auto uicam = CreateCamera(world); uicam=>SetClearMode(CLEAR_DEPTH); uicam->SetProjectionMode(PROJECTION_ORTHOGRAPHIC); This will make 3D elements appear on top of your scene without clearing the previous render result. You would probably want to move the UI camera far away from the scene so only your HUD elements appear in the last pass.
×
×
  • Create New...