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
The admiral
21
Years of Service
User Offline
Joined: 29th Aug 2002
Location:
Posted: 6th Aug 2008 11:44
Is it possible to call the LUA REGISTER DLL from within a script thus adding additional functionality after a programme is released?

The admiral
Airslide
19
Years of Service
User Offline
Joined: 18th Oct 2004
Location: California
Posted: 8th Aug 2008 21:18
I'm having a little trouble calling a function that's part of a table.

Here's the lua file:



The idea is, I read in a 3D World Studio map, and when it comes across an entity, it calls <entityname> + ".OnSpawn". DBP Code:



I put a message command before that to make sure it was coming up with the correct names - it was coming up with "player.OnSpawn". However, it just returns an "attempt to call nil value" error. Is it not possible to call functions from within tables from DBP? I can do it in Lua itself just fine.

Aurum Knight
15
Years of Service
User Offline
Joined: 15th Jul 2008
Location: the suburbs of nowhere
Posted: 8th Aug 2008 21:58
@Airslide

I had that same problem, a while ago that I had forgot about; Apparently this plugin doesn't work when it comes to calling functions inside tables.

Here's what I did instead of using 'lua call function' for your case
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 11th Aug 2008 08:07 Edited at: 11th Aug 2008 08:09
Quote: "
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
"

lol, why is it better?
I remember taking out some of the base libraries when the plugin crashed for some people as it did help them. but now that things look different I will add them back in in the next release.

Quote: "
Is it possible to call the LUA REGISTER DLL from within a script thus adding additional functionality after a programme is released?
"

HmHmHm you can do that without having to call it from a script I guess. just writing dbpro code would be good enough I think. and maybe a config file.
Or do you actually want to prevent users from adding additional functionality? just by that its not possible to call it from lua I would say.

Quote: "
I'm having a little trouble calling a function that's part of a table.
"

Thats right, its not possible. I forgot to parse the parameter of the LUA PUSH FUNCTION for tables... Will do so in the next version and should be possible then. Till then you can also use the workaround proposed by Aurum Knight of course.

in one week my exams are over. figure have more time then...

edit; so far, the latest version is only downloadable from my previous post...

The admiral
21
Years of Service
User Offline
Joined: 29th Aug 2002
Location:
Posted: 11th Aug 2008 09:10
Well I dont want to recompile my exe all the time if i call it from a script then i gain access to new commands.

The admiral
Cash Curtis II
18
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 11th Aug 2008 17:08 Edited at: 11th Aug 2008 17:10
I'll be testing the DLL soon, I've been in the middle of something and didn't want to potentially break anything while it was still broken. I appreciate it!

Quote: "Well I dont want to recompile my exe all the time if i call it from a script then i gain access to new commands."

You can just have a global config variable in your Lua script indicate to the engine whether or not you'd like commands included.


Come see the WIP!
Chenak
21
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 15th Aug 2008 19:10
Is the update available for darkGDK?
TechLord
21
Years of Service
User Offline
Joined: 19th Dec 2002
Location: TheGameDevStore.com
Posted: 2nd Oct 2008 23:03
Barnski,

First, I want to say thank you for such an incredibly flexible, easy-to-use, and fast Scripting Language plugin. Second, I have a question about user defined functions and datatypes. I undersand that Functions made in Lua do not require datatype casting, however, it appears that its required for my user-defined functions with use of the plug in. I made some casting functions as a work-around, but, I'm not certain if there is a more efficient way to deal with this. Any insight would be greatly appreciated. Sincere Thanks.

Airslide
19
Years of Service
User Offline
Joined: 18th Oct 2004
Location: California
Posted: 9th Oct 2008 16:57 Edited at: 9th Oct 2008 17:35
Will you be fixing the issue with calling functions in a table soon? At the moment I'm being forced to use a number of workarounds, though proper support for this would make it significantly easier

