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
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 29th Jul 2007 19:36 Edited at: 30th Jul 2007 01:08
Just a quick question here...
Is there any way to have "normal" arrays in the lua interface?
(With that I mean stuff like array[1, 2] = 16, etc. where the values are returned by giving the array index numbers (1 and 2 in my example))
All I can find about lua arrays is that one should use a table instead (table.index1.index2 = 16); that, however, doesn't do for accessing, say, shield number 58's info, which would be very easily done if you just typed shield(58).

Edit: Allright, that wasn't very clear perhaps; I can create the array, but what I can't make out is how (if it is even possible?) to access the array from DBPro.

"I kören hörs de brummande busarna Björnligan och Gondolen"
The admiral
22
Years of Service
User Offline
Joined: 29th Aug 2002
Location:
Posted: 2nd Aug 2007 08:40
Hey would you be able to add the aility to use commands from other dlls?? Also im having trouble with variables etc im trying to use lua functions to perfrom my magical effects and in order to do this i need access to varaibles like the players health etc is there anyway I can gain access to these varaibles and send the info back into the programme without sending the variables in and out via lua push commands??

The admiral
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 2nd Aug 2007 10:04
@The admiral: About the variables, I use lua tables which are used to hold such information inside DBPro as well; seems to work fine.

"I kören hörs de brummande busarna Björnligan och Gondolen"
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 3rd Aug 2007 12:08
@Rudolpho
Quote: "Allright, that wasn't very clear perhaps; I can create the array, but what I can't make out is how (if it is even possible?) to access the array from DBPro"

What you can do as a workaround, is write lua functions that return a value of an array at a given index.
Otherwise I would have thought that you can access indexed values inside a table also through usage of the index as field name. But I guess I have to add an array set and get function to the plugin. For now you can use the workaround.

@The Admiral
Quote: "Hey would you be able to add the aility to use commands from other dlls?? "

I can try to add a command which loads in all cmds from a named dll. But I need to postpone this after my exams.

Quote: "Also im having trouble with variables etc im trying to use lua functions to perfrom my magical effects and in order to do this i need access to varaibles like the players health etc is there anyway I can gain access to these varaibles and send the info back into the programme without sending the variables in and out via lua push commands??"

You can either store everything in lua tables as Rudolpho mentioned, or, you can use a message base system to inform the dbpro part of what the script would like to change.
E.G. create a table that will hold such "messages", define message via a msg type and some arguments. E.g. msg type "modify character attribute", sub-type "health" and value "-20".
Then, either directly after calling the lua function (which created the message during computation) or once in your main dbp loop, check for those messages and execute them.
I hope this was understandable...

The admiral
22
Years of Service
User Offline
Joined: 29th Aug 2002
Location:
Posted: 8th Oct 2007 11:42
Is there any way to have more than one script loaded at one time and being accessed?

The admiral
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 10th Oct 2007 00:02
for some reason, when I try to download the plugin (click the link on your page), I get the message "This ID is not used".
StOrM3
21
Years of Service
User Offline
Joined: 24th Sep 2003
Location: Cyberspace
Posted: 22nd Oct 2007 23:54
I get the same problem, can anyone send me the plugin, compiler, examples etc.. please..

email them to: storm3@mirrovisionstudios.com
or storm3@twlakes.net

Thanks,

StOrM3

[PKE] Pain Killa Entertainment(tm) [PKE]
Pain Brings Reality...
[PKE] Pain Killa Entertainment(tm) [PKE]
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 30th Oct 2007 01:21
Quote: "for some reason, when I try to download the plugin (click the link on your page), I get the message "This ID is not used". "

Problem fixed. sry for the delay.
Our university's IT changed the filesystem and now everything has problems working...
But I changed to relative paths and download links are valid again! check my page in sig.

Quote: "Is there any way to have more than one script loaded at one time and being accessed?
"

I didnt know that this is a problem. cant u just load two scripts and use both functionalities?
Haven't been into lua for a while..

The admiral
22
Years of Service
User Offline
Joined: 29th Aug 2002
Location:
Posted: 31st Oct 2007 03:37
Im not sure i mean how does it tell which one you want to use a command with?

The admiral
Cash Curtis II
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 3rd Jan 2008 16:11 Edited at: 4th Jan 2008 10:28
Quote: "DBPro.Call ("Print", "HEY THIS WORKS!!!")"


