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.

Program Announcements / New Lua5.1 Plugin - Free Scripting Pack for DBPro!

Author
Message
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 13th Mar 2006 09:33 Edited at: 22nd Oct 2008 00:51
new bugfix: 1.1.1 for dbp plugin and dgdk/c++ library! updated lua to 5.1.3 fixing some crashes! other fixes see changelog.
new: call dbpro user functions from lua! DBPro plugin version 1.1.0 release (affects only dbp, not the c++ library). See the changelog! and make sure to delete the old debug dll.
new2: released unmanaged c++ library of my plugin! download from my website.

check this out: coolgames released a very good lua plugin here: http://forum.thegamecreators.com/?m=forum_view&t=126843&b=5


Hello there!

I just finished a releasable version of my Lua Plugin! It is an interface to use the power of Lua within your DBPro applications.
It is free for non-commercial use, as my Winsock plugin. If you use it commercially please send me an e-mail (read the license text file included in the download pack).

note: I am NOT the author of Lua. For more information about lua visit the official website: http://www.lua.org

Now to my Lua Plugin!

Features
-load configuration files and access the variables
-execute script functions with arbitrary arguments (and access multiple return values)!
-use Lua tables directly and easily in DBPro! (array with named indexing)
-use Lua stack
-new: call your dbpro user functions from within your scripts!
-call every single DBPro/plugin command from within your scripts, directly!
-fast and small release version of the dll
-23 fully documented commands, and more to come...
-5 examples to get you started with the basics!
-1 Tutorial so far


Website
On my plugins website you can find all files and infos about this plugin:
http://homepage.swissonline.ch/barnski/main.htm

Download
read the license agreement please, in the download pack.
You can download it on my plugin website.

Online Help
You can also access each commands help. In the download there are examples included in the help directory.
http://homepage.swissonline.ch/barnski/help/lua.htm

Tutorials
Lua and configuration files http://homepage.swissonline.ch/barnski/Lua-Configuration_files.html

Examples
You find all examples in the download pack in the folder: help/examples/lua
lua_functions example shows how to call DBPro functions
register_functions example shows how to register and call dbpro user functions.

Lua Compiler
I compiled a Lua 5.1 Compiler. With it you can compile your lua scripts. You can load them as usual with LUA LOAD FILE.
Lua5.1Compiler.zip

Lua Editor
A small and fast editor is for example scintilla: http://gisdeveloper.tripod.com/scite.html
A more sophisticated editor is LuaEdit, check for it in google.
Alternatively, you can use John's Synergy IDE to edit lua files.


Why did I do another Scripting plugin?
Well, it has been already a year now since I heard of the capabilities of Lua, that was when I played World of Warcraft from Blizzard. Now I have seen that it is possible to bring the power of LUA to DBpro applications (with Unity by DavidT). Since I would like this power to have in my applications too, I decided to dive into the Lua world. It was actually quite easy to make this plugin, much easier than my Winsock plugin. I made it in a couple of days, and then I just tested it another couple. And it works!
Another reason to do this was to make this available for free!

Now I would like to add, that I did not copy any functionality of Unity (or DarkScript by Torrey, the other scripting pack). Actually, I haven't even looked at the possibilities of it, I did my plugin from scratch, with my own ideas!

This said, it may be that it lacks some functionality. But that does not mean that I won't might add it to my plugin!
One thing I probably won't add is the possibility to register DBPro user functions to the LUA scripting environment (edit: haha, I did it by now!). Since I will use DarkSDK I can do this easily by handing over the function pointers. But for the DBPro plugin it would require quite some assembly hack. Actually, Torrey told me that he did this for his DarkScript plugin, and he pointed me into the direction how to do it myself. For that I want to thank him and link his plugin here:
http://forum.thegamecreators.com/?m=forum_view&t=71740&b=5
note that it is not free.


Conclusion
This plugin should bring you the power of Lua scripting into your DBPro applications, for free!
A DarkSDK library will come too, stay tuned! (edit: its now available)


Thanks for your attention. Oh and, feedback is well appreciated! I will improve what I can.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 13th Mar 2006 10:00 Edited at: 13th Mar 2006 17:49
Removed to prevent the planting of unfounded ideas into other people's heads

Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 13th Mar 2006 10:15 Edited at: 13th Mar 2006 10:21
I quote my self
Quote: "Now I would like to add, that I did not copy any functionality of Unity (or DarkScript by Torrey, the other scripting pack). Actually, I haven't even looked at the possibilities of it, I did my plugin from scratch, with my own ideas!"


