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.

DarkBASIC Professional Discussion / Dynamic Database plugin for DBPro (or RPG) - what's the best and why?

Author
Message
Duffer
23
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 27th Oct 2012 12:42
what is your view and why?

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 27th Oct 2012 13:22
I've never used one, why would you need one?

TheComet

- The codebase
Duffer
23
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 27th Oct 2012 13:30
@ TheComet,

Thanks for getting back so quickly.

I suppose I should explain that all I mean by "Dynamic Database" is a very quick and flexible one into which you can edit/change values.

One that the main program can access quickly to say in an RPG Game gather atttributes, attribute values, I dunno, weapon types, their attributes etc etc.

To sort of answer my own question, the most flexible and quickest I've come across is Kaedroho's XML plugin - but is there something even faster????

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 27th Oct 2012 19:45
Ah, I see.

The XML plugin I'm not familiar with, but a lot of games use it these days, so it's probably a good option to go with.

If you want a quick and dirty method, you can just use DBP's file read/write commands to save things like that.

TheComet

- The codebase
Dar13
18
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 28th Oct 2012 00:36
I second the use of XML, though I'm not sure about Kaedroho's plugin(I've only interacted with XML in C++). The best way to use XML is to model it based on your data structures(UDTs in DBP) so that it's easier to transfer between the two mediums. Also, the writing/parsing/saving to hard disk of XML can be time-consuming so try to avoid it at all costs.

Chenak
23
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 28th Oct 2012 14:06
LUA is the best in my opinion, it has brilliant table manipulation options which are perfect for RPGs and with some clever programming you can implement classes. I'm not sure about the performance costs but I haven't noticed anything
Duffer
23
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 28th Oct 2012 20:30
thanks all - moving towards writing my own databases based upon udts, arrays and Matrix plugin from IanM...

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
The Weeping Corpse
14
Years of Service
User Offline
Joined: 19th Sep 2011
Location: United Kingdom
Posted: 28th Oct 2012 21:06
Ah, flatfile databases, takes me back to the days of GWBASIC, BASICA and Turbo BASIC.

If you use UDTs then make sure to define reserved fields from the get go, for example:



The reserved fields will allow you to add new members into an existing database file by renaming a reserved field...



otherwise, you will have to delete any existing database files before adding new members, because the structure of the records on disk will change.

Duffer
23
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 9th Nov 2012 15:27
@ The Weeping Corpse,

Thanks for the response and the very good pointer re reserved fields...

I'm now wondering also about use of LUA - but I see that you cannot write back to a new / revised LUA file with changed or further table/array items etc.... which gets me thinking about writing my own more flexible array/udt based solution with array sorting and Martix1 datafile saving of complex arrays??

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 9th Nov 2012 16:18
I started writing a MySQL plugin for DBP but having problems with Visual Studio not connecting to libraries, probably cos I do most of my stuff on Linux now. I'll try and get around to getting it working again. MySQL will allow you to connect to a database on your computer or on the web when you're ready to put it online and is very useful too...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Duffer
23
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 9th Nov 2012 19:19
Hi WLGfx,

I've tinkered around with MySQL. It's the flexibility I like about LUA. But the drawback (in DBPro) is you can't save back additions/amendments to a LUA file.

XML is great but a nightmare working your way in and out of the right nodes/elements to get to the value you want.

DarkDATA is confusing with all the iterations of KFS etc.

LookupTables and INI are ok, but not flexible enough.

Say you wanted to look up Items.Weapons.Swords.Claymore.PrimaryDamage (for instance, if you see what I mean) or then also add a Items.Weapons.Swords.Claymore.SecondaryDamage back....

Lua gets half way there...

Hope that is making some kind of sense?

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Chenak
23
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 9th Nov 2012 19:51
Quote: "I'm now wondering also about use of LUA - but I see that you cannot write back to a new / revised LUA file with changed or further table/array items etc.... which gets me thinking about writing my own more flexible array/udt based solution with array sorting and Martix1 datafile saving of complex arrays??"


Yes you can, why can't you? You just use the Write commands to create a new lua file, as long as you structure it correctly its fine. You don't need to do it too often in runtime either so it should be fine.

If you are making an RPG, trust me LUA is perfect, the only thing I'm not sure about is its performance with lots of data, but currently I have no issue with it.
Duffer
23
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 9th Nov 2012 19:54
Hi Chenak,

Are you talking about basic open to write commands and writing in strings in correct LUA format? or are there some commands (in Unity Lua) to write back out a LUA file (with additions/changes)???

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 9th Nov 2012 20:35 Edited at: 9th Nov 2012 20:40
Quote: "Are you talking about basic open to write commands and writing in strings in correct LUA format?"


I'd say yes!

Anything you can do with a string variable, you can do with LUA; XML, MySQL, INI, CSV, BBCode, command lines; any string based file format can have their structure and content copied, amended and saved.

Personally, I do not rely on LUA or XML; or MySQL or INI; on their own. I use them all!

I see them as enhancement tools not replacement tools; some are good for settings, others are good for logic. You can put LUA in XML, XML in MySQL, MySQL in INI, INI in Lua, Lua in arrays, arrays in memblocks, memblocks in net packets; they all just text that your system interprets as what you want.

I'd say that XML is good for relational information. LUA is good for logic and high level scripting. INI is good for settings. MySQL is good for storage and data management. CSV is good for storing function parameters and object properties. Hard coded arrays are quick access and security. Memblocks and membanks are good for network interchange.

So use what is best for given situations. If you are making an online game, then do not forget that PHP, ASP and other server side scripts are strings that can be created and transmitted by DBPRO.

Chenak
23
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 9th Nov 2012 20:52
Quote: "Are you talking about basic open to write commands and writing in strings in correct LUA format? or are there some commands (in Unity Lua) to write back out a LUA file (with additions/changes)???"


Yup just the standard dbpro write commands, as long as you write in a way that a normal lua file will understand it will be fine. Personally I would use Barnskis LUA plugin as it has better features and seems to work nicer. Main feature of course being using Ians Matrix dlls you can forward any function from dbpro into LUA Any help let me know as LUA is a key part of my project at the moment
Seppuku Arts
Moderator
21
Years of Service
User Offline
Joined: 18th Aug 2004
Location: Cambridgeshire, England
Posted: 9th Nov 2012 23:00
The 3 system I would make a choice out of would be:

LUA (Barnski's is free as mentioned)
XML
Dark Data


I've used all 3 and all 3 are good for creating databases. I am currently using XML for my RPG in Dark GDK.NET, but I have used LUA and Dark Data before. Dark Data uses a Key File System and it reminds me of Microsoft Access databases a bit. It looks a bit complicated, but it's easy when you understand how DD works.
LUA on the other hand, is actually pretty simple and easy to integrate and is pretty friendly to folks who aren't familiar with it.

GregA
15
Years of Service
User Offline
Joined: 21st Jun 2011
Location:
Posted: 9th Nov 2012 23:39
I am gonna go with... just hard code it into your game in a UDT array. There you go, the whole thing is in an easy to read and understand text file. You don't have an extraneous file to keep track of.

I mean, what are we talking about here??? A table describing a bunch of items. Maybe a table of characters... Your item list is not going to change.

You shouldn't have need of lookup functions, other than by index...

Things are not gonna change much...

Just make a fixup file that alters where things are... Like if your characters move around, or what not, their status...

Then when this text file gets unmanageable, and you want to use something like access to tinker with it, just make a report that outputs your text/source file that describes all your people, and items.

Make your characters ADTD flat, dont mess with relational here.

DBPro seems really big on integer indexes...
MadBit
VIP Member
Gold Codemaster
17
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 9th Nov 2012 23:55
For XML you can take a look to my XML wrapper for DBPro. might be helpful. (maybe)

http://forum.thegamecreators.com/?m=forum_view&t=188265&b=5

With Computers you can solve Problems that you have never befor.
Share your knowledge. It's a way to achieve immortality. (Tenzin Gyatso)
Duffer
23
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 10th Nov 2012 00:33 Edited at: 10th Nov 2012 00:42
@ All,

Thanks for all your advices. Appreciated.

I think what Chenak is saying is I can use conventional read/write file commands in DBPro to record changes to a lua (uncompiled) file and (on it's face) the LUA file is damn easy and accessible.

Check this fairly ancient link:-

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

That example of a LUA script RPG table is [extremely] simplistic compared to what I am contemplating, sadly. But, conceivably, one item->weapon->sword->claymore could have ->excludedclasses and one other type of sword might not, and so on and so on (if I can be bothered by then!). At least, neater to look at. And maybe I can even find a slightly more user friendly way to parse and junk the data in to the LUA file tables....

I've done the UDT / Array thing as well, semi-node-like, sorting by ID, NodeTree and Node, and it works v well, and with a raft of types, but I keep finding I need to add user defined types. Hence the very good idea of having to reserve some udt fields for future expansion etc etc. Hell, you do not want to know how many UDTs I've thrown on the elements on an array. Then you come to write all the functions to get at the values attached to those UDTs. At that point, you reach for the shotgun and bottle of whisky. For this, I think it's just too be too cumbersome and chunky for me.... I know, coward.

DD is really very good. But it's inaccessible (in terms of lines of code in DBPro) and rather unwieldy for this.

I've used your XML plugin Madbit (and used Kaedroho's one as well). They are both excellent. What I find unwieldy (but can do) is the climbing down in to the sub-elements/nodes (for values) and climbing back up.... So XML is great for other things, and if I were about 20 percentiles smarter I'd probably have little difficulty with using XML for this (as have others) - but again the LUA file is just so damned simple to look at. (IF I can code something to re-write and write in to LUA files...).

I am going with LUA (with my own functions to re-write the LUA files). Thanks again all - and wish me luck....

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Duffer
23
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 10th Nov 2012 11:24 Edited at: 10th Nov 2012 13:16
Some more questions...

In this code


If I were designing a fresh lua file and writing from within DBPro, can I just use the Tab (chr$(9)) once, twice or three times etc to get the structure on each line you see above? Does it make a difference?

Also, could the following also be valid LUA script (for tables)?-



(and again, believe me, my script is going to be a helluva lot more complicated than this.... )

Also, I have Unity LUA (which seems newer, but...). Is Barnski's LUA plugin better or Unity or are they pretty much similar?

[edit]
Sorry about these questions - just dawning on me how very much I've been making my life difficult in programming in the past....

[edit]
P.S. I also get Chris Tate's point about horses for courses ie. perhaps a different combination might be better depending on the use of the database. I am not planning a multi player - just a traditional (and almost certainly 2D) CRPG...

[edit] - I had some further questions - but have figured them out! Should have been using LUA ARRAY commands... Doh!

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Duffer
23
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 10th Nov 2012 13:10 Edited at: 10th Nov 2012 13:18
[edit] sorry now figured out my own answer to this post...

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 10th Nov 2012 16:05
Quote: "just hard code it into your game in a UDT array"


I would have said this a few years ago; but after about 50,000 lines, having to re-compile for 10 minutes to change the walking speed of a hamster and to adjust the brightness of a certain light to stop yourself falling through that dark hole every so often, you really do end up with that
Quote: "bottle of whisky"


However, UDTs all the way for the really low level stuff; LUA is too slow for things like dealling with vertices, particle effects and drawing pixels; but that's obvious.

Duffer
23
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 10th Nov 2012 16:36
@ Chris Tate,

Thanks - I am beginning to understand. And I can always take data I entered on a LUA file and parse it in to something more appropriate.

On thing I am struggling one - how do I know how many items are in an array?

If I had an array of 'list' within weapons within items and I wanted to loop down through it pulling the items in the list, how would I know where to stop?

I've noted that if I try and pull a value from say #10 when there are only 9 items in the array Unity LUA crashes...?

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Chenak
23
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 10th Nov 2012 23:11
A bit difficult to answer this one as I use barnskis lua plugin which I would really recommend as it is easier to use and nicer functions. I remember trying unity and finding it a bit difficult to achieve what I wanted. The main feature you will find lacking is the ability to call functions you want within LUA.

Luckily your current problem is relatively easy to solve in lua, you simply need to iterate through the array:

for e in ipairs(players)
do
text(players[e].stuff)
end


However, if you just need the amount of items in the lua table, in lua do this:

playersCount = table.getn(players)

and it will give you the right number, hope this helps
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 10th Nov 2012 23:47
As Chenak says, just get the table length. You will not crash your program if you do not allow it to exceed the length, so don't panic.

Duffer
23
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 11th Nov 2012 00:15 Edited at: 11th Nov 2012 00:17
@ Chenak & Chris Tate,

I (sort of) get the in-Lua script to get the size of the table - but how do I get at that information from within DBPro (ie. how do I get the size of the table in the LUA script but within DBPro with DBPro code) when I have loaded in the LUA file???

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 11th Nov 2012 00:33
Perhaps Chenak will know what the best method is. I can't remember the official way to do it with Barnskis plugin .

But generally you can execute the lua equivillent in a string of what you need to do, then query the result stored in a lua variable. You could use a LUA function as an iterator or you can call a DBPRO function from LUA, for every array element; send the details to DBPRO through parameters.

Chenak
23
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 11th Nov 2012 00:46 Edited at: 11th Nov 2012 00:50
Not sure with unity, in barnskis use the command: retval=lua int(variable) which will simply grab any variable present globally within LUA. I'm sure there is a similar command in unity.

I would try and keep lua and dbpro separate in certain ways. In my project currently I have DBPro doing mostly just rendering and lua handling logic.
Duffer
23
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 11th Nov 2012 10:19
@ Chenak & Chris Tate,

Thanks both. I will now go away and 'cogitate'...

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...

Login to post a reply

Server time is: 2026-07-10 09:47:24
Your offset time is: 2026-07-10 09:47:24