I would like to create a spell list easily editable with some outside program, for example MS excel. Is it possible to open and read the file with a MUSHclient script? If it is not, what would be the best solution for me? Thank you
Database/file, seeking suggestion
Posted by Prattler on Sat 08 Jan 2005 12:37 PM — 5 posts, 20,475 views.
If you saved the file in comma-separated-value (CSV) format in Excel, you could fairly easily read that with a script, especially Lua. The problem with saving an Excel spreadsheet is that you wouldn't know the format to read from it.
You could probably also use an Excel COM object to open the sheet, but I don't know if that'll let you make row/column queries and the like without actually displaying the sheet.
It depends on what you're going to store in the spell list, really.
You could probably also use an Excel COM object to open the sheet, but I don't know if that'll let you make row/column queries and the like without actually displaying the sheet.
It depends on what you're going to store in the spell list, really.
One approach is to use Excel and then convert the resulting file (with find-and-replace) to resemble ordinary variable definitions in XML, like this:
Then simply import or paste them into MUSHclient.
The name is in the name="xxx" part, and the contents is after the > sign.
Another approach is to use Lua to read the CSV file, see this page for example code:
http://www.lua.org/pil/20.4.html
However more simply, since I presume each line would simply contain variable=contents, you could write a simple script to read in your file (there are lots of examples of reading files here), and simply search for the delimiter (eg. the comma or tab) and put the first part as the name, and the second part as the contents.
<variables>
<variable name="fireball">20</variable>
<variable name="iceblast">42</variable>
</variables>
Then simply import or paste them into MUSHclient.
The name is in the name="xxx" part, and the contents is after the > sign.
Another approach is to use Lua to read the CSV file, see this page for example code:
http://www.lua.org/pil/20.4.html
However more simply, since I presume each line would simply contain variable=contents, you could write a simple script to read in your file (there are lots of examples of reading files here), and simply search for the delimiter (eg. the comma or tab) and put the first part as the name, and the second part as the contents.
Just a sample of using Excel COM object in VBS:
dim xlapp, xlbook,xlsheet
sub Test
dim i,j
set xlapp=CreateObject("Excel.Application")
xlapp.visible=false 'so it runs in background and is not visible
set xlbook=xlapp.workbooks.open ("G:\test.xls")
set xlsheet=xlbook.sheets("Arkusz1")
for i=1 to 5 'rows
for j=1 to 5 'columns
note i & "," & j & xlsheet.cells(i,j)
next
next
end sub
sub Test2
set xlsheet=nothing
set xlbook=nothing
xlapp.quit
set xlapp=nothing
end sub
Test1 opens the file and reads from it first 5 rows and 5 columns and displays to the screen.
Test 2 closes the Excel Application - you must remember to do it;)
It works fine although not very fast and doesn't display the application.
dim xlapp, xlbook,xlsheet
sub Test
dim i,j
set xlapp=CreateObject("Excel.Application")
xlapp.visible=false 'so it runs in background and is not visible
set xlbook=xlapp.workbooks.open ("G:\test.xls")
set xlsheet=xlbook.sheets("Arkusz1")
for i=1 to 5 'rows
for j=1 to 5 'columns
note i & "," & j & xlsheet.cells(i,j)
next
next
end sub
sub Test2
set xlsheet=nothing
set xlbook=nothing
xlapp.quit
set xlapp=nothing
end sub
Test1 opens the file and reads from it first 5 rows and 5 columns and displays to the screen.
Test 2 closes the Excel Application - you must remember to do it;)
It works fine although not very fast and doesn't display the application.
Thank you all for the help, that was what I needed. I'll try to move on on my own now :)