That is just fantastic. I own Unity, and I use it heavily, but I think that I will switch to this plugin for my RPG scripting system. The ability to call DBP commands opens a whole world of possibilities for scripters.

I read through the four pages and I have a fair grasp of the capabilities of this plugin, but I just want to clarify a couple things:

1. When you use 'LUA Make 1' are DLL commands included? For example, I want to use IanM's Matrix1 Utilities.

2. As I understand, you don't have the ability to call DBP functions directly from the LUA script. Is this the case? If #1 is true then I'll be able to call functions directly with IanM's function pointers.

3. Is there an equivalent command for Unity's 'LUA Execute'? Here is the help file information...



The help file looks very straightforward, but I didn't see anything that resembled this.

Great work, this plugin looks fantastic.

[Edit]
After re-reading some posts, then stubbornly trying it out myself, I answered my first question.

If LUA has the pointer to a DBP function, can it call that function by its pointer?

Just so you know, I'm not making a DBP wrapper, I'm just exposing the functionality of my RPG engine to the scripting language.


Come see the WIP!
bass guy1669
17
Years of Service
User Offline
Joined: 24th Mar 2007
Location: The Zone
Posted: 15th Jan 2008 05:06
sorry for the bump but this for some reason it doesn't work

come see night shift at http://forum.thegamecreators.com/?m=forum_view&t=106003&b=25 see you there
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 20th Jan 2008 19:36 Edited at: 20th Jan 2008 19:38
Hey, sry for the late response. I have been on holidays for 3 weeks, traveling through south america.

Quote: "1. When you use 'LUA Make 1' are DLL commands included? For example, I want to use IanM's Matrix1 Utilities.
"

No, custom dlls are not scanned at the moment, thus you cannot use their commands with DBPro.Call() or DBPro.CallEx(). I know I earlier promised to add this functionality in, but I hadn't have time to get to it yet. So dont count on this too soon

Quote: "2. As I understand, you don't have the ability to call DBP functions directly from the LUA script. Is this the case? If #1 is true then I'll be able to call functions directly with IanM's function pointers.
"

No, you cannot use DBPro.Call() to call your own DBP functions, since I still haven't implemented a way to register them. An addressOf(functionName) DBP command would be very handy. But if you have a dll that provides this command, then you can try to do it yourself by assigning to a lua variable the memory address of the function. then you can call it in lua with the usual function syntax. For simplicity you should probably avoid using parameters though. You can use global lua variables as an alternative. Good luck!

Quote: "3. Is there an equivalent command for Unity's 'LUA Execute'? Here is the help file information...
"

Yes, simply use the LUA LOAD STRING command with which you can load a lua code passed as a string. Check the help at: http://homepage.swissonline.ch/barnski/help/lua/LUA%20LOAD%20STRING.htm
The error return value can be checked with LUA ERROR() and LUA ERROR MSG$(). You should call them after the load call, to check for errors and to act apropriatly.

Quote: "sorry for the bump but this for some reason it doesn't work"

Can you please elaborate on what exactly is not working? thx.


Keep me posted with problems, but currently I am in an exam session, so it can take a while.[quote]

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 20th Jan 2008 19:56
@Barnski
Quote: "addressOf(functionName)"


Who said that hasn't been added (Hint-hint look under 'DOWNLOADS' for AddressOf precompiler)

MSon
20
Years of Service
User Offline
Joined: 13th Jul 2004
Location: Earth, (I Think).
Posted: 20th Jan 2008 21:36 Edited at: 20th Jan 2008 21:37
Looks good this, Could be useful

Everyone Be Cool, You, Be Cool.
Cash Curtis II
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 20th Jan 2008 21:55
@Barnski -
Thanks for the reply! I have a question about this...

Quote: "you can try to do it yourself by assigning to a lua variable the memory address of the function. then you can call it in lua with the usual function syntax."

I just tried that but it didn't work for me. It tells me that it could not find a DBP function by that name. I assigned the ptr address to a variable like so,

Quote: "ptr=get ptr to function(2)
Lua Set Int "dbDeleteCube",ptr"


And the pointer address of the function is correctly assigned to "dbDeleteCube". When I use DBPro.Call("dbDeleteCube") it tells me it can't find that command. When I try and print one of the commands, like Print ScaleObject it doesn't print anything. How are the command addresses stored? If I can register my functions manually then it should be able to work.


