Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Plugins ➜ Plugin working as include lib / including .lua files / 2 script languages

Plugin working as include lib / including .lua files / 2 script languages

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Zlad   (6 posts)  Bio
Date Sat 14 Mar 2009 01:39 PM (UTC)
Message
Hi there,

I've been doing basic script in VBS and then due to lack of 'Database' commands I built LUA plugin, which I hoped to work as an include library for basic script.

It didn\t work, so my obvious questions are:

1. Is there any posibility to use plugins in the way of includes. So that I am able to call its script functions from basic script?

2. How can I add .lua files as include to main .lua file, just as it was mentioned for VBS and JS in topic:
http://www.gammon.com.au/forum/bbshowpost.php?id=1297

3. Finnaly is it possible to make hybrid script? Which will partly be written in Lua / VBs?

Thanks for feedback
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Sat 14 Mar 2009 09:01 PM (UTC)

Amended on Sat 14 Mar 2009 09:02 PM (UTC) by Nick Gammon

Message
What do you mean by Database commands?

Version 4.40 added support for accessing SQLite databases from all scripting languages, see:

http://www.gammon.com.au/forum/bbshowpost.php?id=9262


If that is not what you wanted, no you cannot mix languages in a single plugin. Each plugin invokes a particular script engine.

To include Lua files (into a Lua script) just use "dofile" or "require", which are built into Lua.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Zlad   (6 posts)  Bio
Date Reply #2 on Sun 15 Mar 2009 03:29 PM (UTC)
Message
By 'Database commands' i meant *.sqlite database accessing/maintainig functions such as 'DatabaseOpen', 'DatabasePrepare', 'DataColumnValues', etc, which I thought to be only Lua feature.

If I understood your post properly all of these methods are also supproted by other script languages including VBscript... and that makes me a little bit confused.

I didnt really find any VBs examples or notes.

My only goal is to open SQLite db, read/edit values and have the result in VBscript function.


PS. Im not an expert, so you can find some of my statements incorrect.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #3 on Sun 15 Mar 2009 08:21 PM (UTC)
Message
Ah, I was just too lazy to do all of the examples documented under the Database* functions in every script language. The syntax in VBscript is pretty similar to Lua (the table handling is a bit different).

For example, here is how you open a database, create a table, and close it, in VBscript:



DatabaseOpen "db", GetInfo (66) & "mytestdb.sqlite", 6  ' open database

'
'  create table
'

DatabaseExec "db", _
"DROP TABLE IF EXISTS weapons;" & _
"CREATE TABLE weapons( " & _
"        weapon_id INTEGER NOT NULL PRIMARY KEY autoincrement," & _
"        name  TEXT NOT NULL," & _
"        damage INT default 10," & _
"        weight REAL" & _
"      );"
      
DatabaseClose "db"  ' close it


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


17,651 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.