|
Scarn Apprentice
Joined: 24 Jul 2005 Posts: 137
|
Posted: Tue Oct 06, 2015 11:14 pm
COM objects. |
So I want to start branching out into COM objects, I'm trying to load the text in a text file into a CMUD variable. Is this what COM is for?
I've skimmed the help file but it's a little advanced for me to understand, so far I understand that I need to CALL the program (notepad) and then the txt file location?
Would someone be able to show me an example of the simplest form of using COM that I could then build on? |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4690 Location: Pensacola, FL, USA
|
Posted: Tue Oct 06, 2015 11:20 pm |
If you are just trying to edit text files you likely want the #FILE #READ and #WRITE commands.
I am sure it could be done via COM as well though. |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Scarn Apprentice
Joined: 24 Jul 2005 Posts: 137
|
Posted: Tue Oct 06, 2015 11:58 pm |
What I want to do is grab all the data from a text file and display it into a window (it'll be for quest info) working off my map... Basically walk into a quest and my 'Quest' window populates with data from X file.
|
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Wed Oct 07, 2015 6:26 am |
As shalimar mentioned, CMUD's built-in commands would be more appropriate for this use case. You don't need to interact with notepad at all to read a text file, since zScript already provides a mechanism for it. From a brief google search, it doesn't look like Notepad actually supports COM, it is a very simplistic program.
COM is a system used for programs to talk between each other. However, every individual program is responsible for making public the functions that it wants to expose through COM, so it's hard to provide a global example that really encapsulates everything. You would need to read the documentation of the program in question to see what functions are available to be called. A good starting point for experimenting could be to call CMUD's own COM interface (documentation here, replacing zMUD with CMUD as necessary). For example, if you wanted to send a string to the current session, you could do something like this:
Code: |
$cmud = %comcreate("CMUD.Application")
#call $cmud.CurrentSession.SendStr("foo") |
Obviously calling CMUD's COM interface from within CMUD itself seems somewhat redundant, but the idea to wrap your head around is that CMUD has made these functions publicly available to be called from within any application that supports COM. As an example, I've experimented with running CMUD on a webserver, and using COM to send commands and pull live data from the MUD to display on a webpage. |
|
|
|
Scarn Apprentice
Joined: 24 Jul 2005 Posts: 137
|
Posted: Fri Oct 09, 2015 4:29 am |
I'll have an investigate!
|
|
|
|
Scarn Apprentice
Joined: 24 Jul 2005 Posts: 137
|
Posted: Fri Oct 09, 2015 4:35 am |
How would you do the above in lua?
|
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Fri Oct 09, 2015 7:32 am |
Using the LuaCOM library:
Code: |
require("luacom")
local cmud = luacom.CreateObject("CMUD.Application")
cmud.CurrentSession:SendStr("foo") |
|
|
|
|
Scarn Apprentice
Joined: 24 Jul 2005 Posts: 137
|
Posted: Fri Oct 09, 2015 11:43 am |
Ah, was using . instead of :
|
|
|
|
|
|