Come see the WIP!
MSon
20
Years of Service
User Offline
Joined: 13th Jul 2004
Location: Earth, (I Think).
Posted: 21st Jan 2008 15:29 Edited at: 21st Jan 2008 15:51
The option to run your own Functions would definatly be a big improvement, At the moment im having to link Lua to DarkScript for this, but its not ideal as you cant use it until the end of a Function, (After any Lua Commands).



Everyone Be Cool, You, Be Cool.
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 21st Jan 2008 21:02
@Cash Curtis
I was wrong, you cant do it manually, sorry. But good news: I have started to work on it, and it seems doable.

@Diggsey
Thanks for the preprocessor. Now I only need to know where you have the get ptr to function() command from?

So, in the next version you will be able to load custom dbp dlls/plugins and thus making their commands available to the DBPro.Call(). In addition, you will be able to register dbp user functions with help of the get ptr to function() cmd, and then also be able to call them using DBPro.Call(). Parameters and return types should not be a problem. I will next work on Thursday on this.

Cash Curtis II
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 21st Jan 2008 22:28 Edited at: 21st Jan 2008 22:29
Awesome! 'get ptr to function()' is a command in IanM's Matrix1 Utilities, DLL#20 specifically. It's free so there's no excuse for someone not to have it It's here...

http://forum.thegamecreators.com/?m=forum_view&t=85209&b=18

I'm glad you're working on this Barnski. This is exactly what I need for my scripting system.


Come see the WIP!
Roxas
19
Years of Service
User Offline
Joined: 11th Nov 2005
Location: http://forum.thegamecreators.com
Posted: 21st Jan 2008 23:55 Edited at: 22nd Jan 2008 07:01
Never mind.. It would not work :&


Click For Details!
bass guy1669
17
Years of Service
User Offline
Joined: 24th Mar 2007
Location: The Zone
Posted: 23rd Jan 2008 18:34
The commands don't highlight and just won't work

come see night shift at http://forum.thegamecreators.com/?m=forum_view&t=106003&b=25 see you there
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 30th Jan 2008 23:02 Edited at: 30th Jan 2008 23:08
New update available: 1.1.0

Changelog:


You can download the new pack which includes the release dll version from my website (signature). Make sure to delete any old debug dll of the plugin in the plugins-user folder of DBP! I will now only release the "release" version, and no more debug version.

About the functionality:
as the changelog says there are 2 new commands.
One for registering single dlls (dbpro dlls or dbpro plugins). If you dont like to register all dbpro dlls using lua make, you can now call lua make 0, and register each dbpro dll you like.
The other command is for registering single functions, e.g. dbpro user functions, but also dbpro dll and plugin commands, but also arbitrary dll commands. They can have as many parameters you like and also a return type. But it is a bit tricky to register the function. You will have to read the help for the command LUA REGISTER FUNCTION.

Important: There is a new example in the help/examples/lua folder. It is called register_functions.dbpro. It should help you with the new commands!

Quote: "bass guy1669: The commands don't highlight and just won't work"

You need to extract the whole pack into your DBPro folder. That is the dll into the plugins-user (make sure there is only one file of my plugin, only release and no debug version), the help folder, and for highlighting the editor/keywords folder.

Hope you get it right guys! I have tested all but the registering of arbitrary dll functions. But in theory it should not be a problem
Oh and I advice to use IanM's great MatrixUtility plugins for the command GET PTR TO FUNCTION and GET PTR TO DLL FUNCTION.
And you might also want to check out Diggsey's addressOf() preprocessor.
hf!

MSon
20
Years of Service
User Offline
Joined: 13th Jul 2004
Location: Earth, (I Think).
Posted: 1st Feb 2008 17:12 Edited at: 1st Feb 2008 17:13
If this works like you say, then this will be essential to my application, will try later.

Thanks

Everyone Be Cool, You, Be Cool.
MSon
20
Years of Service
User Offline
Joined: 13th Jul 2004
Location: Earth, (I Think).
Posted: 1st Feb 2008 22:43 Edited at: 1st Feb 2008 23:02
I use to have my own scripting language, and although it was not that good, i have now reused part of it here