EDIT: Hmm, it seems that I've stumbled across another problem. When attempting to use the load string suggestion above (Previously I had simply replaced the dot with an underdash, but now that I really need the fact that they are part of the table, that won't work anymore) it doesn't seem to fully accept strings that are essentially more than one line (like the entity data provided from a 3D WS map, ie: you print it to the screen and it shows up as more than one line) It just replaces the point where it skips to the next line with "...".

Of course, if you get table functions to work with push function, this won't be an issue

Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 22nd Oct 2008 00:41 Edited at: 22nd Oct 2008 13:13
New Update available: v1.1.1 (plugin & c++ lib)

new: updated to lua 5.1.3 -> some crash fixes!
fix: you can now properly access indexed table field, ie. table.1
fix: you can now call functions stored in table fields, ie. table.func
fix: memory leak from last unofficial release.

the update is for the dbp plugin and the dgdk/c++ library.
for dbp its release dll, for c++ its debug library.

the downloads are available from my plugin site as usual, see signature.

sry for the long wait, I was making holidays in India


@Chenak
yes, the update is now available also for dgdk!

@Airslide
problems should be fixed. report if your happy

@Techlord
Please show some code so I can better understand what you want to do. What datatypes do you need to cast? you should actually be able to directly use most common datatypes...


greetz,
barnski

Airslide
19
Years of Service
User Offline
Joined: 18th Oct 2004
Location: California
Posted: 22nd Oct 2008 05:50
Excellent! Superb job Barnski This plugin is the core of my game.

