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
CuCuMBeR
16
Years of Service
User Offline
Joined: 11th Jan 2003
Location: Turkey
Posted: 10th Jul 2009 11:18
I have 2 questions about different lua files also.

1-when i do the below, does variable "a" in second file overwrite the value of "a" in first file? and what about the string in 3rd file, does it overwrite the first and second "a" variable?

dbpro:
lua make
load first lua file and do something
load second lua file and do something else
load third lua file and do something else
lua end

1st lua file:
a = 1

2nd lua file:
a = 2

3rd lua file:
a = "some string"

2- when i do the above thing with dofile() and include 2nd and 3rd in 1st file, does that give an error? or just overwrites the variables?

There is always one more imbecile than you counted on.
MonoCoder
13
Years of Service
User Offline
Joined: 4th Dec 2005
Location: england
Posted: 10th Jul 2009 13:23 Edited at: 10th Jul 2009 13:27
If you have "a = 1" in your first file and "a = 2" in your second file, and were to load them one after the other, it would be exactly the same as having just one file that said "a = 1; a = 2". It's not that it overwrites per se, but that it simply assigns it the new value. If you have changed the value between loading one file and the next, it will still be assigned the value specified in the second file when it is loaded. On a side-note, if you have "a = a + 10" in your second file, that will also work (ie. it won't wipe away your existing a value leaving you with a nil and an error, but it will assign it the value of itself plus ten). Your best bet is to think of loading another file as just running a function. Every reload would be another "call".

I've not used dofile before, but I gave it a brief look-at, and it should work the same. I think there was something about it's error messages and stuff though compared to loadfile. This page should tell you what you need to know.

AndrewT
12
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 10th Jul 2009 17:01 Edited at: 10th Jul 2009 17:23
Woohoo! Thanks for the help Mono, this is going really well. Now I can design an entire 2D game with a set of simple LUA files.

I'll be sure to post back if I have any more questions.

EDIT:

Ok, I've got yet another question. Is there any way to find out if a value is nil, but from DBP? The thing is, I have no way of controlling which properties the user chooses to set in a LUA file, and so if I try to access a property that isn't set I get an error message saying it's nil. So is there any way to either disable the error message or find out if a value exists in a file?

i like orange
MonoCoder
13
Years of Service
User Offline
Joined: 4th Dec 2005
Location: england
Posted: 10th Jul 2009 17:46 Edited at: 10th Jul 2009 17:54
Here's one way of doing it: DBPRO:


LUA:


This will check to see if t.x is nil. The function returns 1 if so and 0 if not, and a message is printed. Add
at the top of the lua script to see it change.

As far as I can see you can't do this using the standard "lua push function", "lua pop int", etc. commands as you can't pass a reference to a lua variable into a lua function.

AndrewT
12
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 10th Jul 2009 18:03
Thanks!

i like orange
Duffer
16
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 10th Jul 2009 20:09
for me, a command that allowed you to save out the lua script as a file when you'd made changes to data / arrays within - now that would be damn fine...

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
wickedly kick it
13
Years of Service
User Offline
Joined: 13th Jul 2006
Location: Fort-worth Texas
Posted: 2nd Aug 2009 05:04
Planning on making this compatible with DGDK?

Duffer
16
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 2nd Aug 2009 12:21
ping - any chance of my suggested saving out lua file commands - incorporating variable/data/array changes made ?

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
BMacZero
13
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ N_America/ USA/ CA/ South
Posted: 12th Aug 2009 04:00
Quote: "Planning on making this compatible with DGDK? "

It is.



zapakitul
12
Years of Service
User Offline
Joined: 1st Mar 2007
Location: In my world
Posted: 12th Aug 2009 16:06
^Yeah, but only in debug mode :\
BMacZero
13
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ N_America/ USA/ CA/ South
Posted: 12th Aug 2009 16:43
Ah...



Chenak
16
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 22nd Aug 2009 17:36 Edited at: 22nd Aug 2009 20:12
I can't seem to register any functions for use in lua with floats, for example i have a function

Function framePosition(obj As integer,x As integer ,y As integer ,width As integer,height As integer,order As float)

Which is registered using ianMs plugin and then registered as a lua function.

lua register function ptr_framePos, "Frame_Pos","LLLLLF", 0, 0

and this is how it is called in LUA:

DBPro.Call('Frame_Pos', 1 , x, y, sx, sy, 0.0 )

However every time I compile it returns with "cannot match arguments with DBPRO command "Frame_Pos".

Any ideas?

Edit: It seems that it won't work unless I find a way to define variable types in LUA which is rubbish a bit rubbish if LUA doesn't use variable types. Is there any solution to this?

Edit: found a solution, found the string conversion commands tostring seems to have solved the problem for string functions but haven't found one for floats yet..
TechLord
16
Years of Service
User Offline
Joined: 19th Dec 2002
Location: TheGameDevStore.com
Posted: 9th Sep 2009 04:48 Edited at: 9th Sep 2009 04:50
[DGDK]

I searched hi & lo for a answer to the following question in the DGDK threads with no luck.

1. How do you call DGDK commands from within your scripts directly? I understand that lua::make creates a dbpro table and registers all dbpro dlls. But the Lua Script Functions
results in a error
. Should I be using lua script function
???

Any and all assistance is greatly appreciated.

Trapped inside the DGDK Open Source Project.
MayoZebraHat 1979
11
Years of Service
User Offline
Joined: 21st Dec 2007
Location:
Posted: 3rd Oct 2009 05:35
I'm sure it's something silly, but I can't seem to "require" other files. I thought this worked before but it leaves an Lua error (attempt to call a nil global "require"). Am I just supposed to load it in memory instead of relying on require? That method works but I'm not sure if it's how I should load my modules for usage.
Maxmax123
11
Years of Service
User Offline
Joined: 11th Feb 2008
Location:
Posted: 4th Oct 2009 05:52 Edited at: 4th Oct 2009 05:54
Someone please sell me on this plugin (even thought its free)