Set the Directory to your Keywords folder and perform a file scan, open every file and remove the paramiters so your ownly left with the commands, then build a Paramiter String and Paramiter String Type, in most keyword files it specifies the type, once you get each command all you need to do is Add a bit of code to an open file using the Darkbasic file commands, adding all the commands into 1 file like so



You can usually work out from the keyword files if it returns a value, Then in a Seperate file you write the Lua Command to add the Function




Im rewriting my code at the moment to work with the new lua commands, but this should allow full access to all darkbasic commands, and all commands from any plugins you have installed

what you end up with is 2 include files just needing a little manuel editing, and what do you know, Every command available

Just what i needed for my project.

Thanks


Everyone Be Cool, You, Be Cool.
Cash Curtis II
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 2nd Feb 2008 14:43
Barnski, you rock!! Thanks for doing this, I can't wait to get started


Come see the WIP!
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 2nd Feb 2008 16:24 Edited at: 2nd Feb 2008 16:25
@MSon
(I also replied to your thread in the dll forum)
You got it. You can have every command available in lua. Actually, lua make 1 does this already for every dbpro dll. What you then need to do additionally is to use LUA REGISTER DLL to get all the commands of any plugins you want. And finally you can register your user function with LUA REGISTER FUNCTION.
Your way of automatically registering all functions using the keywords ini files is good too. You should call lua make 0 then, to not double register the functions. With your way, you also get the functions of encrypted dlls/plugins, where the stringtable is not directly accessible, and therefore LUA REGISTER DLL wouldnt work (This is what I ve been told..). Maybe you are so kind to share your "preprocessor" with us?
In either case you need to manually make sure all the dlls/plugins are compiled into the exe by using at least one command of each in your dbpro code.

@Cash
Thanks, and I am looking forward to see how you guys put this plugin to good use!

Cash Curtis II
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 3rd Feb 2008 23:48
The first issue I'll have to address is to create a pre-processor that will convert all of DBP's code functions into LUA commands. That will be fairly easy, the unpleasant part right now is correctly ascertaining the returnvalue datatype from the function, I know that I have some functions that explicity declare the datatype and do not follow the standard conventions of '$' and '#' for strings and floats. It's not hard to do, it just represents more tedious coding.

In the end I want to have wrapped LUA functions that the end users can call transparently as if they were actual commands. So instead of them having to type 'DBPro.Call("dbRotateObject",obj,xRot,yRot,zRot)' they'd use 'rotateObject(obj,xRot,yRot,zRot)', and a similar convention for regular functions.


Come see the WIP!
MSon
20
Years of Service
User Offline
Joined: 13th Jul 2004
Location: Earth, (I Think).
Posted: 10th Feb 2008 16:22 Edited at: 10th Feb 2008 16:47
This is Proberley a no, but is there any way to list all values which have been set?
IE: to list table and string values or to export them to a file?

Im looking for a way to moniter my setting as it would be easier to keep track of them this way, (like a log or debug option to throw them to a file)


That code above may look a little long, But its because my programmes Largeley Scripted so this is my settings file


Everyone Be Cool, You, Be Cool.
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 14th Feb 2008 21:02
Quote: "This is Proberley a no, but is there any way to list all values which have been set?
IE: to list table and string values or to export them to a file?
"

I dont know whether LUA allows to get a list of defined variables. My plugin does not keep a record. And also, it could not track assignments done within lua scripts. So yes, this is probably a no.

What you might want to do is to wrap the var setting into functions which also update your logging data.

Xlaydos
20
Years of Service
User Offline
Joined: 26th Mar 2004
Location:
Posted: 17th Feb 2008 17:41 Edited at: 17th Feb 2008 17:43
I am having problems with storing image paths into tables due to the '.' in the file type e.g .bmp. Lua seems to think i want to reference a table field .bmp such as table.blah.image1.bmp when i wish to reference table.blah.(image1.bmp).

Is there anyway around this or should i just parse every file name and replace the '.' with another ascii character e.g. image1~bmp.

Here is my code.


Lua file:


Maybe there is a better way to do this, as you probably already worked out, i am trying to code a system which checks if an image is already loaded by reading a table entry with the imagename in LUA. If the table entry is 0 then the image is loaded, else the table entry is the DBP image number.

Feel free to point out any awkward methods i use as well, i'm new to LUA.

