View Single Post
  #9  
Unread 01-13-2016, 02:31 AM
Thurallor's Avatar
Thurallor Thurallor is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: May 2013
Posts: 202
Quote:
Originally Posted by corhub
I've been looking at Garan's Lotro Alerter and can't figure out how it's writing to the log window
I assume you mean the chat window. If so, here's how:
import "Turbine";
Turbine.Shell.WriteLine("Hello, world");
Quote:
and I can't even figure out how it is getting my characters name.
import "Turbine.Gameplay";
local player = Turbine.Gameplay.LocalPlayer:GetInstance();
Turbine.Shell.WriteLine("your name is " .. player:GetName());
Quote:
It is difficult for me to understand the lua code, I wish there were simpler examples I could look at. The code is very efficient but that in itself makes it difficult for me to understand. For me, there is no logical flow from defining a variable to where it is used, displayed, written to a file. I know that is because I do not yet understand how the lua coding works and am trying very hard to understand it but I feel as if I am making little to no progress.
Perhaps with your VBA background you're not comfortable with object-oriented programming. A lot of plugin functionality is done by attaching callback functions to events generated by objects. You should read the "Programming with Class" section in Garan's tutorial. (You should really read the whole thing; it's not that long.)

Quote:
If it is possible, could someone please include a few lines of code that shows how to do the following: read the chat log (standard and quest only)
You have to attach a callback function (event handler) to the Chat object:
import "Turbine";
function ChatMessageReceived(chatobject, args)
Turbine.Shell.WriteLine("channel = " .. args.ChatType .. "; message = " .. args.Message);
-- Note: The list of channels is in the Turbine.ChatType enumeration.
end
AddCallback(Turbine.Chat, "Received", ChatMessageReceived);
Quote:
and how to write to a file (I have done this but don't know the difference between that and appending to the file nor do I know how to write an array to a file) and append to it.
You cannot append to a file; you can only overwrite the entire thing. You use the Load() and Save() functions of the Turbine.PluginData object. See Garan's tutorial.
Reply With Quote