Jump to content

Script:UpdateWorld() Main Game Loop or every object?!


WazMeister
 Share

Go to solution Solved by WazMeister,

Recommended Posts

Hello,

I bought LeadWerks on steam beginning of week, finally sat down tonight to play around and learn.

Reading the help documentation, referencing Script:UpdateWorld() it states it should be called once in Main Game Loop.

Running through the marble tutorial, I've already noticed we've called it several times for individual objects.  i.e the Ball, now the coin to spin it...

 

So what exactly does it do specific for objects, and why not call it once in a main game loop.. where that may be (as assuming there is not one with scripts added to entities etc?!

 

Many in advance for all your assitance.

W

 

Dream since child of making games! From Game Programming Starter Kit 3.0, Blitz Basic, Map Creation since Duke 3D, Game Maker, Blitz3D (of recent..2023) and many other engines and years..... never really sticking to it with inner struggles that I've had to fight along with pushing to learn and acheive.

40 years old.. came across Leadwerks on Steam... Learning slowly but surely and loving it!

Learn with me or just watch me fail! at my random Youtube Channel, as I stream adhoc while learning and using LeadWerks and other game creating tools.

https://www.youtube.com/@wazmeister3151/featured

Link to comment
Share on other sites

  • Solution

Thanks Josh.

 

OK. So why does the tutorial ask us to put world update in scripts for specfici objects and not in a main script? 

Dream since child of making games! From Game Programming Starter Kit 3.0, Blitz Basic, Map Creation since Duke 3D, Game Maker, Blitz3D (of recent..2023) and many other engines and years..... never really sticking to it with inner struggles that I've had to fight along with pushing to learn and acheive.

40 years old.. came across Leadwerks on Steam... Learning slowly but surely and loving it!

Learn with me or just watch me fail! at my random Youtube Channel, as I stream adhoc while learning and using LeadWerks and other game creating tools.

https://www.youtube.com/@wazmeister3151/featured

Link to comment
Share on other sites

Thanks again Josh, very kind to assist.

 

I'm still not getting it.  I understand that on other languages I'd have at end UpdateWorld(), RenderWorld() etc at end of main game loop.

The Lua Leadworks tutorials go through add scripts to objects and adding UpdateWorld() script to some of them to update them....  but the API Documents say only add one to the Main game Loop.

What I don't understand is.

a) Where is main game loop in Lua / Leadwrks Engine to add or edit UpdateWorld? Why has the tutorial not asked us to add a main game loop?

b)why does the tutorial add updateworld to each object / script?

 

Or.. is it a case each script tied to an object is like it's own 'programme / code' and it needs it's own UpdateWorld() because it's in it's self a main game loop but for each script added to an object? If that makes sense... or am I looking at this totally wrong?

 

Dream since child of making games! From Game Programming Starter Kit 3.0, Blitz Basic, Map Creation since Duke 3D, Game Maker, Blitz3D (of recent..2023) and many other engines and years..... never really sticking to it with inner struggles that I've had to fight along with pushing to learn and acheive.

40 years old.. came across Leadwerks on Steam... Learning slowly but surely and loving it!

Learn with me or just watch me fail! at my random Youtube Channel, as I stream adhoc while learning and using LeadWerks and other game creating tools.

https://www.youtube.com/@wazmeister3151/featured

Link to comment
Share on other sites

The main program is stored in main.lua. That file is available to edit, but you probably won't need to modify it. It normally just stays the same unless you are doing something special.

Each script with an UpdateWorld function just handles updating of things related to that single entity.

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

Script:UpateWorld() is called during each world update, as opposed to Script:UpdatePhysics(), which is called each physics step. These two things can be different depending on the framerate.

In Ultra, there is just a single Update() function in scripts.

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

11 minutes ago, Josh said:

The main program is stored in main.lua. That file is available to edit, but you probably won't need to modify it. It normally just stays the same unless you are doing something special.

Each script with an UpdateWorld function just handles updating of things related to that single entity.

OH OK.. Now it's starting to make sense.  Thank you. 

 

So if I removed the update world function from the Coin, for example it might now update it's spin or position etc? 

Dream since child of making games! From Game Programming Starter Kit 3.0, Blitz Basic, Map Creation since Duke 3D, Game Maker, Blitz3D (of recent..2023) and many other engines and years..... never really sticking to it with inner struggles that I've had to fight along with pushing to learn and acheive.

40 years old.. came across Leadwerks on Steam... Learning slowly but surely and loving it!

Learn with me or just watch me fail! at my random Youtube Channel, as I stream adhoc while learning and using LeadWerks and other game creating tools.

https://www.youtube.com/@wazmeister3151/featured

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