Embedding Lua in C++ #1

  Рет қаралды 171,850

javidx9

javidx9

Күн бұрын

C++ and Lua work very well together. Using Lua you can create modifiable programs by embedding it into your C++ program. In this video I take an introductory look at enabling data transactions between C++ and Lua.
Source: github.com/OneLoneCoder/Javid...
KZbin: / javidx9
/ javidx9extra
Discord: / discord
Twitter: / javidx9
Twitch: / javidx9
GitHub: www.github.com/onelonecoder
Patreon: / javidx9
Homepage: www.onelonecoder.com

Пікірлер: 374
@robinvanderploeg5485
@robinvanderploeg5485 5 жыл бұрын
"I'm using tabs for spacing instead of multiple spaces. This will make people angry. Additionally, I am going to place opening brackets on a new line instead of at the end of the preceding line. This will also make people very angry. Actually, every single thing I do here will make people angry, because people are horrible and this is why we can not have nice things."
@Nunya58294
@Nunya58294 3 ай бұрын
People that do shit like that are stupid
@bigcrazycarboy672
@bigcrazycarboy672 3 жыл бұрын
This has got to be the best tutorial on KZbin for this. It's extremely well made and rich with content. I hope to eventually get the opportunity to embed Lua in a game in Unreal Engine, but this is the first step ;)
@BlazertronGames
@BlazertronGames Жыл бұрын
Best tutorial for this on the internet, let alone youtube. I spent hours trying to figure out how to embed lua in c++, and all that came up were bad tutorials that barely mention anything. Even the official documentation doesn't cover it very well. This video covers lots and explains it really well in 35 minutes. Although, I do wish there was a text version of this video, for quick reference.
@GTR487
@GTR487 2 жыл бұрын
I watched this video 2y ago but I was unable to understand it because I didn't know English. Two years later, after learning English, I'm able to fully understand the video, and that's great, because it's an amazing explication. Thanks you very much :)
@ashrasmun1
@ashrasmun1 5 жыл бұрын
Fantastic! I was always fascinated with Lua from the day I've learned about it in WoW. Can't wait to use it in my C++ projects!
@LM555chip
@LM555chip 3 жыл бұрын
i just found this awesome channel recently. i like how you explain things simply. i also like how you approach critiques. like who cares really if you use system("pause") for convenience. nothing is taboo in programming imo, all options should be considered. congratulations for having so many subscribers, and you deserve more.
@JordanXion
@JordanXion 5 жыл бұрын
Nice video - I'd like to see videos on how to integrate Lua more broadly with C++, with unknown code, in the context of game add-ons/mods specifically
@storyseeker5387
@storyseeker5387 5 жыл бұрын
ty man. You gotta make more vids explaining more stuff. Really well explained here too, I'd love to see more
@RozzmanLists
@RozzmanLists 5 жыл бұрын
As always: very informative and very clear. Thank you for putting so much work and thought into your tutorials! I really appreciate what you offer
@javidx9
@javidx9 5 жыл бұрын
Thanks Rozzman, much appreciated!
@ragnarock811
@ragnarock811 2 жыл бұрын
I was modifying minetest to add custom function interfacing the clientmods without any understanding of this concept (although it worked), and now I watch this golden video explaining the basic I supposed to understand back in the day.. Good job, keep going!
@wowLinh
@wowLinh 5 жыл бұрын
I love LUA!! Only discovered it a couple of years ago and simply loved it. Great video explaining things, as usual!!. Love your channel keep it up!!
@javidx9
@javidx9 5 жыл бұрын
And as usual, thanks very much wowLinh! Gotta keep track of the early supporters now XD
@egdrei
@egdrei 4 жыл бұрын
Instantly subscribed 3 minutes into the video. Not because of the special nature of the video. But because it's clear your understanding of the topics are solid. Your explanations are direct and concise. I like that.
@harleyspeedthrust4013
@harleyspeedthrust4013 5 жыл бұрын
I've never really bothered with Lua but I'll have to check it out because this is cool. I usually use java, and my go-to solution for settings files was the reflection API because that made it easy to deal with type checking and such. You can have a class with all the fields named exactly as they are in the file and you can go through each line in the file and use reflection to get a field in the class by name and ensure that it's type matches with the type given in the file, then set the field to the value given in the file. You can't do more complicated stuff though, so I'll definitely have to take a look at this. Nice video, as always!
@billowen3285
@billowen3285 5 жыл бұрын
40k subs? Man I remember 8k, so glad you're getting the growth you deserve
@javidx9
@javidx9 5 жыл бұрын
Hey thanks Bill, both for the kind comment and the long time support.
@yan-amar
@yan-amar 5 жыл бұрын
I've been hearing about Lua for a long time, but this video really makes me want to use it.
@teucay7374
@teucay7374 4 жыл бұрын
This is exactly what I was looking for. You are awesome!
@MohammadHefny_HefnySco
@MohammadHefny_HefnySco 2 жыл бұрын
Great video .. . few days ago I knew nothing about lua.... now your video gave me a great push forward... many thanks for your effort.
@giuseppefusco1189
@giuseppefusco1189 5 жыл бұрын
You deserve a lot more subscribers. I'm gonna share your channel with my friends 😊
@javidx9
@javidx9 5 жыл бұрын
Thanks Giuseppe, I dont actively publicise the channel anywhere, nor do I use social media with any effort, but yes, tell your friends! XD
@ipa_stor
@ipa_stor Жыл бұрын
That's crazy how good is your explanation. I accidentally got this video in recommendations (0 at cpp, almost 0 at lua) but wow, this content is 🤯 thanks. and one more "thanks" for you logging operations with language tag👍👍👍 definitely must watch more
@DiegoLopesCF
@DiegoLopesCF 5 жыл бұрын
Oh! look mah I'm in a video :D
@nettoribeiro4267
@nettoribeiro4267 4 жыл бұрын
que privilégio, cara
@floretionguru2977
@floretionguru2977 4 жыл бұрын
Can't recommend these videos enough!
@ariseyhun2085
@ariseyhun2085 5 жыл бұрын
Explained it so damn clearly - Thank a lot for this video!
@highbrAned
@highbrAned 5 жыл бұрын
these tutorials are so comfortably helpful. thank you !
@javidx9
@javidx9 5 жыл бұрын
Thanks Klaus, Im pleased its useful to you!
@rigbyb
@rigbyb 4 ай бұрын
Your videos are so good! I wanted to learn how to embed Lua, and this video was insanely helpful. Thanks :)
@Ruxify
@Ruxify 5 жыл бұрын
Thanks for this. I've been wanting to implement LUA in my game engine for quite some time, but never knew where to start, instead trying to manually create an interpreter for a simple C like language. I managed to get most things working except for converting the AST tree into actual instructions to run in my simple virtual machine which managed to melt my brain, so I gave it up for a while. Now I can scrap that and start implementing LUA. :)
@zadfoe
@zadfoe 2 жыл бұрын
Hows the game engine
@HTDBarsi
@HTDBarsi 2 жыл бұрын
hows the game engine
@Ruxify
@Ruxify 2 жыл бұрын
I'm supposed to be doing a rewrite on the render module (including implementing PBR) but I haven't touched it in a while.
@HTDBarsi
@HTDBarsi 2 жыл бұрын
@@Ruxify Oh thats cool!
@mooks500
@mooks500 2 жыл бұрын
damn thats badass
@jsflood
@jsflood 5 жыл бұрын
Excellent explanation on a very interesting topic.
@dieSpinnt
@dieSpinnt 3 жыл бұрын
My sneaky rascal:) In the second example, the table-based configuration, you omitted the error checks. Thank you for the video.
@syne1456
@syne1456 5 жыл бұрын
have been waiting for this for soo long, thank you!
@javidx9
@javidx9 5 жыл бұрын
I hope its useful to you Syne!
@syne1456
@syne1456 5 жыл бұрын
@@javidx9 it was thanks!
@joelmanning249
@joelmanning249 Жыл бұрын
Very clear and concise with excellent examples.
@diegorosadossantos8493
@diegorosadossantos8493 4 жыл бұрын
That was an amazing lecture, thank you for sharing
@nl3146
@nl3146 2 жыл бұрын
BIG LIKE and thank you for the video. It' was very instructive and i learned a lot about Lua :D
5 жыл бұрын
This tutorial opens new galaxies for hobbyists. :) thanks again!
@javidx9
@javidx9 5 жыл бұрын
Hello Gurkan. It certainly does open up opportunities for hacking and playing. Loads of fun!
@stanosipenko7305
@stanosipenko7305 5 жыл бұрын
Finally, lua getting the love it deserves
@aryanmn1569
@aryanmn1569 Жыл бұрын
A masterpiece of explanation, barely possible to make big improvements on
@Mythricia1988
@Mythricia1988 5 жыл бұрын
Haven't watched yet, but I look forward to! I've spent the last 6 months or so writing Lua code so it'll be interesting to see it from the other side of the fence, so to speak. Lua is lovely! And extremely fast with LuaJIT, too.
@javidx9
@javidx9 5 жыл бұрын
Lua is awesome on its own, it gains awesomness when smashed into C++ at 100mph XD
@Mythricia1988
@Mythricia1988 5 жыл бұрын
@@javidx9 Maybe it could be fun looking at other embeddable scripting languages too? Things like Wren seem really awesome, and is purposely designed to be embedded like this, too.
@Philippe-ch6uk
@Philippe-ch6uk 5 жыл бұрын
I love your videos ! Keep up good work !
@javidx9
@javidx9 5 жыл бұрын
I appreciate that Philippe, I Will!
@gilneyn.mathias1134
@gilneyn.mathias1134 3 жыл бұрын
"C++ and Lua work very well together." Couldn't agree more! Playing around with Tibia's private servers for a couple of years was very cool ;p (and knowing that its a brazilian programming language makes it even better ;p huehue)
@frankluvsu21
@frankluvsu21 3 жыл бұрын
I am a beginner and the truth is that you explain very well.
@cpuwolf
@cpuwolf 2 жыл бұрын
the best tutorial for me trying to embed Lua
@sudeepgopal
@sudeepgopal 2 жыл бұрын
Thank you so much - Really appreciate the work you have done...
@asmbaty
@asmbaty 3 жыл бұрын
Great introduction! Thank you!
@xx512
@xx512 5 жыл бұрын
Beautiful. More please!
@trafficface
@trafficface 5 жыл бұрын
Thanks to this, I have Lua working in Web Assembly in node.js
@javidx9
@javidx9 5 жыл бұрын
Great stuff Adam!
@trafficface
@trafficface 5 жыл бұрын
@@javidx9 wip: github.com/acronamy/wasm-lua-node-tidal if your interested. Also I'd love to see some content for a game engine port to WASM in either node or browser. Blazor, cpp, rust or C.
@Shadow-bc5nr
@Shadow-bc5nr 2 жыл бұрын
Thanks alot for creating this video!
@winifix
@winifix 4 жыл бұрын
Finally I understand it, and I was not even trying to study it, now i can fix my WoW bots :)
@drorraba5775
@drorraba5775 4 жыл бұрын
Hi, I think im having familiar problem in other MMO-RPG game, any chance you can contact me?
@btatarov
@btatarov 5 жыл бұрын
You actually don't need to use for prints in lua :) Great tutorial
@matthewburren8563
@matthewburren8563 4 жыл бұрын
Your channel is a blessing
@nedok4724
@nedok4724 5 жыл бұрын
Great video. However, why use float for lua_HostFunction? To my knowledge, lua uses double as its internal representation for numbers and converting to float could lead to truncation errors. Maybe something to mention in the next installment
@samuelhurel6402
@samuelhurel6402 5 жыл бұрын
Grrrrr I'm so angry you don't code the exact same way as me! Nice tutorial, thanks for the video :)
@javidx9
@javidx9 5 жыл бұрын
Lol Samuel, you'd be surprised what my inbox gets these days XD Thanks buddy!
@davidste60
@davidste60 5 жыл бұрын
Nice video, I'm looking forward to more in this series. This Lua VM seems quite forth-like, does it have a seperate return stack?
@DavePoo
@DavePoo 5 жыл бұрын
I quote the Lua manual "Whenever Lua calls C, the called function gets a new stack, which is independent of previous stacks and of stacks of C functions that are still active."
@davidste60
@davidste60 5 жыл бұрын
@@DavePoo - Thanks but I meant a stack just for return addresses, not parameters. I guess not though. Forth has two stacks.
@jamesgrimwood1285
@jamesgrimwood1285 5 жыл бұрын
This is a fun rabbit hole to fall down 😀
@javidx9
@javidx9 5 жыл бұрын
Yeah it is James, Ive done some crazy things with Lua and C++, they really work well as a pair
@isaidstream4547
@isaidstream4547 5 жыл бұрын
Im so happy you use Lua :D, There's a game called Transformice, and you can make minigames using Lua :D
@juhabach4802
@juhabach4802 5 жыл бұрын
And Roblox but the syntax is a little different
@kaleidodeer
@kaleidodeer 4 жыл бұрын
​@@juhabach4802 The syntax is the same, it just gets a lot of extra functions, tables, methods etc to represent the C++ environment. workspace for example is really just a table that simulates OOP. So Roblox isn't doing anything weird with their implementation. (Although they did just get a new and faster VM for Lua) Gideros is probably a better example for a implementation of Lua but with different syntax. Gideros has a couple of community patches added onto it. Shorthand operators and easier array syntax for example.
@paradisefallen8385
@paradisefallen8385 2 ай бұрын
Still petfect guide. I like how you show stack changes
@MoroZ4300
@MoroZ4300 5 жыл бұрын
Great video! I got into Lua after playing Project Zomboid.
@javidx9
@javidx9 5 жыл бұрын
Thanks Mahdi!
@neozoan
@neozoan 5 жыл бұрын
Excellently done. Thanks!
@javidx9
@javidx9 5 жыл бұрын
Thank you Daniel!
@Michael-hs8gs
@Michael-hs8gs 3 жыл бұрын
Very nice video I really like your content.
@unevenprankster
@unevenprankster 5 жыл бұрын
I was waiting for this.
@javidx9
@javidx9 5 жыл бұрын
Hey Prankster, its a basic look at embedding, but I gotta start somewhere :D
@jurdendurden
@jurdendurden 4 жыл бұрын
Love your work, thank you.
@xemuth1643
@xemuth1643 3 жыл бұрын
Awesome vid ! I will use it to externalise some behavior on my 3d viewer !
@szczypiorofixable
@szczypiorofixable 5 жыл бұрын
Thank you for your tutorial! :)
@BlazertronGames
@BlazertronGames 3 жыл бұрын
Thanks for making this. It's way simpler than I thought it would be. I tried reading the lua documentation to figure this out, but there's no examples, just a function reference.
@raoul4246
@raoul4246 5 жыл бұрын
great !! as usual its probably took me 1 week to fully understand the video :-)
@javidx9
@javidx9 5 жыл бұрын
Nah Raoul, you'll get this!
@xTheKnallstock
@xTheKnallstock 5 жыл бұрын
Hi David, again a very nice tutorial, as usual. I would like to ask you, if you can possibly make a video about the rvalue reference and move constructors in the future because, you always explained hard topics like polymorphism so good to me and I can imagine, you will also do it with that topic. Thanks for making this awesome videos. Greetings Knallstock
@javidx9
@javidx9 5 жыл бұрын
Thanks Kiba, I'll add it to the list. I'll need to find a suitable "delivery vehicle" that can exploit using these concepts in an interesting way.
@zatochiSiberian
@zatochiSiberian 3 жыл бұрын
Great video! Thanks)
@bakioztepe
@bakioztepe 4 жыл бұрын
You sir are a great helper :)
@edmondmovsisyan2224
@edmondmovsisyan2224 3 жыл бұрын
27:45 how could I make the c program sensitive to the text file changes?
@urugulu1656
@urugulu1656 5 жыл бұрын
nice one ! only one Question : what did ya do to get rid of that sorta ever neccessary stdafx.h that visual Studio puts in everytime without it complaining on that?
@eminioxpl6651
@eminioxpl6651 5 жыл бұрын
Hah, I was just about to write small simple game in C++ with lua scripts to learn it and boom your video, thanks. You are my most trusted C++ information. I can't wait for more advanced stuff and see implemented lua in your game.
@javidx9
@javidx9 5 жыл бұрын
Thanks Eminiox, yeah Im looking forward to abusing Lua in my game too!
@timkim1967
@timkim1967 5 жыл бұрын
Thank you for all your videos you are a extremely skilled programmer. I’m just curious about something, how can I use multiple different objects for the same memory slot? For example if I wanted multiple different characters inserted into my game, how can I use the same memory slots so I don’t overload and/or slow down the program?
@rishiniranjan1746
@rishiniranjan1746 3 жыл бұрын
Beautiful and interesting
@dirtyblasion15
@dirtyblasion15 5 жыл бұрын
Stop hacking my browser history...I was just looking for this on google a few seconds ago
@javidx9
@javidx9 5 жыл бұрын
Ive got to get my ideas from somewhere DB XD
@SoftBreadSoft
@SoftBreadSoft 5 жыл бұрын
What the actual fuck me too this was creepy LOL
@drewestification
@drewestification 5 жыл бұрын
yeah same lol
@Music-sq8oy
@Music-sq8oy 5 жыл бұрын
omfg same lmao idk how
@noshit1128
@noshit1128 5 жыл бұрын
How the fuck are you guys still not aware of Google tracking and spying on you? Of course it will recommend videos on its own platform based on data it gathers from web pages which has Google's bullshit embedded in some way.
@Shorthouse061
@Shorthouse061 4 жыл бұрын
Great video, really easy to follow and understand. Do you still have plans to continue this series?
@javidx9
@javidx9 4 жыл бұрын
Thanks! I think i might, the #1 doesnt indicate a series, its just the first c++ and lua video. That said, theres a lot more detail to go into, so yeah, probably!
@dromedda6810
@dromedda6810 Жыл бұрын
this makes it so clear, why game devs decide to use lua for modding support, or scripting. lua despite its wierdness is such a great tool to have
@Bbdu75yg
@Bbdu75yg Жыл бұрын
Amazing !!
@kyoai
@kyoai 5 жыл бұрын
Hey javidx9, have you heard of the Lua wrapper SOL2? If you're working a lot with C++-embedded Lua i highly recommend using it (you can find it on Github, a user named ThePhD created it). I've been using it for years and it's absolutely amazing... though, embarassingly, while i've been using Sol2 for years i never learned how the direct Lua-C++ boundary works (because Sol2 abstracts that away), so i'm looking forward to more videos in this "series". :)
@javidx9
@javidx9 5 жыл бұрын
Hi Stefan, I have heard of it. There are numerous Lua wrappers and binders available, though Ive always enjoyed the "connection" of doing it myself. I think if I was using Lua in my professional role, I wouldnt think twice about using a wrapper.
@Octavarium666xyz
@Octavarium666xyz 5 жыл бұрын
You are reading my mind. I was thinking about starting with LUA for past few days.
@javidx9
@javidx9 5 жыл бұрын
lol, its a fun language Ales, very fast too
@user-pm2ru6ir6n
@user-pm2ru6ir6n 5 жыл бұрын
Very easy description for lua basics! thanx ) What about userdata, and lightuserdata, with images in next tutorial? ) (or effictive share dynamic array of structs between host and lua script, in both direction)
@javidx9
@javidx9 5 жыл бұрын
Thanks, yes I'll be covering lightuserdata in a follow up video, I find it very useful for shifting pointers to objects around.
@fk115
@fk115 4 жыл бұрын
Thanks for this well explained and very educational video. One suggestion I would have, however, is that you should wear another clip-on microphone in all your videos during the side view in which you speak visibly. The differences in tone (clear off-voice compared to ambience sound with a reverb) are a little distracting and slightly semi-professional. But this is only a very small drop of imperfection, otherwise your videos are excellent and I would be happy if even more users would watch them.
@javidx9
@javidx9 4 жыл бұрын
Cheers, interesting... i used to use a clip on mic, but i didnt like the indistinct vocals at all. Personal tastes i suppose. I like the cutaways to be a little break in proceedings.
@flobuilds
@flobuilds 5 жыл бұрын
Thats really awesome you could make a command line where you can enter full formulas and execute them in c++
@javidx9
@javidx9 5 жыл бұрын
Thats right Bluestroker, and effectively if you install lua properly, that is exactly what the Lua command prompt does, you can enter full functions and objects and tables, all valid lua code this way.
@flobuilds
@flobuilds 5 жыл бұрын
@@javidx9 thanks i did not know that lua is awesome
@Ben-up4lj
@Ben-up4lj 5 жыл бұрын
Good morning Javid, I'm following you about some month now and see that you're using C++ heavily. I'm a engineer and more focused on C, never learned C++ properly. I guess you are good in C too, so it would be nice if you can a video why you changed to C++ and who you see the advantages. There are already some videos about the languages but I like to watch what you think in this special case (C vs C++). Keep it going, your channel satisfying my brain :).
@javidx9
@javidx9 5 жыл бұрын
Hi Ben, I did start with C (Turbo C to be precise), but swiftly moved on to C++. It is my opinion (no doubt a controversial one) that there is literally no point in learning C anymore. Even embedded platforms have a growing number of C++ implementations available to them. The nice thing about C++ is you can pick and choose whether or not you need the Object Orientation capabilities. Again, in my opinion, these things are useful even for trivial tasks regardless of how your system design is constructed. If you can program in C++, you would find the migration to "pure" C quite trivial. BUT! And its a big but, the way C++ is presented these days is to actively avoid using C like constructions and syntax - something which I disagree with. I believe you should program in the style that solves your problem with the least resistance, and if a C like project structure is better for what you are doing, then run with it. Perhaps not necessarily the answer you were looking for, but I like to be honest. Thanks for watching though, I like to think the way I make my videos you could reproduce the core content in almost any language.
@jonteboimakesgames
@jonteboimakesgames 5 жыл бұрын
Nice tutorial!
@javidx9
@javidx9 5 жыл бұрын
Thanks Seashore!
@jonteboimakesgames
@jonteboimakesgames 5 жыл бұрын
Np as a awesome creator you diserve it!
@SapphFire
@SapphFire 5 жыл бұрын
Thank you!
@zaspanyflegmatyk2446
@zaspanyflegmatyk2446 5 жыл бұрын
PLLSSSS make a tutorial about cmake i cant find anything good and yours would be 10/10
@javidx9
@javidx9 5 жыл бұрын
lol thanks for the belief Zaspany, but I found CMake to be such a confusing mess I refused to use it. Maybe, one day... Though there are some cmake experts on the discord if you want to ask someone!
@madkouryt
@madkouryt 5 жыл бұрын
I agree that CMake is a mess mostly because of the legacy functions and the backward compatibility stuff, but it's rather a powerful tool if you are working on more than one platform or IDE, and also if you hate to go through all visual studio's properties tabs. I would recommend this talk "Florent Castelli: Introduction to CMake" by Florent Castelli: kzbin.info/www/bejne/oKWWnpiOmbVgh6s This talk uses modern CMake functions, also all the code is available at github as a tutorial.
@code-dredd
@code-dredd 5 жыл бұрын
Ahhh yes.... cmake, the thing you need to use for cross-platform project/compilation support only to discover it's a f(*&! language of its own and you can no longer focus on writing your originally intended code in the first place.... I don't like cmake and the docs suck as much as cmake itself >:d
@madkouryt
@madkouryt 5 жыл бұрын
@@code-dredd For small projects there is no need to use CMake, but if you are working on a corss-platform project/library that has dependencies on other libraries, and you have more than one contributor every one with his own favorite IDE/text editor, you have two choices: 1- Maintain multiple project files, then if you add just one source file you have to update and test all these project files. 2- Use CMake and maintain only CMakeLists.txt files, then every one generates projects files for his favorite IDE/tool chain. I would argue that for large project, it's easier to run with CMake, but if your project is small it isn't worth the hassle as you have to write some boilerplate when you can just click file-newproject and be done.
@notsalman
@notsalman 5 жыл бұрын
Zaspany Flegmatyk are you trying to do cmake on Linux?
@karlkastor
@karlkastor 5 жыл бұрын
Interesting. My old company embedded Lua directly into C++ for preprocessing like e.g. internationalization. So you'd first run Lua on the source code to get the final C++ source code and then you could compile the C++.
@marcoalejandrosalas1066
@marcoalejandrosalas1066 3 жыл бұрын
I want to understand and have something clear, since I am a learner in this world of programming and that, in this tutorial it is taught clearly and "practically", how to execute Lua code or Lua itself in a C ++ program. If so please affirm me to know that I have learned something great for future project applications, thank you
@davidbundgaard
@davidbundgaard 4 жыл бұрын
@javidx9 Hi, good work on this topic, have you considered what you want to for part #2, if such ever will exist?
@user-bf1zg6tx6u
@user-bf1zg6tx6u 4 жыл бұрын
0:33 It's also very useful for businesses and industry to be able to modify their programs vapidly
@krenciak
@krenciak 4 жыл бұрын
Please make a second part!!
@selfhelp441
@selfhelp441 Жыл бұрын
great video! where can i find what libraries are included in lualibs?
@Johannes00
@Johannes00 3 жыл бұрын
Hi! :) I have a question. Constantly error checking every LUA variable (or parts of the external LUA script) seems very tedious to me. Isn't there a simple but speedy way to loop through the code / script that needs to get the C++ "it's not malicious LUA" stamp of approval?
@javidx9
@javidx9 3 жыл бұрын
Hi Johannes, Im afraid its not that simple. If you know your lua is just for you, then only error check what you need to. This is quite a common thing, all your lua files could be embedded in your executable for example. As soon as you open up your program to running unknown code there is risk. One way to help reduce risk is to only prime the lua vm with the libs that you need, so if you dont give it the file handling library for example, the users code wont be able to open files...
@Johannes00
@Johannes00 3 жыл бұрын
​@@javidx9 Thank you for the quick reply! Well, I guess I just have to buckle up and hunker down with learning the proper ways then. At least I feel that with the help of your videos over the years, I have been able to push myself past the point where I'd usually give up! (But I often have trouble staying focused on learning one thing at a time, hehe)
@justsomedude5108
@justsomedude5108 5 жыл бұрын
javidx9 your channel is excellent. Please demonstrate how to draw 2d isometric tiles and sprites. There's lots of tutorials showing how to draw the artwork but I find anything about the programming of them. It would be awesome if you could cover how to calculate the movement when the view is isometric too. Thanks for everything you share!
@javidx9
@javidx9 5 жыл бұрын
I would like to explore isometry too at some point so it is definitely on my list of things to demonstrate.
@justsomedude5108
@justsomedude5108 5 жыл бұрын
@@javidx9 I can't wait until you do! I loved games like Diablo and Starcraft. I'll keep a look out for your videos. Thanks again
@BlazertronGames
@BlazertronGames 3 жыл бұрын
including lua.hpp will do exactly what you've done with the extern C line.
@inx1819
@inx1819 2 жыл бұрын
thanks good to know
@rockyrivermushrooms529
@rockyrivermushrooms529 5 жыл бұрын
Id like to see some python related videos. and maybe some engineering related C++ videos!
@CoolDude911
@CoolDude911 3 жыл бұрын
I have a question about the size of the stack. Is it standard practice to pop the stack after saving a global lua variable to a C variable? When a fixed amount of global vars are read I guess it does not matter but would you pop or clear the stack at certain points as standard practice to avoid the lua stack getting too big?
@javidx9
@javidx9 3 жыл бұрын
Managing the Lua stack is "on the whole" automatic, but there are instances where you need to do it yourself. You'll realise when, because your memory consumption will always be increasing XD
@CoolDude911
@CoolDude911 3 жыл бұрын
@@javidx9 Cool thank you for making these videos.
@veda-powered
@veda-powered 5 жыл бұрын
Just one thing I noticed: because lua5.3 has native support for integers it would be better to call lua_tointeger instead of lua_tonumber and casting to an int.
@javidx9
@javidx9 5 жыл бұрын
You are quite right Ben of course, it does support integers, but at this stage in the series I think just number was clear enough. The code I uploaded to accompany the video does use tointeger conversions.
@MatchTerm
@MatchTerm 2 жыл бұрын
Hello, This tutorial has been VERY useful for my own things, but I do have a question if you don't mind: is there a way to have the check also display other errors being made in the lua part of the code instead of just the first breakpoint? I am doing some code that would require something akin to that, so if you could provide some information on how to achieve that, I would be grateful
@javidx9
@javidx9 2 жыл бұрын
Thanks, lua is fundamentally interpreted (using vanilla lua) so it can only detect runtime errors when they occur. It can of course identify syntax errors when the file is parsed.
@MatchTerm
@MatchTerm 2 жыл бұрын
@@javidx9 Hmm, I understand. Thank you regardless
@alessandroculatti1613
@alessandroculatti1613 3 жыл бұрын
Regarding the example of storing the settings in an external file, is there any particular reason to use a scripting language over a file type meant to store values, like a json file?
@javidx9
@javidx9 3 жыл бұрын
It entirely depends on what you need to store, but it can be pretty awesome to have a config file with dynamic attributes. An exaggerated example. You store your application window size in the config file. But a dynamic one could actually determine the best window size and provide that, without needing any modification of your existing code.
@alessandroculatti1613
@alessandroculatti1613 3 жыл бұрын
@@javidx9 That would be a cool feature to have, I can see why a dynamic config file could be useful
@ThePhobosAnomally
@ThePhobosAnomally 5 жыл бұрын
Hello, I recently learned that your name was David. Let me congratulate you on getting such a nice name. I'm David as well. Could you perhaps make a tutorial on how you name your variables and how you keep your code manageable? I'm sure you have plenty of tips for that. Thanks!
@ashrasmun1
@ashrasmun1 5 жыл бұрын
"Hello, I recently learned that your name was David. Let me congratulate you on getting such a nice name. I'm David as well. " what the fuck did I just read...
@atrumluminarium
@atrumluminarium 5 жыл бұрын
Here's a bit of a wordy question: So say I am writing a Lua script. In this script I define a function matMul(a,b) that takes in two matrices and multiplies them the normal way we multiply matrices. This function was chosen because it's generally an operation that involves a heavy workload, ~O(n³) to be exact After this video, now I know that I have two options: • write the entire function within the Lua script as "pure Lua" • write the function such that it lets C++ do all the grunt work and Lua just handles the initial and final values As an intermediate level programmer, I would be inclined to think that for large work loads, the low-level Lua/C++ would out-perform the high-level Lua/Lua since it allows for more detailed optimisation (especially if considering frameworks like OpenMP and OpenCL for parallelism). My question is, would it possible to discuss this by showing a few benchmark comparisons in a future episode? I was tinkering with this particular concept a while back but there is little info about it. Maybe having an episode about comparisons would lead people easier to this video where you discuss the "how to" aspects. Also thanks for the video, like I said this issue was driving me nuts trying to figure out before I saw this video :)
@javidx9
@javidx9 5 жыл бұрын
Hey atrum, your instincts are correct. Do the grunt work in optimised C++ code. And call that from lua. This is how most systems that use lua should work. Which can make defining the boundary between whether your program is mostly a C++ or a Lua one a little blurred. I will be following up this video showing more complex interactions between the two.
@atrumluminarium
@atrumluminarium 5 жыл бұрын
@@javidx9 Thank you :)
@ryzenrog1139
@ryzenrog1139 4 жыл бұрын
Hey man! I've got an error when i try to debug my application... In the output, it's written that i do not have reference to the lua methods...
@Yes-gu2wn
@Yes-gu2wn 3 жыл бұрын
F
@justgame5508
@justgame5508 5 жыл бұрын
I always store file settings as text then write my own parser and read them in using regular expression or something similar, just using Lua looks a lot safer and simpler. Nice
Automating Sequences via Lua Coroutines in C++
45:23
javidx9
Рет қаралды 58 М.
Intrinsic Functions - Vector Processing Extensions
55:39
javidx9
Рет қаралды 122 М.
Dynamic #gadgets for math genius! #maths
00:29
FLIP FLOP Hacks
Рет қаралды 18 МЛН
ONE MORE SUBSCRIBER FOR 6 MILLION!
00:38
Horror Skunx
Рет қаралды 14 МЛН
How many pencils can hold me up?
00:40
A4
Рет қаралды 18 МЛН
Omega Boy Past 3 #funny #viral #comedy
00:22
CRAZY GREAPA
Рет қаралды 33 МЛН
Embedding Lua in C++ Part 3: Meh... Just use Sol...
31:10
javidx9
Рет қаралды 24 М.
Cross Platform Graphical User Interfaces in C++
44:49
javidx9
Рет қаралды 856 М.
Why Is Lua So Popular?
8:03
Awesome
Рет қаралды 83 М.
What Are Pointers? (C++)
41:55
javidx9
Рет қаралды 558 М.
why do header files even exist?
10:53
Low Level Learning
Рет қаралды 351 М.
NeovimConf 2022: Lua, a Primer
30:10
John McBride
Рет қаралды 14 М.
I made my own Programming Language
9:10
FaceDev
Рет қаралды 381 М.
Power up all cell phones.
0:17
JL FUNNY SHORTS
Рет қаралды 49 МЛН
Carregando telefone com carregador cortado
1:01
Andcarli
Рет қаралды 2 МЛН