I love the way you explain things and It would be really useful for me and a lot of other people if you in future could make a tutorial series about Modern C++. I just can't grasp it on my head and there isn't that good tutorials out there and the way you explained LUA is perfect. Thanks anyway!
+Greedy TopAz I have considered it. The big problem with C++ is complexity. For example, when it comes to datatypes, for number types in C++ there are: char, int, double, float, long, signed/unsigned versions, bool (yes... its a number type...) When do you use each? Largely it's a matter of what platform you are working on, which compiler you are using, etc... were on some platforms, certain int types will operate 10x slower than others, while on different platforms, this is completely different. How big is each data type? Well... this again depends on which platform and which compiler you are using. Hell, the order the number is even stored in (endian-ness) is platform dependent. With this obscene amount of variety, and inconsistent implementations, its very easy to be wrong or misleading. It is something I have considered writing for a very long time, as I know many people are using on particular RU-vid source and its absolute garbage.
Which is exactly why it is so hard to grasp it on my head. There are just too many different documentation based on different compiler or language version that it is almost impossible to know what the correct and efficient way of doing something is. But when it comes to speed, there is no other choice except C++. C# and Java afaik has never been used in any AAA games that is released.
#include //Where the system function is located. int main() //The main entry point of the application { system("lua53 "); // Using the console command to run lua code. system("pause"); // So it don't immediately exit out. return 0; // telling the console everything ran fine and we can quit. } in C++ so you don't need to keep doing lua53 Batch Version: @echo off lua53
local string = "heyo" print (heyo) doesn't work when doing it in the command prompt....that ramcha or whatever u called it where u open lua in command prompt and test stuff out directly there. If u get rid of the local it works there though. Little things like this cause great frustration for me when learning. I think you should indicate that the code we do in our interpreter won't work the same as writing it in the command prompt or at least in this case. Does this hold true for anything else or is this one of those exception things?
Hey, dude, I'm a complete beginner so I might be wrong, but I think that code should be as follow" local string = "heyo" print (string) You used the value in the "print" command, instead of using the variable. Edit: I actually understand the problem you are facing, now, as I tried to emulate it on my command prompt and had problems as well. Using local when setting a variable always return a nil. I'm also curious to why that happens.
Alright, hopefully both of you figured it out by now, but for future reference in case anyone else stumbles upon this: From what I could gather, when you assign a local variable at the start of the script, it gets scoped to the whole script, so print(string) is able to print the value of your variable. Within the interactive prompt, however, there is no script to scope the variable to, so it ends up being scoped _to that single line of code._ As a result, when you type print(string), there is no variable named "string" in the current local scope, which means the print function is looking for the variable "string" in the global scope and, since no such variable was ever assigned, it prints nothing. Try typing "local string = "hello" print(string)" all in one line in interactive mode, and you'll see that it works. Also, you can reference a local variable assigned within a function's scope in interactive mode the same you would in a script. So if you define a function: function sayHello() local myString = "hello" print(myString) end And then call the function with sayHello(), it will work as expected.
I wanted to write a quick equivalency test comparing 2 variables as seen below. I would expect the first "YES" value to never display. But what happens is that its always YES so long as I'm checking its equal to a value no greater than 2. I don't get it, as this seems to indicate that local dog = 3 is actually saying dog = 0, 1 , 2, 3; and cat = 0, 1 , 2. So if I'm checking if cat and dog == 3,4,5,6+ its no, but if cat and dog ==2, 1 ,0 its yes. I'm definitely not understanding something here. local dog = 3 local cat = 2 if cat and dog == 2 then print("YES both numbers are equal to 2") else print("NO they are not both equal to 2") end
If I'm running local dog = 2 local cat = 3 if dog and cat == 2 then print ("YES") else print ("NO") end My program always says NO. If I run something like local dog = 2 local cat = 3 print ("cat and dog == 3") It always says true. Same if I use print (cat and dog) to which it answers 3. Pretty weird.
I haven't done any serious coding in a long time so I'm just looking into different things and ended up here. From what I'm seeing Lua looks like it might be fun to work with. It sounds like userdata is something similar to passing parameters from say dll's. I'll have to look into it later on once I'm more familiar with the language. I'm surprised that it has the option to assign threads. Lua seems like it might be a bit more powerful than I was initially thinking. I have to say that the section on boolean numbers was a bit confusing and if I didn't already understand the subject I would probably be totally confused by the whole thing.
Thank you :) I know you have done a bunch of videos for lua, if you don' tmind making the same kind of lua videos but if you could go more in depth with what each variable ect does I would really appreciate that(I have no experience with programming at all). Maybe give some examples aswell like "okay so this code could be used in my "game" that im making and what it does is that when I press on the health potion it should drink it/use it. Thank you and will be continuing to watch the rest of the lua vids tomorrow, cause I need to learn this for Dota2 modding :)
Short answer, no. Medium answer, sadly no. Long answer, still no, with a but. That but is source level patch ( lua-users.org/wiki/LuaPowerPatches ) adding them. I do believe you can emulate them as well, but another advanced too.
+Gamefromscratch That's a bit disappointing. Is there a reason why it hasn't been added in yet? I really can't think of many languages that don't have them.
+Lonely Goblin There are a few (GDScript in Godot for one). I think it's mostly a matter of language simplicity. It's easily enough added to the core langauge. At the end of the day it's just syntactical sugar anyways, so while I miss them, they dont really take much away and I can see how some could make the argument they make for harder to read code. I can also see how people can argue they make more readable code too... ;)
+Gamefromscratch I love the way you engage your viewers, by using a very relative enthusiastic tone in your voice . To me those make for the best instructors , because a boring teacher voice is no fun right.lol On a serious note though , do you honestly feel that once a individual develops those core principles to coding , it forever becomes a piece of cake for them ?
Piece of cake might be a bit strong, but yes. I would say learning your second language takes a fraction of the effort of learning your first. I'm not talking syntax here... I mean, once you actually understand programming using a single language, learning different programming languages is a lot easier. These days after working in so many different languages, I can generally pick up and be productive in a new programming language within a few hours to days. Of course, learning the fine nuances takes much longer. There are some exceptions. For example, learning a functional language like F#, Haskel or LISP is going to require a bit of a loop in the way your brain works and are going to take a bit longer to come to terms with. They will still be easier to pick up with a good solid foundation in another programming language. Of course you can go your entire life without every learning one of these languages. Also this is becoming less of a point too, as aspects of functional programming languages are being adopted in traditional languages ( such as lambdas and closures ). Glad you enjoyed the tutorials. Cheers.