Just so others know - this update seems to fix a memory leak in my game which I was witnessing previously (of course, I may have just changed something without realizing it, but I don't think so ). I'm assuming it's the new version of LUA.

Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 22nd Oct 2008 13:11
I indeed fixed a memory leak in this update, but I thought I introduced it only in the last unofficial version which I posted in a post earlier only. I allocated a char buffer to print out debug messages to fix the indexed access of table fields, and while I removed the debug output, I forgot in the last unofficial release to remove that buffer allocation.

But the last official release should not have had memory leakage as I do test for that (although you cant ever be 100% sure of course).

Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 22nd Oct 2008 13:22 Edited at: 22nd Oct 2008 13:40
Oh I forgot to mention about the lua library calls that I make as previously someone requested the base library to be included:

I now include (in v1.1.1) following additional lua libraries using these calls:

luaopen_base(L);
luaopen_string(L);
luaopen_math(L);
luaopen_table(L);

NOT included are:
//luaopen_io(L);
//luaopen_package(L);

These latter libraries caused some crash problems in previous versions. Maybe it was fixed in 5.1.3. But I dont think they are very important anyways, unless someone thinks otherwise..!

Airslide
19
Years of Service
User Offline
Joined: 18th Oct 2004
Location: California
Posted: 6th Dec 2008 04:28
I seem to be having a problem - forgive me if I'm being a moron and missing something obvious, but this crashes the game with a standard windows error:



Using GetDir instead of GetDir$ returns a lua error saying it couldn't find the command, but with the $ it crashes. Am I missing anything?

KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 13th Jan 2009 00:14
Would,

return DBPro.Call("GetDir$()")

make any difference?

Airslide
19
Years of Service
User Offline
Joined: 18th Oct 2004
Location: California
Posted: 14th Jan 2009 15:43
Unfortunately that returns the command-does-not-exist error, which I expected as other commands are called without the parentheses.

BayOfXyz
15
Years of Service
User Offline
Joined: 25th May 2008
Location:
Posted: 18th Jan 2009 13:13
Why I can't use "register_user_function" to register my function in DarkGDK version when I used it my program was crash.
Syncaidius
19
Years of Service
User Offline
Joined: 22nd Mar 2005
Location: United Kingdom
Posted: 18th Mar 2009 12:07 Edited at: 18th Mar 2009 14:45
Really nice LUA plugin Barnski. It's been working perfectly for me since I switched from coolgames LUA plugin.

EDIT:
Is there any chance that you can make it so you don't have to call DBPro.Call() or DBPro.CallEx to call a user function from a lua script. I've got used to using coolgames' Lua plugin and I liked the way he registered a user function and it worked without needing to do anything like DBPro.Call().

For Example, with your plugin I have to do DBPro.Call("my Function", parameter, parameter, ..., etc). With coolgames' plugin could call it like myFunction(Parameter, Parameter, ..., etc)

Being able to do that with yours for user functions would be really really nice.

Airslide
19
Years of Service
User Offline
Joined: 18th Oct 2004
Location: California
Posted: 19th Mar 2009 01:02
I usually wrap commands...ex:



This has advantages. For example, I simulate Vectors in LUA by making tables with x,y, and z values. I can pass that table to the function and it will take the x/y/z values and pass them individually to the function.

Aurum Knight
15
Years of Service
User Offline
Joined: 15th Jul 2008
Location: the suburbs of nowhere
Posted: 31st Mar 2009 02:07
Hey Barnski. Thanks for adding in those libraries =D I know I'm kind of late, I had thought I replied, but apparently I didn't =S

I've had some weird problems with numbers in your plugin lately.

Whenever i tried to call d3d_rgba from cloggy's d3dfunc, it didn't take the paramenters right. It seems to be rounding it to either 255 or 0. I tried making my own rgba function, but it did almost the same thing.

here's the rgba function:


Try using it on something like 200 or 120. Unlike on the d3d_rgba function, for some reason, if you put in all four values 255, it returns 0. I tried to fix this by subtracting one from self.color in the function, but for some odd reason, it wont subtract that from it o.O

This is really weird...
Airslide
19
Years of Service
User Offline
Joined: 18th Oct 2004
Location: California
Posted: 31st Mar 2009 07:25
I noticed you define the function as f:rgba. Are you calling it as f.rgba? If so, your first parameter will become self. That *could* have something to do with your problem, but you've probably thought of that.

Aurum Knight
15
Years of Service
User Offline
Joined: 15th Jul 2008
Location: the suburbs of nowhere
Posted: 3rd Apr 2009 01:18
Yea, I know to use the ":". It's the same thing when i call cloggys DLL's rgba from there. I don't get what the problem is with doing simple math
Airslide
19
Years of Service
User Offline
Joined: 18th Oct 2004
Location: California
Posted: 3rd Apr 2009 16:47
Try separating the equation with parenthesis to make sure it is doing it in the right order. That's the only other thing I can think of.

MayoZebraHat 1979
16
Years of Service
User Offline
Joined: 21st Dec 2007
Location:
Posted: 2nd May 2009 09:37 Edited at: 3rd May 2009 08:56
I'm trying to use "Lua Call Function" and it's returning a "could not understand command" error. I'm using it like this:

Lua Push Function "bob"
Lua Call Function( 0, 0 )

I'm not sure what's wrong but I did look at the string tables of the dll and noticed that the parameters needed are %LLL% and not %LL% two integers as the help file would lead me to think. Of course putting 3 integers in instead doesn't fix this.

Nevermind... I have to use variable = lua call function...
Sorry.
Geddon00
18
Years of Service
User Offline
Joined: 9th Nov 2005
Location: USA
Posted: 4th May 2009 07:51 Edited at: 4th May 2009 08:13
Can anybody tell me if there is anything wrong with this code? The DB code creates a bug in my program. I am sure there is nothing wrong with the lua code in "mine.cfg".

Lua:
Script={
"Scripts/Bullets/mine.cfg"
}

DB:
lua load file lua string$("Script[1]")

Edit: Nvm, it works if you use "Script.1" instead of "Script[1]"

Your signature has been erased by a mod for being too cool
TechLord
21
Years of Service
User Offline
Joined: 19th Dec 2002
Location: TheGameDevStore.com
Posted: 5th May 2009 07:25 Edited at: 5th May 2009 10:05
U73 broke Barnski's Lua5.1 Plugin v1.1.1. Compiles fine, but exe crashes when ran. Unfortnately, this is a show stopper for me. Just curious if anyone else had trouble/fix with U73 & Barnski's Lua5.1 Plugin before I attempt downgrade DBP.

Aurum Knight
15
Years of Service
User Offline
Joined: 15th Jul 2008
Location: the suburbs of nowhere
Posted: 9th May 2009 17:50
I think I might have found where the problem is. I tried my rgba function only returning the red, green, and blue, and it worked fine, with blue have a value of 124. But as soon as I added the alpha, the rounding thing started again, and the blue went back to 0.

I still can't figure out why though... I figure it's something to do with the number being too big...
jeffhuys
17
Years of Service
User Offline
Joined: 24th May 2006
Location: No cheesy line here.
Posted: 10th May 2009 19:14
I get an error on your site: 403 Forbidden >.<



You're the 'th to view this signature!
Not_Maindric
16
Years of Service
User Offline
Joined: 10th Jul 2007
Location: Omaha, NE
Posted: 10th May 2009 22:18 Edited at: 12th May 2009 06:43
I am getting the same error as jeffhuys, forbidden..

~~

Ok, problem fixed.

cyangamer
15
Years of Service
User Offline
Joined: 2nd Jun 2008
Location: Houston, TX, USA
Posted: 22nd May 2009 23:58
How do you "push" and "pop" tables to/from the stack? It'd be nice if I could call a function with just one argument and returning one argument as opposed to ten.

Currently working on - Enemy AI using Dark A.I. I probably should've looked at the reviews in the Dark Physics and Dark A.I. forum first.
MonoCoder
18
Years of Service
User Offline
Joined: 4th Dec 2005
Location: england
Posted: 14th Jun 2009 02:40 Edited at: 15th Jun 2009 01:52
Been using Unity for my gui project until one day I noticed simple actions caused the program's memory usage to suddenly and uncontrollably begin rising. So today I've switched over (or yesterday anyway) and so far so good. However I've a few queries:

• I can't access index 0 of my tables anymore (ie. lua string$("DRAW.0.DrawType") won't work). I could before; should I change things to start at 1 instead or is this something needing fixing?
• I used Unity's message queue to pass values from LUA to DBPRO as it was far faster than reading out of the tables DBPRO side. Is there some kind of equivalent here, or how else could I get some speed back?
• All my variables are declared inside a function. Unity was happy with this, but this plugin says they are not global (ie. "ENTRY is not a global string"). Rework or is there a way to global-ise them? I thought they were all global unless otherwise stated. :S