Thanks a lot.
TechLord
21
Years of Service
User Offline
Joined: 19th Dec 2002
Location: TheGameDevStore.com
Posted: 18th Feb 2008 17:11 Edited at: 18th Feb 2008 17:14
Hi Barnski,

I want to sincerely thank you for this awesome plugin. I finally took the plunge into LUA. All the examples work fine, except for the "lua_functions.dbpro" example, which unfortunately crashes for unknown reason. Can anyone shed light on this issue?

I haven't altered the example code:



Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 22nd Feb 2008 19:49
@TechLord
You are welcome
Your posted code of the lua_functions example is old. Try to download the newest pack: v1.1.0_release.
The new example code works well here. Make sure it is executed in the "help/examples" folder, because it needs some media files and a lua file.

@Xlaydos
I would recommend to either replace the '.' with another sign as you mentioned (or remove it), or just not use the extension on your tablenames. I dont think there is a better way around this, because the access function takes every '.' as a table field seperator. Hope you get it to work.

Xlaydos
20
Years of Service
User Offline
Joined: 26th Mar 2004
Location:
Posted: 24th Feb 2008 01:13
Thanks for the reply... i've got it to work with changing all the table names to image1*bmp.

Thanks again
Xlaydos
20
Years of Service
User Offline
Joined: 26th Mar 2004
Location:
Posted: 1st Mar 2008 14:43
Is there anyway to get the problem to work on Vista? Everytime i use the "lua make" command it causes the program to stop responding

Thanks
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 5th Mar 2008 20:49 Edited at: 5th Mar 2008 20:50
jeffhuys
18
Years of Service
User Offline
Joined: 24th May 2006
Location: No cheesy line here.
Posted: 3rd Apr 2008 17:10 Edited at: 3rd Apr 2008 17:11
Hey Barnski!
At first: awesome plugin you got here, man! I can use it really well!
Secondly: I have a little problem:
You see, this code:


I'm putting variables from the LUA file in the program with this loop. But I want that "ad" can be a changing thing like this:



So in the file you would have:


But when I do that code, LUA gives the error: '=' expected near '.1'.

How is this possible with LUA?
Thank you very much!

Jeff


You're the 'th to view this signature!
Xlaydos
20
Years of Service
User Offline
Joined: 26th Mar 2004
Location:
Posted: 3rd Apr 2008 18:23 Edited at: 3rd Apr 2008 18:47
Sorry for the (very!) late reply!

Barnski, that kind of fixed it, It now works if i use "Lua Make 0", but will still crash if i use "Lua Make 1" or "Lua Make".

EDIT: The problem gets stranger... simple programs work fine, but when i try to run lua make with other commands in my code which aren't even being run, it still crashes. For example, in my current project, reming out this line

causes the program to compile fine, otherwise it will crash when the command "lua make 0" is called.

On an unrelated note, this code works fine:


However when the program ends i get popup saying "Dark Basic Pro has stopped responding, windows is searching for a solution to the problem message" instead of ending "cleanly" as it would if i did not use any lua commands.

@Jeffhuys I don't know if this is the best way, but i place a alphabetical character before anynumbers to stop that error e.g


I don't think lua likes having numbers at the start of variable names. Maybe barnski knows a better solution however...
jeffhuys
18
Years of Service
User Offline
Joined: 24th May 2006
Location: No cheesy line here.
Posted: 3rd Apr 2008 18:54
@Xlaydos:
Thanks, but I want it to be possible to call it from inside a FOR...NEXT loop... So a1 won't work... :/


You're the 'th to view this signature!
Xlaydos
20
Years of Service
User Offline
Joined: 26th Mar 2004
Location:
Posted: 3rd Apr 2008 19:04
I've fixed the problem fully barnski, i just downloaded your most recent version of the plugin... i feel silly now. Thanks again for your help anyway!

@Jeffhuys: Can't you just do this to call it

jeffhuys
18
Years of Service
User Offline
Joined: 24th May 2006
Location: No cheesy line here.
Posted: 3rd Apr 2008 20:26
Ah, thanks! That i did'nt think 'bout that Gonna give it a shot! Thank you!


