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.

Dark GDK / Problems with the lua plugin

Author
Message
zapakitul
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location: In my world
Posted: 19th Jul 2009 15:18
I downloaded Barnski's lua plugin and I seem to have 2 problems with it.
1. I can't compile my project in release mode, while in Debug mode works thine.
2. How can I read a string from a file? I can read integers and floats, but not strings. Any ideas? I tried using lua::get_string("String_Variable_Here",layer1,256); but it doesn't work.
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 19th Jul 2009 16:55 Edited at: 19th Jul 2009 17:06

this will open C:test.txt and read 80 characters from it
i hope that is useful
zapakitul
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location: In my world
Posted: 19th Jul 2009 16:58
Yes, I could do that myself, but I was interested in getting Lua to work with my engine. Thanks for trying though Hassan. My problem still remains the same, I can't compile my project in release mode, and I don't know how to use lua::get_string.
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 19th Jul 2009 17:37
What are you referring to as a string ? .. do you mean std::string ? or a character array pointer(char*) ?

Im sorry ive not used that plugin for lua scripting so I cant tell you about it's methods specifically, but the way in which you deal with std::string, as opposed to c-style strings is different.

Can you post your code, or the parts that are giving you trouble ? Someone may be able to help more with some code to look at.

If it ain't broke.... DONT FIX IT !!!
zapakitul
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location: In my world
Posted: 19th Jul 2009 18:07
Seems the plugin only came with documentation for Dark Basic Pro. Now, the DarkBasic Pro syntax is string$=lua_string("Parameter") .
Now, in C++ using that plugin, you can retrieve an integer just like in DBPRO, like foe example:

Really easy, but, retrieving a string is slightly different I think.
Here's the code I'm using:

This compiles, but outputs this when I'm running my app:

Now, here's what it asks for:

Any ideas?
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 19th Jul 2009 19:15
hmm, so thats a dark basic pro plugin that you are attempting to use in cpp ? ...

Im not exactly sure of the implementation differences but I can tell you that DBPro strings are not compatible in a 1:1 way with any for of string or character in C++ ..

The closes would be std:string I think.etc...

The other variables would work pretty well because most of the dbpro built in data types have a 1:1 equivelant in c++ that is capable of holding the value, so calling for a dbpro integer is the same as a c++ integer(mostly).

Here is the typedef for LPSTR :



Its basically a character array pointer. That means that it wont work at all like DBPro style strings.


In this line here :


You have a variable "test" having it's value assigned by "lua::get_string" .... what type is "test", how did you declare it ? Is it "char* test;" or "std::string test;" .....

Also, intellisense should tell you what the return type is for lua::get_string..

If this plugin is designed for DBPro, I think that you will be shooting yourself in the foot trying to use it in C++. There are a number of lua scripting class libraries that you can download online for C++.
If it is designed for GDK aswell, then I would have to guess that you are mis-using some data type somewhere...(it will run fine in debug because the debugger has a heap of extra imformation about how the program is "supposed" to run, that release mode doesnt have, the debugger also looks after memory while your program executes inside of it.)

If it ain't broke.... DONT FIX IT !!!

Login to post a reply

Server time is: 2024-10-01 08:31:13
Your offset time is: 2024-10-01 08:31:13