Other than that, liking it so far.



Edit: Done a bit of research. Still not sure about table index 0's, but otherwise:

• Will switch to directly calling the DBPRO drawing functions from LUA in absence of the message queue. I imagine this will be even faster than it was before.
• My string-not-global problem stemmed from this DBPRO line,
Interestingly, everything has been fixed with
So question is, is this a DBPRO or a LUA bug?


Ta!



Edit 2: Another problem, related to the last. This lua code:
would crash the program once I started deleting objects from my GUI. I changed it to this:
but the problem persisted. Then on a whim I changed it to this:
and once again, that empty string addition has solved it. How, I have no clue. I'm guessing an oversight in parsing or some'etes?


Additional Ta!

Spiteful Eye WIP. Go on, it's fun sort of.
Diggsey
17
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 16th Jun 2009 00:52
The entry problem is because DBPro returns a NULL string when nothing has been typed in, rather than an empty string. Concatenating the empty string causes it to become non-null.

MonoCoder
18
Years of Service
User Offline
Joined: 4th Dec 2005
Location: england
Posted: 16th Jun 2009 01:19 Edited at: 24th Jun 2009 15:15
Now I look like a presumptuous idiot. >_> Future generations will look back at my post and laugh.


Ta for insight


edit: I don't suppose you have an idea what's up with table index 0 referencing? <_<
works but
gives "invalid table-access string: 0.Class".


edit: Here's a better example...