I don't see a reason for flaming here. If you don't want to use my plugin, then just don't. I certainly will, and I think there are others who might appreciate it too, that I released it here for free! I just follow an other philosophy when it comes to software.

I think linking Torreys Script is perfectly appropriate, if you read this:
Quote: "One thing I probably won't add is the possibility to register DBPro user functions to the LUA scripting environment. Since I will use DarkSDK I can do this easily by handing over the function pointers. But for the DBPro plugin it would require quite some assembly hack. Actually, Torrey told me that he did this for his DarkScript plugin, and he pointed me into the direction how to do it myself. For that I want to thank him and link his plugin here:
"

it clearly states that his plugin provides more fucntionality.

People can also see my plugin as a start, to get insight in scripting. But maybe it provides just enough power for their needs, as it does for mine.

Batvink:
Quote: "Why oh why oh why!?!?!?!?!?"

why should I buy a plugin, if I can do it myself?
And its just in my nature to share the result of my work.

greets,
Barnski.
Torrey
20
Years of Service
User Offline
Joined: 20th Aug 2004
Location: New Jersey
Posted: 13th Mar 2006 10:21
Hopefully he doesn't get caught in the cross fire of the scripting wars. Just for the record I had no knowledge of him creating this scripting plugin. A few days ago he asked in the DLL Talk forum about passing dbpro functions as pointers to a dll, where I answered some of his questions about this idea.

Thank you for the mention in your post. The plugin looks like it has a really nice start and your mind is filled with ideas. Good luck with your development process!

Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 13th Mar 2006 10:35 Edited at: 13th Mar 2006 10:36
Quote: "Just for the record I had no knowledge of him creating this scripting plugin. A few days ago he asked in the DLL Talk forum about passing dbpro functions as pointers to a dll, where I answered some of his questions about this idea.
"

Yea, that was two days ago. And I started this Plugin 5 days ago, to tell the truth. And when I was asking I could not possibly have known who would answer right but I mentioned I will link your plugin, and I can take it out of course if you want me to do so...

So actually, since I did this in a mere over-night-work, there was not much knowledge to have about my plugin at that time

Quote: "Thank you for the mention in your post. The plugin looks like it has a really nice start and your mind is filled with ideas. Good luck with your development process!
"

Thanks to you!

greets,
Barnski.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 13th Mar 2006 11:40 Edited at: 13th Mar 2006 17:49
Removed to prevent the planting of unfounded ideas into other people's heads.

Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 13th Mar 2006 12:05
Quote: "The reason for my comments is that DavidT put the extra effort in to make his product saleable through TGC. They don't just take any old product, they ensure that everything is of marketable quality. So it's a bit unfair on DavidT to give away, what is essentially an identical product.
"


Just because our script plugins use both lua, does not mean they are identical. Lua is widely used in the developing industry, as also in games. Lua has a C API, which somehow dictates how you have to design the interface, thats why the commands probably will look similar.
Altough I haven't bought Unity nor did I have a closer look to tell you the differences, I think that DavidT's plugin is better and provides more functionality to the DBPro user, at least at the moment. I don't know whether or how far I am going to continue developing the DBPro interface, it depends on how many like to use it.
But I will make a fully featured c++ library for those who use DarkSDK, as me, where you can register your own function, and where all DBPro functions are usable in the script (the latter is actually not yet possible in my plugin!)

So again, I did not copy unity! I just used LUA, which is free available source code from www.lua.org and I think I came close to its spirit by making a free plugin with it.

greets,
Barnski.
John Y
Synergy Editor Developer
22
Years of Service
User Offline
Joined: 4th Sep 2002
Location: UK
Posted: 13th Mar 2006 12:12
Barnski,

If you want to keep developing it then go for it, competition stops stagnation and drives innovation (I should know being in the IDE maket)

I would like to see how you implement the dbpro commands.

David R
21
Years of Service
User Offline
Joined: 9th Sep 2003
Location: 3.14
Posted: 13th Mar 2006 17:34 Edited at: 13th Mar 2006 17:37
Indeed, I agree.

I realise that David T's plugin was of a high quality (not to say that this one isn't), and had a lot of time invested in it, but we shouldn't allow it to become a 'monopoly' or one party state - just because it was there first doesn't mean that there isn't room for a free alternative.

