Jump to content

Found some training on base lua... where to after that?


WSI
 Share

Recommended Posts

I found a video series on learning Lua. Just plain Lua, not Lua using Love2D, or Lua using Roblox, etc. Just Lua. I figure that's going to give me a better foundation and understanding of the language itself. Right now, I don't understand what I'm looking at when I look at a script in LW. Hopefully it'll help me better understand and learn when I start applying it to Leadwerks.

My question is, what would be recommended glue to bring basic Lua together with Leadwerks? I assume there's going to be a lot of commands specific to Leadwerks. I noticed that when I looked at Love2D. I want to first learn and understand Lua by itself, not as colored by a specific engine. 

Hope that makes sense.

Link to comment
Share on other sites

I know what you mean. There is a gap between learning a language and then getting it to do what you want it to do.

BluHornet did a series a few years ago. He takes you thru weapon drops, respawning, triggers etc.

https://www.youtube.com/channel/UCdNkNE5acxWUf2vCEo-eOcw

The best videos were by Jorn Theunissen. He had a series called Project Saturn. Unfortunately it is no longer available.

https://www.youtube.com/c/Jorntheunissen/videos

Other things you can  do include the tutorials in the Leadwerks documentation, look at the scripts that come with LW ( FPS script etc), check the forums ( I ran a Monthly script challenge a while ago where we did jetpacks, gravity guns etc).

Enjoy the journey.

  • Like 2
Link to comment
Share on other sites

Exactly so.

I'm running into a similar problem with the Lua video I'm following. It's just going through a bunch of different things (variables, loops, etc) with random examples, then moving on to the next subject. There's no practical example or explanation given of when you'd want to use these things. 

I honestly wonder how people manage to teach themselves programming with how many terrible courses/tutorials there are out there, whose creators don't seem to remember what it's like to be brand-new to it.

  • Like 1
Link to comment
Share on other sites

4 hours ago, Josh said:

Yup! Gone through that a few times now. 
It's very well done, but it's also very limited in scope - understandably. You're not trying to provide a complete Lua course here (though you'd probably do an excellent job of it, based on that tutorial).

The other thing is, it's specific to LW, which adds more complexity into an already complex subject - and I'm trying to avoid that. I want to learn Lua itself, to understand the base language, so I can then expand out into something like LW and already have that foundation.

Link to comment
Share on other sites

If you understand functions, tables, variables and loops, you are ready to go. Lua is that simple. My advice is to read Leadwerks' default scripts and see how those concepts are used there along with Leadwerks API. Then you try to adapt example scripts to your needs. And after that you are ready to program everything yourself.

Link to comment
Share on other sites

11 hours ago, Josh said:

Lua is pretty darn simple. I don't think there's much beyond what is described in the Leadwerks tutorials.

 

9 hours ago, Genebris said:

If you understand functions, tables, variables and loops, you are ready to go. Lua is that simple. My advice is to read Leadwerks' default scripts and see how those concepts are used there along with Leadwerks API. Then you try to adapt example scripts to your needs. And after that you are ready to program everything yourself.

I think that kinda goes into the area of what it's like for an experienced programmer, versus someone brand-new. I'm sure Lua's very simple, relative to other languages, for an experienced programmer. For someone just getting started, like myself, not so much. Learning the syntax, variables, loops, etc isn't the hard part. For me, it's figuring out what to use when. And it's where I feel almost every course or tutorial I find falls short. Everything is taught through memorization alone, rather than by practical example.

For example...
I decided my first task in LW would be to write a script that would simply move an object forward when I press W.  I went through the FPS player script, figuring I'd find a clue there, since it has that same functionality. Couldn't understand anything I was looking at. The Lua stuff was familiar - everything else was completely alien. Tried looking through the documentation, at the LW specific commands, etc.. Couldn't find anything that seemed like what I was looking for. Eventually concluded it's still too advanced for me. 

So, that's where I'm at. Stuck at learning the syntax, but not knowing what to do with it, where/when to apply it.

And I'm not even trying to become Mr. Super Coder. I just want to learn enough to create simple mechanics, or rough prototypes and such for my own projects. Proofs of concept, etc. Whatever it is that I should be doing to make it sink in keeps eluding me.

Link to comment
Share on other sites

The actual LUA founders site is pretty darn good itself, although I'm sure you already been through that tutorial but if not here it is - https://www.lua.org/pil/1.html

To me I always found the language wasn't that important at the start. Once you got a full grasp on any coding language, be it Dark basic, Blitz3d, Blitzmax, pascal, python.. anything....   once you understand the flow of coding in general then plugging in any language to that understanding is as easy as 'connecting a to b'.  

I'm only happy when I'm coding, I'm only coding when I'm happy.

Link to comment
Share on other sites