CuCuMBeR
21
Years of Service
User Offline
Joined: 11th Jan 2003
Location: Turkey
Posted: 24th Jun 2009 15:49
Lua set int command doesnt seem to set the variable value neither in the lua script nor in the lua environment, anytime i do this, it gives an error like "variable is not a number".

any solutions?

There is always one more imbecile than you counted on.
MonoCoder
18
Years of Service
User Offline
Joined: 4th Dec 2005
Location: england
Posted: 24th Jun 2009 16:19
Does this work? Only the second one should give an error.



CuCuMBeR
21
Years of Service
User Offline
Joined: 11th Jan 2003
Location: Turkey
Posted: 24th Jun 2009 17:41 Edited at: 24th Jun 2009 17:43
your code works as how you said.

But when i do it with loading a lua file, it just doesnt work unless i define the f1Key value inside the lua file as well.

Dbpro code:


Lua file Code:


There is always one more imbecile than you counted on.
MonoCoder
18
Years of Service
User Offline
Joined: 4th Dec 2005
Location: england
Posted: 24th Jun 2009 18:11 Edited at: 24th Jun 2009 18:19
You're loading the script first, and the script is executed immediately. Variable f1Key has to exist when the assignment involving it is performed, otherwise it won't work. You might be assuming it will constantly enforce that assignment..? (It won't btw )

To clarify, this will give Debug as 0 and f1Key as 59: DBP:

LUA:


As will this: DBP:

LUA:


This will give both as 59: DBP:

LUA:


And so will this: DBP:

LUA:



(Unless I've completely missed your point )

CuCuMBeR
21
Years of Service
User Offline
Joined: 11th Jan 2003
Location: Turkey
Posted: 25th Jun 2009 10:27
I see, the last one was what i wanted. Well, im new to this LUA thing.

Which is the best plugin by the way? Barnsky, coolgames or unity?

and where can i learn more about lua language?
Can we do loops in lua? if else statements?
how do i make a mmo?

There is always one more imbecile than you counted on.
MonoCoder
18
Years of Service
User Offline
Joined: 4th Dec 2005
Location: england
Posted: 25th Jun 2009 15:36 Edited at: 25th Jun 2009 15:37
More about lua - Manual, and some additional help.

Loops and if/else - DBP (play with the values of the variables):


LUA (call it "cake.lua"):


Also shows how to call DBPro commands, a useful thing.

Best Plugin - haven't tried coolgames', but otherwise: Unity costs, can't use dbpro commands, and was also susceptible to memory leaks. Thus far, Barnski's has been, well, the opposite.

Airslide
19
Years of Service
User Offline
Joined: 18th Oct 2004
Location: California
Posted: 27th Jun 2009 19:58
For those who are interested in setting up object classes:
http://lua-users.org/wiki/LuaClassesWithMetatable

It may be a little hard to understand at first but it has been invaluable to me - it made me realize that my existing system was causing too much duplication of data. This lets you treat tables like objects, and even change things like how they are added to each other. For example, here's my test code that I used while figuring this all out:



This means that you can setup vectors in LUA and add them together. You can also add the subtraction/multiplication/division etc. functions yourself.

I highly recommend this approach, it makes life much easier and shows how flexible LUA is. I'm using this technique for many aspects of my engine - vectors, entities, etc.

CuCuMBeR
21
Years of Service
User Offline
Joined: 11th Jan 2003
Location: Turkey
Posted: 30th Jun 2009 14:25
I dont know if this have been asked before, but i dont want to go over whole 6 pages or the whole forum for the answer.

How do i write the actual variable value in lua environment to a lua file?

like i set an integer from dbpro and i have a lua file open meanwhile, and i want to write this set integer value to the actual file. Do i need to use dbpro write commands or is it possible with lua plugin itself?

There is always one more imbecile than you counted on.
MonoCoder
18
Years of Service
User Offline
Joined: 4th Dec 2005
Location: england
Posted: 30th Jun 2009 16:11 Edited at: 30th Jun 2009 16:14
You'll need to use the DBPro file commands for it. There might be a way to automatically go through every item of data in the lua environment to save (you can definitely use "for key, value in pairs(tablename) do" to go through each index in a table). It's usually ideal though to keep track of your data and systematically run through each "set" of data to save.

Example: LUA:


DBPro:


This will read the variables A, B, and C from LUA and write a new script for it. If before you save you change A to Dog, and double B and C, you get example.lua as:


(Not tested, but it should work. C might come out slightly differently being a float, but I wouldn't have thought so).

edit: I'm not entirely sure of this, but there may be some io commands in the plugin, but you'll have to consult the manuals for that as I've not yet used it.

CuCuMBeR
21
Years of Service
User Offline
Joined: 11th Jan 2003
Location: Turkey
Posted: 30th Jun 2009 16:59
eh, too much work. Ill use ini plugin to write stuff. Its just simple variables anyways.

Thanks anyways.

There is always one more imbecile than you counted on.
CuCuMBeR
21
Years of Service
User Offline
Joined: 11th Jan 2003
Location: Turkey
Posted: 8th Jul 2009 14:12
is it possible to write dbpro code in a lua file and call the whole thing from dbpro?
like;

dbpro:


lua:


or, does the for next and such stuff has to be written as lua code?

There is always one more imbecile than you counted on.
MonoCoder
18
Years of Service
User Offline
Joined: 4th Dec 2005
Location: england
Posted: 8th Jul 2009 15:27
Your DB code would have to look like this:


and your lua code like this:



So yes, anything on the lua side has to be written as lua code. You could make it do it in DB code, DB side with something along these lines:


and this lua code:




CuCuMBeR
21
Years of Service
User Offline
Joined: 11th Jan 2003
Location: Turkey
Posted: 8th Jul 2009 15:54
i see. Thanks, the first one will do fine in my case.

There is always one more imbecile than you counted on.
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 10th Jul 2009 01:47
Before I do any actual work with LUA, I have a question. I'm working on a 2D game framework ATM. Currently it requires the entire game to be written in DBP. However I was curious as to whether or not this would be possible with LUA instead, so I have a couple questions:

1. Is it possible to have more than one LUA script loaded simultaneously?

2. Is it possible to store functions in tables?

i like orange
MonoCoder
18
Years of Service
User Offline
Joined: 4th Dec 2005
Location: england
Posted: 10th Jul 2009 02:09 Edited at: 10th Jul 2009 02:15
1. Aye. They all get poured into the same lua "environment", so it's a little like piecing together one big script a bit at a time.

2. Yes. I haven't even tried that myself yet until now. :S
functable.lua:


dbpro code:


The table t has a field/property/whatever called MyFunction that is a function that takes two variables and returns their product (here, 20). To call it just give the function's name (t.MyFunction) and it's parameters in brackets just as usual. Note that while you can do this:



as far as I'm aware you can't do this:



That is, you can't put it straight into the table as you can with normal variables, but must add it afterwards (as in the first code snippet).

AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 10th Jul 2009 02:24 Edited at: 10th Jul 2009 02:27
Thanks. I've got one more question. Is there a way to check if a field exists in a table? When evaluating the script file for values I have no way of telling if a user did or didn't enter a value into the LUA script, and os if he didn't I get a 'nil' error. If it's not possible to check if a field is valid, can I disable error message boxes?

EDIT:

Never mind, I've worked out a different solution.

i like orange
MonoCoder
18
Years of Service
User Offline
Joined: 4th Dec 2005
Location: england
Posted: 10th Jul 2009 02:29 Edited at: 10th Jul 2009 02:31
To check if a field in a table exists, say field "EnteredValue" in table "UserInput", just see if it equates to nil:



"~=" equates to DBPro's "<>".

edit: ah ok.

Login to post a reply

Server time is: 2024-03-29 11:43:24
Your offset time is: 2024-03-29 11:43:24