Just the same with physics engines, however, in reverse; Newton does a perfect job, and TGC are also making a full blown commerical one for DBP. There's no problem with that, and there is no problem with this plugin either.

So good for Barnski, and a job well done too

Quote: "So it's a bit unfair on DavidT to give away, what is essentially an identical product.
"

So, your saying thaat no free alternatives should be availible for paid products? So the Linux community should just lay down its arms agive up, because MS put lots of time to get Windows as a salable product? I don't think so.

I understand what you mean, in general, but I think we should just let Barnski do his job, and get his plugin going. There's zero problem with it.

Quote: "Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all."
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 13th Mar 2006 17:48
In retrospect, maybe I was a bit harsh. I should have thought a bit more before opening my mouth

Sorry, Barnski, please accept my humble apologies.

Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 13th Mar 2006 18:42
Quote: "If you want to keep developing it then go for it, competition stops stagnation and drives innovation (I should know being in the IDE maket)

I would like to see how you implement the dbpro commands."
Thanks John
As for the dbpro commands: I am now trying to read the string table of the dll's that are present in the exe at-runtime, and then automatically get the function address and name. I already managed to get the address by hand, but now I want to serialize it so that any DBP update, or any plugin that is being added (or that I dont have) can be used from within the scripting functions. More on that as I make progress...

Quote: "So good for Barnski, and a job well done too ...
... I think we should just let Barnski do his job, and get his plugin going."

Thanks for your opinion David; I am on it

@Batvink
I am happy that you changed your mind, and I gladly accept your apologies

Now lets keep the talking about the plugin

greets,
Barnski.
Chris Franklin
19
Years of Service
User Offline
Joined: 2nd Aug 2005
Location: UK
Posted: 13th Mar 2006 18:54
and i got unity less than 2 months ago

John Y
Synergy Editor Developer
22
Years of Service
User Offline
Joined: 4th Sep 2002
Location: UK
Posted: 13th Mar 2006 19:18
Barnski,

No problem. You can get access to the dbpro commands from the globstruct.h file. Maybe a C++ programmer can give you more information.

coolgames
19
Years of Service
User Offline
Joined: 26th Sep 2005
Location: Oregon, USA
Posted: 13th Mar 2006 22:40
Is there a place where we can learn the basics of lua?

Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 13th Mar 2006 23:10 Edited at: 13th Mar 2006 23:36
Quote: "No problem. You can get access to the dbpro commands from the globstruct.h file. Maybe a C++ programmer can give you more information."

Fantastic! thanks alot John, you saved me some hours of trouble..
in the globstruct header are the instance handlers of the dll's, and whether they have been loaded or not. Now I just have to parse the string tables, look for the function addresses, and register them within lua. I will also check for the "spare" handlers, which might hold user-plugin dll's, I guess.

Quote: "Is there a place where we can learn the basics of lua?"

Yes, I started to learn it using an online book, although I haven't come past part I, hehe, I mainly read the last part, which is about the C API. You don't need to read that part, unless you want to make a c++ plugin yourself.
first, the official website is: http://www.lua.org
go to documentation, and there you will find a reference. But also the forementioned online book!


edit; in case you ever need to check with your own plugin for dbp dll's that have been loaded with the exe, this skeleton I just made with c++ might come handy:


greets,
Barnski.
coolgames
19
Years of Service
User Offline
Joined: 26th Sep 2005
Location: Oregon, USA
Posted: 14th Mar 2006 01:08
Can this execute Dark Basic commands?
Whenever I try to use commands that output to the screen, nothing happens.

Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 14th Mar 2006 01:13
Quote: "Can this execute Dark Basic commands?"

I just implemented this now during the last hour. But I have not tested it yet and I am too sleepy to continue...

Tomorrow it should be working, check back then!

greets,
Barnski.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 14th Mar 2006 14:21
Executing DB commands is a nice feature, but I would encourage people to use this as a method when all else fails. You should design your game engine to do the hard work, and Lua to chnage the way the AI works.

For example, you could program the movement of your character in Lua via DB commands. But what you should be doing is getting Lua to decide whether a character needs to change direction, send an appropriate message, and let the engine turn him. The engine knows how to turn the character and react to obstacles and other influences. If physics in involved, moving the objects in Lua is a complete no-no.