You're the 'th to view this signature!
Xlaydos
20
Years of Service
User Offline
Joined: 26th Mar 2004
Location:
Posted: 4th Apr 2008 00:25
No problem, glad i could help
Xlaydos
20
Years of Service
User Offline
Joined: 26th Mar 2004
Location:
Posted: 4th Apr 2008 16:36 Edited at: 6th Apr 2008 20:35
EDIT: Problem solved, turns out it was due to vista and administrator problems, thanks anyway

What am i doing wrong here?



Gives the error "'model' is not a global string"

This is my villager.lua (i stripped it down and it still gives the same error)



Thanks
The admiral
22
Years of Service
User Offline
Joined: 29th Aug 2002
Location:
Posted: 19th Apr 2008 12:09
Im wondering how would I go about manipulating data in my typed arrays via a lua script?

The admiral
Xlaydos
20
Years of Service
User Offline
Joined: 26th Mar 2004
Location:
Posted: 19th Apr 2008 15:54 Edited at: 19th Apr 2008 15:55
Is there anyway around the limit of number of Lua Tables? At the moment it appears to be 32 (31?) and then it crashes, try this code to see if it happens for you to.



Edit: One way i have found is to create a parent table in which every table is stored like this.

Chenak
22
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 28th May 2008 18:15
How do I retrieve variables from within lua arrays with a numeric reference?

I have this for the table:

and this in the dbp code:

print str$(lua int("test.0.num"))

it only results in an error.

Cheers
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 22nd Jun 2008 08:18
Where's the DarkGDK thing? I'm sorry, I'm not skimming through 5 pages with limited time.

If you can do any models for FW, reply to the FleetWars thread.

Click here!
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 16th Jul 2008 17:44 Edited at: 16th Jul 2008 17:57
@Zuka,
check the webpage in my signature for the DarkGDK c++ library.

@Chenak & Cash-Curtis,
I have been working on this and can give you a dll version where you can access indexed fields like you wanted in your post:
lua int("test.1.num")
However, for it to work you need to explicitly give each entry in your table an index as you did in your example lua code:




There is a problem related with the text dll of DBP, whenever you use a string command in your project, the anonymously indexed elements of a table cannot be accessed anymore. Thats why you need to explicitly specify each elements index with [1]=...
I havent found a fix for this problem. So far I found out that directly after loading of a lua file the anonymously indexed fields are not accessible anymore if you include a string command in your dbp code.
But if you specify them by hand anyways, then it will work.

Attached you find the dll. I am not uploading it to my website yet because I am still hoping to solve the mentioned problem, maybe with new lua version or so.

Attachments

Login to view attachments
Chenak
22
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 16th Jul 2008 20:47
Thats fine, I think thats how you have to define numbered arrays in lua anyway. Awesome I'm going to attempt to implement it to my game and see if it works
Cash Curtis II
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 16th Jul 2008 22:11 Edited at: 16th Jul 2008 22:13
It sounds like there is no direct fix, but...

what if you parsed a workaround? For example, whenever the file is being loaded an parsed and it encountered an element with no index it created an index for it? So,
Quote: "
{
count=2,
{....},
{....}
}"


would be delivered to Lua as...
Quote: "
{
count=2,
[1]={....},
[2]={....}
}"


I don't know if you have that level of control during parsing, but if you do then it seems like it would work.

But, numbering them is completely acceptable, just not preferable. If it's not then I'll create a wrapper function for loading that does the same thing to a temporary file then loads it. Let me know what you think. If I do make that then I'll post it here.


Come see the WIP!
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 17th Jul 2008 03:06 Edited at: 17th Jul 2008 03:07
Problem fixed! Please test attached dll.

I downloaded the latest bugfix of lua version 5.1.3 and now it seems to work fine!
Cash Curtis; I also checked it with your initial source you sent me, and it works now also with the string commands in place.

Have a try!

If all is fine I will update help files and release new version.
Oh and I might add another cmd since I am on it

edit; fixed means that you dont have to explicitly index your table fields in the lua script and string commands wont make any problem!

Attachments

Login to view attachments
Aurum Knight
16
Years of Service
User Offline
Joined: 15th Jul 2008
Location: the suburbs of nowhere
Posted: 3rd Aug 2008 02:37
Hey Barnski, I bought Unity, but this is better

Do have a question though, does your dll load the lua base library? I can't seem to use the 'tonumber' function in lua

Login to post a reply

Server time is: 2024-11-21 17:42:02
Your offset time is: 2024-11-21 17:42:02