Since posting that last comment, I found this video online:
https://www.youtube.com/watch?v=zOjov-2OZ0E

I think this might just be what's been missing. The video isn't language specific, which is probably a good thing for me at this point, as I'm learning the concepts, rather than worrying about learning specific syntax. It not only goes over what different things do and how they work, but it's using practical examples that I might use in an actual project to convey their use. It's not saying "a for loop lets you print "Hello World!" 100 times", and leaving it there. 

I'm about half way through, and so far, it's all clicking in a way it didn't before, thanks to the more relatable examples and how they explain things in general.

To someone already experienced, it's probably "there's absolutely nothing new or insightful here". If that's what is occurring to you (who ever happens to read this), I'd just ask you to remember you're looking at it as an experienced programmer, and all of that is 2nd nature, and "simple". For me, it's all still very new and I'm still absorbing it. Different people learn in different ways, and for me, it's all about having something explained with a context that I can relate to. That's when I get it. 

So, we'll see how this all pans out.

Just occurred to me this is starting to read like a personal blog lol. Sorry 'bout that 😛

  • Like 2
Link to comment
Share on other sites

I remember when I first tried Dark Basic and downloaded a tree model from somewhere, loaded it in DB, applied a texture to it and got very angry because it was just flat brown. (No texture coordinates, and I didn't know what those were).

I also remember the first time I played one of my own maps in Quake and was shocked when I loaded it up I couldn't distinguish any of the level geometry. (Full bright with one texture, no lighting).

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

2 hours ago, Josh said:

I remember when I first tried Dark Basic and downloaded a tree model from somewhere, loaded it in DB, applied a texture to it and got very angry because it was just flat brown. (No texture coordinates, and I didn't know what those were).

Lol, I loved those days.  I wasn't new to programming ( as it was called ) back then but I was brand new to 3D programming.  I remember when I was making Beasts Online in Darkbasic vanilla, it was a mmorpg game but DB had no multiplayer or communication commands so I wrote a server then clients in VC and had to feed the DB application the packets via the Clipboard commands. :)

Ahhh the ingenuity, and that was after DB had been around a few years, the clipboard commands were added later.  I used the HD for packet control. lol.

( Sorry WSII got way off topic there... just that Halo... errrr. I mean Josh,  brought back some fond memories. :)

 

I'm only happy when I'm coding, I'm only coding when I'm happy.

Link to comment
Share on other sites

Decided to look at some tutorials online, etc. I found one that sounded like it should be simple enough, but I'm just confused watching it.
 

Here's what's confusing me...
What are the "Script." and "self." for?
I notice 'Script' is capitalized and 'self' isn't, but I don't know why that would be the case.
Why does he use : in some spots, but . in others?

And so on. 

According to others "reading others' code is a great way to learn". It's only confusing me more, because I haven't seen anything in this video in any of the Lua tutorials I've seen. Only one that's similar is the Lua tutorial here that Josh linked in a previous reply. But then nothing I've learned in Lua itself helps me understand what I'm seeing here. This is the wall I keep running into.

Beginning to think maybe I should just stick to "codeless" game engines, or just stick to environment stuff - though then I won't be able to convey or test ideas I have for games. 

Ugh. 

Again, this makes me super impressed by people who teach themselves. I've been trying to learn coding for a long time now, and I keep running into walls like this, where I encounter code or concepts that nothing I've learned up to that point helps me understand. So I end up wondering "am I just that thick?", "is there some chunk of important stuff I completely missed or overlooked?", "am I just incapable of absorbing this stuff?"

Link to comment
Share on other sites

5 hours ago, WSI said:

Why does he use : in some spots, but . in others?

https://www.leadwerks.com/learn?page=Tutorials_Lua-Scripting_Functions

Quote

 

A table function is called with the table variable first, followed by a colon (":") and then the function name.  When a function is called in this manner, the table itself is accessible inside the function code with the keyword self.  In the next example, the keyword self is used to get the table's own "health" value and display it:

MyTable = {} MyTable.health = 100

function MyTable:PrintHealth()
print(self.health)
end

MyTable:PrintHealth()

Note that the table variable and function name must be joined by a colon (":"), not a period(".").  Using the colon separator will silently insert the table itself into the "self" value.  If you use a period, the self variable will not be recognized in the function code:

 

 

  • Like 1

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

Just copy what others have done, adapt it to your need and ask questions like you just did in the process. Everyone has done it this way, it doesn't mean you need a codeless "engine".

 

Script. is a table defined by Josh in Leadwerks. You add functions and variables to it indicating that they are part of this script and nothing else. You can create a variable without "Script." and it will simply be global across every script.

Script.number = 1	--Accessible inside this script
number = 1	--this is global in your entire game

 

  • Like 2
Link to comment
Share on other sites

I will try to explain this script for you.

Script. respawnPoint = "" -- entity  "RespawnPos"

As Genebris explained above, this is a variable  specific to this script which will hold the information of an entity. In this case the place (pivot) where you want to respawn the player. Using the "-- entity" part generates a box in the editor where he drags the pivot into  at time point 4.41 in the video.

function Script:Collision( entity, position,normal,speed)

This is the collision function which is triggered if something hits whatever this script is attached to. In this case the big box below the player. The things inside the brackets are information on what hit the box. The entity, where it hit and its speed.

if (entity:GetKeyValue ("name") = "Player") then

This line of code checks to see if the entity that hit the box is called "player". This is the first use of the colon. So what does this mean. If you look up entity in the documentation and look at the list of functions that are associated with entities you will find  "GetKeyValue". Using the colon allows use to access any of these functions. Entity:Getcolor will tell you the color of the entity. Entity:Turn will rotate the object etc.

RespawnPos = self.respawnPoint:GetPosition()

In this line he is creating a variable called  RespawnPos, this is the position that he wants the player to respawn to.  The self refers to this script and the ".respawnPoint"  is the entity variable he made at the start of the script. Just like he  used the :GetKeyValue for the name now he uses the :GetPosition to find out the position of the respawn point. Remember the respawnPoint variable is an entity and we can access all those functions mentioned in the documentation.

entity:SetPostion(respawnPos)

In this line he sets the players position to that of the pivot ( respawnPos). Again the colon is used so that we can access the function SetPosition. ( check the documentation).

onRespawnPos = self.respawnPoint:GetRotation()

This time he is making a variable to hold the rotation of the respawn point.

entity. script.camRotation =  onRespawnPos

Now he  accesses the variable, camRotation which is inside the player script with the value of the rotation. So entity is player, script is FPSplayer script and camRotation is a variable inside that script. 

Hope this helps.

  • Like 2
Link to comment
Share on other sites

Thanks for the explanations. It kinda makes sense to me, though I don't know how "onRespawnPos" is getting the value for "respawnPoint", since there's no value assigned to it at the beginning of the script. It's just empty quotes.

 

  • Like 1
Link to comment
Share on other sites

32 minutes ago, WSI said:

Thanks for the explanations. It kinda makes sense to me, though I don't know how "onRespawnPos" is getting the value for "respawnPoint", since there's no value assigned to it at the beginning of the script. It's just empty quotes.

At the start of the script he doesn't assign  a value to respawnPoint but assigns an entity to the variable. In this case its the pivot  that he places in his map. Because the variable is now an entity we can now access all those functions outline in the documentation. This time he uses :GetRotation  so that he can then place this rotation value onto the player.

 

  • Like 1
Link to comment
Share on other sites

Have you had a look at the FPS template in Leadwerks.

It has many scripts already available to make a standard FPS game.

It sounds like you are very comfortable with the artistic side of game development. Use these skills to craft an interesting environment for a FPS game. Use the assets  from the workshop and the FPS tutorial .

https://www.leadwerks.com/learn?page=Tutorials_Games_First-Person-Shooter

Use the terrain editor to create your environment. Add a FPS player, add some enemies and create your story. No scripting required.

 

 

  • Like 1
Link to comment
Share on other sites

On 7/17/2022 at 5:17 AM, Thirsty Panther said:

Have you had a look at the FPS template in Leadwerks.

It has many scripts already available to make a standard FPS game.

It sounds like you are very comfortable with the artistic side of game development. Use these skills to craft an interesting environment for a FPS game. Use the assets  from the workshop and the FPS tutorial .

https://www.leadwerks.com/learn?page=Tutorials_Games_First-Person-Shooter

Use the terrain editor to create your environment. Add a FPS player, add some enemies and create your story. No scripting required.

Heya, thanks :)

I have looked through the script, when I was trying to figure out how to get a model to just move forward when I pressed a key, but couldn't find anything that seemed to do the trick. Though, again, I couldn't interpret most of what I was reading at all, so that didn't help in the end.

The games I want to make, at least my first ones, are all 3rd person... a puzzle game, a top-down auto scroller, etc.  The games that would be telling stories are considerably bigger and more complex action-adventure style, so I would need a lot more experience in programming, and game design/development in general, before I'm ready to tackle those. Only one of those bigger ones would actually be from first-person, heh.

The first one is a kinda whimsical, tile-based puzzler.  No combat, no fancy moves.. just moving around tile-based levels with grid movement, and completing objectives. Maybe 4 or 5 "mechanics" tops. Looking into how to make a model move by pressing a key was intended to be the first step to learning how to do the grid-based movement.

 

  • Like 1
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   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.

 Share

×
×
  • Create New...