coolgames
19
Years of Service
User Offline
Joined: 26th Sep 2005
Location: Oregon, USA
Posted: 14th Mar 2006 14:57
It still makes it a ton easier. What happens if you have to change multiple objects? Or It's not a fixed object id that you are changing? It makes it a ton easier if you can execute db commands externally.

Freddy 007
19
Years of Service
User Offline
Joined: 30th Nov 2004
Location: Denmark
Posted: 15th Mar 2006 19:33 Edited at: 15th Mar 2006 19:47
I thought about getting Unity, but I think I will go for this one instead(sorry DavidT )! Then I can have NGC too...

Barnski for the win!

EDIT:
Ok, it's not that I don't want Unity, but if I go for this free LUA-thing, then I can have both LUA and NGC.

Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 17th Mar 2006 20:46 Edited at: 17th Mar 2006 20:47
May I have your attention please...

I proudly present you my new update !

You can now call ANY DBPro command from within your lua scripts!

I worked for the last 3 evenings on it and it took me even into the world of assembly to achieve my goal. lol I remember when I thought I had done it 3 days ago in my post above... but then I realized that it wasn't that easy. I had to make lua call ANY arbitrary dbpro function, with any amount of arguments.. and phew... all these overloaded commands! NO I did not manually code every single dbpro command and link it into the script
I made it automatically scan the EXE file when it is used (when you call LUA MAKE), and scans every dbpro dll that has been linked into the exe. It creates then a lua table with all the information it can get on the commands (arg types, overloaded functions, return types...), and waits for YOUR command to unleash its power! hehe..
Actually this loading isn't even noticeable! I haven't measured it since it is really nothing. It may depend on how many dlls you have in the exe, but it should really not bother (guess some milliseconds). Oh yea, of course you have to make sure that the dlls you want to use are linked within the exe. If you don't use object commands for example, then the Basic3D dll wont be linked, and you wont be able to call these commands from your scripts. To enable this, simply add a dll-specific command at the end of your dbpro code file, like: make object 1, 1, 1... its as easy than that.

Yes I know.... I know... you don't care about this feature? well then let me just be proud of it, because I think there is enough reason to be proud of
I feel like sharing my insight now, so if you want to know more about how I did it, feel free to ask.