Would LUA be a good choice for avoiding massive IF-ELSE chains or or SELECT/CASE statements for say mapping controls or creating custom action sets where the list of possible actions could be quite large?

I would like my video game to know exactly what function is desired and not need to go thought many IF-ELSE logic to actually get to the function needed.

This would potentially reduce latency by a large margin as my game involves a lot of possible actions for a particular button press.

Thank you
Aurum Knight
11
Years of Service
User Offline
Joined: 15th Jul 2008
Location: the suburbs of nowhere
Posted: 4th Oct 2009 23:33
Barnksi, could you look into the problem I posted a while ago? (last page, with the rgba function)
Kaegos
10
Years of Service
User Offline
Joined: 16th Aug 2009
Location: Brisbane
Posted: 17th Nov 2009 02:54
Hey, I just started using Barnski's DLL in a major project I am working on, however when the program reaches the LUA REGISTER FUNCTION call it crashes, triggering the visual studio just-in-time debugger. I replicated the relevant code in a new project and it still causes the problem so it's not anything else in my project causing the problem.

Here is the source code for my test version;


And the script file used is attached to this post. If anyone could help me out that'd be excellent (Notepad++ is my editor of choice).

Attachments

Login to view attachments
BMacZero
13
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ N_America/ USA/ CA/ South
Posted: 18th Nov 2009 02:16
Try this?



If that doesn't do it, I'm stumped

Kaegos
10
Years of Service
User Offline
Joined: 16th Aug 2009
Location: Brisbane
Posted: 18th Nov 2009 02:35
Tried that BMac, still the same issue. Using the Just-In-Time debugger it seems where the break is occurring is in the actual Barnski DLL, somewhere in the nether-regions of assembly code.

I'll get around it by putting the relevant stuff into Darkbasic instead, still, it's a shame
BMacZero
13
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ N_America/ USA/ CA/ South
Posted: 18th Nov 2009 02:47
That's weird. I'm using LUA REGISTER FUNCTION in a project and it's working fine. I'm fiddling with yours but it hasn't worked yet.

Kaegos
10
Years of Service
User Offline
Joined: 16th Aug 2009
Location: Brisbane
Posted: 18th Nov 2009 05:26
Would you mind posting an example of your code? It can be an abstracted version if it's a private project, that's cool. Just wanna rule out anything blatantly obvious we might be missing
BMacZero
13
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ N_America/ USA/ CA/ South
Posted: 18th Nov 2009 05:34
The code is quite long an untidy and uses a number of Lua files - I'll see if I can write a working example from it tomorrow.

Kaegos
10
Years of Service
User Offline
Joined: 16th Aug 2009
Location: Brisbane
Posted: 18th Nov 2009 05:50
HAHAHAHA Oh man I feel stupid. Though we both missed it, so that makes me feel a little better. I hadn't called LUA MAKE in that example so the plugin wasn't initialised.



Thanks for the help lol
BMacZero
13
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ N_America/ USA/ CA/ South
Posted: 18th Nov 2009 15:34


entomophobiac
16
Years of Service
User Offline
Joined: 1st Nov 2002
Location: United States
Posted: 24th Nov 2009 11:16
Has anyone more than me had problems with the "require" functionality in Lua? As in, it doesn't seem to work at all?

I did an extremely simple test to see if it worked.

Two files. One has no numbers in it but a "require 'file#2'" statement. The second file had an integer value that I tried to display.

Nothing happens.

So, what I wonder is -- did I execute it in the wrong way or does Barnski's plugin simply not load dependency files?
Outscape
11
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 10th Dec 2009 00:22 Edited at: 10th Dec 2009 00:49


i get that error when running



in GDK

i set the additional dependency to Barnski'sLuaPlugin_debug.lib
i made it MT

can anyone help me please? the files are in the right place too



Syncaidius
14
Years of Service
User Offline
Joined: 22nd Mar 2005
Location: United Kingdom
Posted: 29th Dec 2009 18:18 Edited at: 29th Dec 2009 18:18
I've got a problem.

I've got the function LUA_CREATE_PRIMITIVE(pType$ as string,width# as float,height# as float,depth# as float) which returns an integer value

The function is registered with lua using lua register function get ptr to function("LUA_CREATE_PRIMITIVE"),"Ent_Create","LSFFF",1,0

Then in my lua scripts I call it using local r = DBPro.Call("Ent_Create","box",width,height,depth)

Even though I call the function correctly from lua I get the following lua error: load string error: error, could not match arguments to DBPro command 'Ent_Create'

Any ideas as to whats wrong with it?

BMacZero
13
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ N_America/ USA/ CA/ South
Posted: 29th Dec 2009 18:58
Are the width, height, and depth declared as floats somehow in Lua?

Syncaidius
14
Years of Service
User Offline
Joined: 22nd Mar 2005
Location: United Kingdom
Posted: 31st Dec 2009 21:24 Edited at: 31st Dec 2009 21:25
Fixed my problem now. Found a bug along the way while registering DBP commands with lua that return a float. I had a function that took no parameters, and returned a float only. Registering it with the normal "F" for float didn't seem to work properly (i.e. it wasn't returning anything in lua), so i registered with "O" for double float, and it works fine.

Not sure if anyone else has had that problem, but there it is.

Login to post a reply

Server time is: 2019-08-23 23:58:26
Your offset time is: 2019-08-23 23:58:26