Scripts / Reloaded LUA Script and Engine Communication and Sequencing??

Author
Message
Go Devils
11
Years of Service
User Offline
Joined: 13th Aug 2012
Location: Phoenix Arizona USA
Posted: 3rd Jan 2015 20:54
Reloaded LUA Script and Engine Communication and Sequencing??

What remains unclear is the LUA script sequencing and engine interactions. I understand the common Functions in the Global.lua script as commands to the engine.

It's my understanding that the actual functioning of the game engine is to loop through each of the lua scripts continuously based upon the scripts attachment to an entity....

A) Is this correct?
B) What about scripts like Global.lua which is not attached to and entity?
C) Are the global variables that are defined at the beginning of global.lua, re-read during each loop or only once at the beginning of the game?
C) Is there any trick to creating my own MyGlobal.lua script to define my own global's and common functions? (running in addition to the basic global.lua script)
D) Are there other engine interactions that will effect, or are effected by lua scripts?
E) Are there any of these rules written down somewhere?

OK here's the bonus question... How are numeric variables displayed in prompt or other HUD displays?

Thanks

There is no Spoon...
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 3rd Jan 2015 22:18
A) yes
B) they are treated like functions and used when called by other scripts
C) the variables are updated in their respective functions
C2) yes you can use require http://www.lua.org/pil/8.1.html to call a file from a script (or global.lua)
D) dont know
E) no?
bonus) use
Quote: "value = 10
Prompt("this value is " .. value .. " units")"

basically wrap it in
Quote: ".."
(or just
Quote: "Prompt("this value is ..value)"
if nothing coming after.)

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Go Devils
11
Years of Service
User Offline
Joined: 13th Aug 2012
Location: Phoenix Arizona USA
Posted: 4th Jan 2015 01:00
Fantastic smallg
Your the "Code Master"
I just downloaded those series of scripts you posted earlier.

So let me pick a little further if I may...

C2) I think I understand the basic concept behind the require Function, though I'm unclear on where and when that command is used.
I'm assuming that I can have a MyGlobals.lua script with my global variables and my common functions like the global.lua script (??) Thus the
require Function forces MyGlobals.lua into active status, establishes my global variables, and remains active. ????

I'm also having trouble getting the ShowImage function to work. I think my problem is in the definition of path to load the images.
here's what I have so far but it errors when run

-- LUA Script - precede every function and global member with lowercase name of script + '_main'




Thanks

There is no Spoon...
Avram
GameGuru TGC Backer
17
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 4th Jan 2015 11:39
It should be something like this:



Go Devils
11
Years of Service
User Offline
Joined: 13th Aug 2012
Location: Phoenix Arizona USA
Posted: 4th Jan 2015 15:16 Edited at: 4th Jan 2015 15:23
Thanks Avram

You got me on the right track but it's still not displaying the image when I get inside 1000 units



here's the code that I ended up with.







In working with your code I discovered that the lua script name must be in lower case

I also discovered that the LoadImages string is a folder name "test" inside the scriptbank\images\.. correct?

It also seems that these type of prompt and display image function calls must be attached to a dynamic entity, static entities do not work... correct??



Thus, the above code does work without any loading error, and when I get within 1000 units, the prompt appears, but not the ShowImage(1) ???



The image that is loaded is a .png with the file name image0001.png, and is the only image in the folder "test" (360 x 225) size

What am I doing wrong???

There is no Spoon...
cybernescence
GameGuru Master
11
Years of Service
User Offline
Joined: 28th Jan 2013
Playing: Cogwheel Chronicles
Posted: 4th Jan 2015 17:01
The images MUST be called 000.png, 001.png, 002.png etc. Not image0001.png or anything else.

If you have a folder created under scriptbank\images called 'test' then your lua code should be OK as it's looking for that folder name "test". You can name this folder anything you like as long as the folder name matches the name you use in LoadImages command.

smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 4th Jan 2015 17:14
i dont personally use the require command as i only use a couple extra functions which i add directly to the normal global file but from reading previous posts it's like this


with "myglobal" being the name of the lua file you want to include

and yes dynamic for scripting always - i believe even if you are simply referencing that object (to move it via a script on a different entity etc) it also now needs to be dynamic (as if you bake the scene it becomes locked in place) - i could be wrong as i havent tested that though.

also note scripts have a range before they stop working - you can disable this by setting the "always on" in their properties.

think the image should be answered already... good luck

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Go Devils
11
Years of Service
User Offline
Joined: 13th Aug 2012
Location: Phoenix Arizona USA
Posted: 4th Jan 2015 20:05 Edited at: 4th Jan 2015 20:18
OK, it works!!

Here\'s my final code





placed a 2nd image in the folder, to test the image number in show and hide and all worked correctly.\r\n\r\na few other questions..

1) SetImagePosition, these value seem to be percentages(?) Set to (50,50) places the image at the center of the screen.

2) What other images file formats can be used?

3) I'm assuming that gif can be used with its transparency settings so the image can have parts that are see-thru (for use as a HUD)?

4) Since prompt seems to be the only way to get text to appear on the screen, can one control the location of the prompt text to line-up with the HUD or is this done a different way?



Thank you for your help on this, I promise that these are my final questions for this post...

There is no Spoon...
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 4th Jan 2015 20:48 Edited at: 4th Jan 2015 21:15
1) yes

2)

3) edit; using transparency in png's works fine

4) not yet but eventually it should get a complete system - last beta at least added a couple more options but still a long way to go

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Go Devils
11
Years of Service
User Offline
Joined: 13th Aug 2012
Location: Phoenix Arizona USA
Posted: 4th Jan 2015 23:41
Thanks smallg

There is no Spoon...

Login to post a reply

Server time is: 2024-05-07 19:33:50
Your offset time is: 2024-05-07 19:33:50