OH and the most important thing I want to add: you have to test it! If you find a command that does not work (this is highly probable, since I may haven't thought of all exceptions), then report it please and I will make sure that these kindalikes work!


So how do you call the commands within your scripts?

like that:

DBPro.Call ("Print", "HEY THIS WORKS!!!")
DBPro.Call ("LoadObject", "my_super_object.x", 1)
DBPro.Call ("WaitKey")


Note: Lua is case-sensitive. DBPro and Call have to be correctly typed, and also the dbpro-command string argument! "Print" "LoadObject"
Syntax of dbpro commands: I automatically deleted the spaces in the dbpro commands and made first letters of words upper case. so "load object" becomes "LoadObject".
why? because I may add macros to the DBPro table, such that you can directly call: DBPro.LoadObject ("filename.x", 1).
and Lua does not allow spaces in function names.

I also might add security levels, such that you can allow and/or disallow dbpro dll's to be used from the script.


so, I hope you will play around with this feature.

Have fun!!

IMPORTANT NOTE: Since this plugin allows you to virtually resell DBPro (compile a dbpro.exe with all dll's in it, and that calls a main-script function, in where you can use all dbpro commands), I hereby DISALLOW you to SELL or distribute any product that simluates the usage of DBPro. You know, I mean a product, which sole purpose is to allow a user to use every DBPro commands. Even though they would be slower, I think it is fair to disallow it. And I don't want to get any license troubles with TGC.

greets,
Barnski.
Hawkeye
21
Years of Service
User Offline
Joined: 19th Sep 2003
Location: SC, USA
Posted: 17th Mar 2006 20:54
Uber!


I am but mad north north-west; when the wind is southerly I know a hawk from a handsaw - Hamlet, Hamlet
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 19th Mar 2006 14:51 Edited at: 19th Mar 2006 14:58
Yep

I just found a nice editor to use for LUA script files: SciTE

you can get it from here: http://gisdeveloper.tripod.com/scite.html

Here is a screenshot of it in action, and it shows also the usage of DBPro.Call extensively, for a scripted object viewer.



edit; I made the object viewer reload the script when you press spacekey at runtime, such that you can change the behaviour of the program during runtime!
I will post the scripted object viewer as an example when I am done with it.
edit2; in case you wonder whether this runs too slow: No it doesn't! it runs at 1000fps if I don't lock it to 60!

Torrey
20
Years of Service
User Offline
Joined: 20th Aug 2004
Location: New Jersey
Posted: 19th Mar 2006 15:16
Excellent work on the dbpro commands! Becareful though, during my development I got bitched at about having dbpro commands accessible with the possibly of creating a dbpro wrapper. TGC could get upset about this feature.

What's up with the scripting IDE's lately? People taking inspiration from my post?

Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 19th Mar 2006 20:51
Thanks Torrey.

I now explicitly disallow in my license txt file to make a dbpro wrapper with my plugin.

I just started to script, and I needed an editor better than notepad, so I looked for one
here's a list for those who haven't one for lua already:
http://lua-users.org/wiki/LuaAddons
I tried LuaEDIT but I don't like it, it is too slow when it comes to saving. So I am using SciTE (Scintilla) now. the link is in my first post above!


Yes and finally there is a new version downloadable. Someone had problems with the lua IO library, so I excluded it from the default loading. it isn't used anyways, as we use dbpro to handle input and output. make sure to clear your web cache before downloading....

Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 21st Mar 2006 11:57 Edited at: 23rd Mar 2006 17:43
I made a small bug fix; LUA STRING$() did not work properly on lua tables (e.g. "x.y"). Now it should!

If you find a bug, please make sure you have the latest version (check the date of the download in the first post). If yes, then send me an email/msn, or post here. Thanx!


edit; just another update(18:48)! I fixed another bug, now really every overloaded dbpro command should be recognized! the bug was it didn't recognize the last overloaded version of a command...
so for example, CLS has two versions:
1. CLS
2. CLS color
previously the 2. did not work. (note, it is "Cls" in my plugin)

another example: LOOP OBJECT ("LoopObject")
1. LOOP OBJECT id
2. LOOP OBJECT id, start
3. LOOP OBJECT id, start, end
previously, the 3. did not work, only 1. and 2. now all versions work!

just uploaded a new version. Added a DBPro.CallEx function, which allows to specify which argument types are being passed. This is needed for some functions that allow different numerical parameter types, e.g. Print.
Syntax: DBPro.CallEx ("Print", "O", 1.2345)
note: O means double float.

fixed a bug where DBPro.Call did not return floats properly.

Besides, I am on holidays now for a week

Xarshi
18
Years of Service
User Offline
Joined: 25th Dec 2005
Location: Ohio
Posted: 24th Mar 2006 00:49
can you call your own functions from the lua script? and when making a function,do you go like " function bla(bla as string) or what? im talking in the lua script. because with the pic above you just have a function like this: function refresh().

all ben needs is his band,his guitar,and his computer
Xarshi
18
Years of Service
User Offline
Joined: 25th Dec 2005
Location: Ohio
Posted: 24th Mar 2006 01:21
nevermind. this is a really great program though! its so awsome!

all ben needs is his band,his guitar,and his computer
Peter H
20
Years of Service
User Offline
Joined: 20th Feb 2004
Location: Witness Protection Program
Posted: 24th Mar 2006 02:59
*Kisses Barnski full on the face*

you probably didn't want that, but people who release things like this for free make my day

"We make the worst games in the universe..."
Olby
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location:
Posted: 24th Mar 2006 11:08
mine too, hehe

"Gangsters die, they don't go to heaven where angels fly!"
AMD Sempron 3.1+ Ghz, 512MB Ram, ATI R9550 256MB Ram, Sound Blaster Live!, WinXP SP2, DirectX 9.0c
qwerty823
18
Years of Service
User Offline
Joined: 17th Jan 2006
Location:
Posted: 29th Mar 2006 01:19
For your next update, can you make calls to:

luaopen_package() and luaopen_table().

Not being able to use the table functions (ie, table.insert(), table.remove() ) and not being able to "require" other modules, make it difficult to make usable lua programs.

Thanks!
Segan
19
Years of Service
User Offline
Joined: 28th Aug 2005
Location: Canada
Posted: 29th Mar 2006 18:44
This plugin looks good! I'll have to keep an eye on this thread...
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 2nd Apr 2006 16:22 Edited at: 2nd Apr 2006 16:25
Hello all, I am back from holidays

Quote: "nevermind. this is a really great program though! its so awsome!"

Quote: "*Kisses Barnski full on the face*
you probably didn't want that, but people who release things like this for free make my day"

Quote: "mine too, hehe"

Quote: "This plugin looks good! I'll have to keep an eye on this thread..."

Thanks for all the comments guys! as for the kiss; I will survive it I guess hehe

Quote: "For your next update, can you make calls to:

luaopen_package() and luaopen_table().
"

Updated and uploaded. Grab the new version as usual from the first post. After download make sure the release version date is the same as in the post (or else just clear your browser cache before downloading).

Quote: "can you call your own functions from the lua script? and when making a function,do you go like " function bla(bla as string) or what? im talking in the lua script. because with the pic above you just have a function like this: function refresh()."

It is not possible to call your own user functions that you defined in DBPro from within your lua script. I might add this feature though if I happen to have a great day or feel the need for. it may look something like this:
in the function you want to be accessible from your script you will have to put at the beginning a code line like:

to define lua functions within the script that take arguments you do not need (nor can you) to specify the argument type, since lua will handle this automatically. so, e.g.: function add(a,b) will take two args a and b, which may be numerical, or also strings... its like PHP.

Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 4th Apr 2006 17:30
New update.

Someone requested new features to load lua chunks...

two new commands:

LUA LOAD STRING lua_chunk as String, chunk_name as String
LUA LOAD BUFFER lua_chunk as Dword, chunk_size as Integer, chunk_name as String

important: I renamed a command (examples are updated)!

LUA LOAD filename as String
becomes
LUA LOAD FILE filename as String

I have added help for the new commands. Read it for more information.
Short: you can now call lua code from a string, or memory block (e.g. memblock). They can also be precompiled lua code. You can compile your lua code using "luac", a lua compiler. Google for it!

Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 4th Apr 2006 23:52
Once Again an update
I made a little mistake, now the commands work. I tested them with a small new example. It shows how to load lua chunks (script code) either in textual or binary (compiled) form.
I included it in the download pack: chunks.dba

I have also uploaded a Lua5.1Compiler that I compiled for you. You find it in my first post...

Tell me if you see a need for having the compile command within the plugin...

Next things I will do is:
- add the possibility to register custom dlls (other plugins)
- add a command that dumps all registered dbpro cmd names into a file so that you can look em up during development (also the custom dlls)
- allow thread handling from within DBPro
- <insert your feature request here>

Segan
19
Years of Service
User Offline
Joined: 28th Aug 2005
Location: Canada
Posted: 5th Apr 2006 03:20
I think you deserve some feedback after three strait messages giving updates:

Great job! As soon as I get some free time I will need to check out all of the new features (even if it means sacrificing some time spent on my own project... )
coolgames
19
Years of Service
User Offline
Joined: 26th Sep 2005
Location: Oregon, USA
Posted: 7th Apr 2006 16:28
This is really great! Those tables saved my life.

Maleck
20
Years of Service
User Offline
Joined: 12th May 2004
Location: US
Posted: 21st Apr 2006 22:35
You seems to have done some good work here. I hope to check it out soon. Been away from the programmign a while ot do some models for my projects and just starting to get up to speed on everything that has been going on recently.
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 25th Apr 2006 00:58
I hope you will find it useful, and thanks for the comments.

Unfortunately I am totally overloaded with studies at the moment, such that I cannot work on my plugins for awhile

However, dont hesitate to post anything that comes up..

dab
20
Years of Service
User Offline
Joined: 22nd Sep 2004
Location: Your Temp Folder!
Posted: 25th Apr 2006 07:25
Can you create a command that makes a MMORPG for us??

Lol. Just Kidding. Great dll Barnski.

Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 9th May 2006 21:27
The MMORPG will have to wait... at least for the DGSDK update

Someone asked me how I did call dbpro functions from my dll, and I would like to give a short howto here.

First: globstruct

include "globstruct.h" in your c or cpp file.
Use the g_pGlob pointer that is declared in it to acces the h_instance of the dll in which your command is located (e.g. g_pGlob->g_Basic3D). Note that the specific dbp dll may not have been loaded if you did not use a dll-specific command when compiling your dbpro app (e.g. one of the object 3d commands).
Optionally you can check for this using the ***made functions and inform the user/developer of the missing dbpro dll (e.g. g_pGlob->g_Basic3Dmade). You can use the window handler g_pGlob->hWnd to display a messsage box in c++.

Second: GetProcAddress

Using this function you can get the adress of a dll-function.
Syntax:
FARPROC GetProcAddress( HMODULE hModule, LPCSTR lpProcName );

hModule is the h_instance you retrieved before. lpProcName is a string containing the name of the function you want (e.g. "make object cube"). The return value will then be used to call the function. You can store it in a pointer and then cast it to the function type your specific function has.

Example (c/c++ code):


I hope it helps you guys writing your own dlls that use DBPro functions.

Note on the source: I wrote this on the fly with reference to my own source code, but some things I made different, so I can't tell for sure if the above is 100% correct syntax wise. Furthermore I made it automatically scan for dbpro functions, but this is a little more complex to explain...

coolgames
19
Years of Service
User Offline
Joined: 26th Sep 2005
Location: Oregon, USA
Posted: 10th May 2006 00:35
Could you show the whole c source for making a function that checks if an object exists. I can't quite get what you are saying unless you post the entire soure for calling a dbpro function.

Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 11th May 2006 23:19 Edited at: 11th May 2006 23:22
What exactly didn't you quite get?

Anyways, here is an example suited to "object exists":
(again, I write this directly in the post, no guarantees!)


The globstruct.h can be downloaded somewhere on the update pages of DBP of TGC.

coolgames
19
Years of Service
User Offline
Joined: 26th Sep 2005
Location: Oregon, USA
Posted: 12th May 2006 01:56
Now I get an error for these lines:
#include "dxdiag.h"
#include "D3dx9tex.h"

Where is it going to include these files? Where can I get them?

Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 12th May 2006 16:29 Edited at: 12th May 2006 16:32
They are being included in the globstruct.h file.
The reason are some texture pointers in the globstruct declaration.

Normally you 'd have to download the DirectX SDK (from microsoft).

Here is a hack that should solve your problem without downloading the 300mb SDK:
Open globstruct.h
Comment the two include lines:

Then, further down in the header file, you find a set of struct variables declared like this:

You can either change the texture pointers to void pointers like this:


Or define (on top of the file) the macro for texture pointers as void pointer:


Okay thats it. could work.

Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 14th Jun 2006 12:26 Edited at: 14th Jun 2006 18:19
Great plugin, Barnski
Just a question though; there's no support for DBP commands such as 'Do', 'While', etc. ? (I guess they wouldn't really be needed, but anyways)
~~~~~~~~
By the way, what is wrong with the following lines?
I intended to see what I could get out of this plugin; I've managed to get it to output some variables, but when trying to make this good old program, it gives me some really annoying error message "load_file error: [path to scriptfile]:4: '=' expected near 'Y'".

From what I guess, it's expecting an equal symbol before/possibly after the Y on the fourth line.
There's already one there as you can see, and it gives the same error even if I put another '=' there.... help please? ^,^´

Lua part:

(And yes, I also think that its inneccessary to have Y = 0 on the top line, since that didn't help either )

Det är väl så
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 14th Jun 2006 18:21 Edited at: 14th Jun 2006 18:42
Thanks Rudolpho, glad you like it.

No, you can't use dbpro language commands like if-statements, do, while etc. in your lua-code.

But as you said it doesn't matter, because with lua you can easily do such things. Have a look at the lua online book:

http://www.lua.org/pil/index.html

or, directly here for while-do-loops:
http://www.lua.org/pil/4.3.2.html


~~~~~~~~

Put your lua-code into a lua-function;
function show_cube()
<insert your code>
end

Again, have a look at the lua book for the correct syntax.
Then, in dbpro-code simply use the lua call function commands (see their help for usage), after having loaded the lua script.

Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 14th Jun 2006 20:34
Thanks for the info Barnski
However, your (seemingly correct) solution to the function problem terminates the executing DBP app and gives the message 'attempt to call a nil value'.
Since it does the same even if you leave out every reference towards any variables, I'm quite confused about it...
It might say something on the topic somewhere on lua.org though, shall check, but I thought I could ask here as well '

(... and no, didn't find anything useful on google)

Det är väl så
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 16th Jun 2006 14:34
Rudolpho:
have you already looked at the examples I provide in the download pack? look in the help directory of the zip.
If this doesnt help, can you post your dbpro and lua code? I will try to figure out what the problem is.

Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 22nd Jun 2006 11:54
@Barnski: *Goes and hides in the garden upon hearing that there were examples attached*
I wonder how I could've missed them.... well, anyways, will go through them today.
Thanks

Det är väl så

Login to post a reply

Server time is: 2024-11-24 17:18:33
Your offset time is: 2024-11-24 17:18:33