Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / An example of LUA combined with the DGSDK

Author
Message
Mnemonix
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 21st Dec 2004 01:05 Edited at: 21st Dec 2004 01:52
Hi, Since I got the DGSDK a couple of days ago I have been working to integrate lua and create some examples of lua`s capability and potential within the DGSDK. Here is an example that I made yesterday and today. I shall explain how it works.

When the application is run, a script called main.lua is activated and this sets up the program. If nothing is in main.lua then the app is just a blank loop and is generally very boring.

There are a few commands I have created, they are

id=createObject(scriptname)
colorObject(id,r,g,b)
rotateObject(id,x,y,z)
positionObject(id,x,y,z)
moveObject(id,distance)

Ok, so nothing you can create the next NWN with, but let me explain the fist command. It returns the objects id number so you can use it to further setup the object using main.lua. The scriptname is the script that will be executed for that particular object when its event is fired. By default its event is fired every 10 loops but you can change this using setInterval(id,num_of_loops).
Also in the scripts for each personal object you have to get the id of the object you are working with (I will change it so that it defaults to the current object in the future). For now you have to use the getCurrentId() command. The lua language supports all kinds of loops and conditional statements, arithmetic etc. The examples included will probably explain more. See if you can think of any good things to change or include with this example.

[EDIT] I uploaded the file to my server. Can be downloaded by

http://logicstudios.net/script.exe

[/EDIT] Sorry for the confuzzlement

The 3d chat is coming...
Rights For Traffic Cones!
cybernetic wraith
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location:
Posted: 21st Dec 2004 02:37
Weeeeeeeeeee! =)
Mnemonix
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 21st Dec 2004 07:32
eh!? Is that your most constructive comment?.

The 3d chat is coming...
Rights For Traffic Cones!
TKF15H
21
Years of Service
User Offline
Joined: 20th Jul 2003
Location: Rio de Janeiro
Posted: 21st Dec 2004 07:39
Wooooeeeeeeeee! =)

TKF15H
21
Years of Service
User Offline
Joined: 20th Jul 2003
Location: Rio de Janeiro
Posted: 21st Dec 2004 08:05
Ok, on a more serious tone (I just made the "Take over the world" tutorial, you can't expect such a quick mood change!), would you be able to wrap this for DBP? Lua works well with C++, but there's no way to do this for DBP. Many people are asking for some kind of scripting engine and Lua would be great.

How has DGSDK been treating you? I'm thinking about getting it. Seeing that Lua works with it gives me a reason to do so. How do you think it could manage 20 simple FSM AI units?

Mnemonix
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 21st Dec 2004 08:09
Dont know, but I believe its more down to coding than performance of the language. Even with my code you can kill the fps by doing one type of script, while you can then edit the script, change a few things and get almost the same visuals but without the dent on the fps. Mainly because my scripts are run for each object at each interval. I tried making the interval work off the timer but that didnt work so instead I just did it in number of checks, i.e. so 1 is fastest (every loop the script is fired), 2 is twice as slow and 4 is twice as slow again etc.

Its about managing the events successfully.

The 3d chat is coming...
Rights For Traffic Cones!
billy the kid
19
Years of Service
User Offline
Joined: 7th Dec 2004
Location:
Posted: 23rd Dec 2004 11:39
Isnt VB basically a scripting language? Why then would you want a wrapper for a scripting language of a scripting language? Im not even sure that sentence makes any sense.
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 23rd Dec 2004 18:05
Quote: "Isnt VB basically a scripting language"

No - your thinking of the VB scripting system inside Word and what-not.

Quote: "Im not even sure that sentence makes any sense"

Indeed it doesn't.

Beware the cat... The alien... The heretic...
Mnemonix
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 23rd Dec 2004 22:03
Im not sure where he got the notion I was using VB from .

Perhaps its the only language he has heard of .

The 3d chat is coming...
Rights For Traffic Cones!
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 23rd Dec 2004 22:20
Indeed - the whole post is, as they say, rather odd...

Beware the cat... The alien... The heretic...
billy the kid
19
Years of Service
User Offline
Joined: 7th Dec 2004
Location:
Posted: 23rd Dec 2004 22:55
LOL!!!

The post was meant for TKF15H who wants to be able to use Lua with DBP. And I think thats kinda silly since VB, Basic, DBP, whatever (never used DBP and never will) is already basically a scripting language. So I was asking why would one want a wrapper for a scriping language (DBP) of a scripting language (Lua)? Does that make any more sense? Probably not.
Mnemonix
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 24th Dec 2004 00:34
Umm.

Neither VB, Basic nor DBP are scripting languages.

The 3d chat is coming...
Rights For Traffic Cones!
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 24th Dec 2004 01:47
Quote: "Does that make any more sense? Probably not"

Nope.

Indeed - A scripting language is a language that is used to control or otherwise modify parts of a controlling program (ie a program that calls one or more functions in the script). It has less functionality over proper languages in graphics, sound and various other bits (if any at all).

Beware the cat... The alien... The heretic...
Mnemonix
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 24th Dec 2004 09:52
Hey!. This thread got a mention in the newsletter . Thanks Rich.

The 3d chat is coming...
Rights For Traffic Cones!

Login to post a reply

Server time is: 2024-11-22 14:06:12
Your offset time is: 2024-11-22 14:06:12