LoTROInterface

LoTROInterface (https://www.lotrointerface.com/forums/index.php)
-   Chit Chat (https://www.lotrointerface.com/forums/forumdisplay.php?f=2)
-   -   New Combat stats plugin (https://www.lotrointerface.com/forums/showthread.php?t=3495)

Trilesch 05-27-2014 04:14 AM

the plugin is comming along nicely so we have damage done damage taken healing done and healing taken in a nice little box we are now working on the dps side and diffrent attacks side of things.

Thurallor 05-29-2014 11:41 PM

Coroutines do work, sort of. The following code
Code:

local func = coroutine.create(function(num)
    num = coroutine.yield("a" .. tostring(num));
    num = coroutine.yield("b" .. tostring(num));
    num = coroutine.yield("c" .. tostring(num));
    return "d" .. tostring(num);
end);

result, value = coroutine.resume(func, 1); Turbine.Shell.WriteLine("result = " .. tostring(result) .. "; value = " .. tostring(value));
result, value = coroutine.resume(func, 2); Turbine.Shell.WriteLine("result = " .. tostring(result) .. "; value = " .. tostring(value));
result, value = coroutine.resume(func, 3); Turbine.Shell.WriteLine("result = " .. tostring(result) .. "; value = " .. tostring(value));
result, value = coroutine.resume(func, 4); Turbine.Shell.WriteLine("result = " .. tostring(result) .. "; value = " .. tostring(value));
result, value = coroutine.resume(func, 5); Turbine.Shell.WriteLine("result = " .. tostring(result) .. "; value = " .. tostring(value));

produces the following output:
result = true; value = a1
result = true; value = b2
result = true; value = c3
result = true; value = d4
result = false; value = cannot resume dead coroutine
However, I don't think you can call any API functions within a coroutine (e.g. Turbine.Shell.WriteLine doesn't work), so it seems pretty useless. You can access global variables, though. So if you had a big number crunching task, you could put it in a coroutine that is resumed in an Update() event handler, and spread out the computations over time until complete. I haven't tried this, but it seems like it would work. :D

Edit: I suppose you could pass a function and arguments to coroutine.yield(), and call the function in Update() when it's returned by coroutine.resume().

Digpoe 05-31-2014 08:06 AM

Quote:

Originally Posted by Equendil (Post 11361)
As far as I know, packages, I/O and OS operations, and debug functions have been stripped. I don't think coroutines work either. So basically you have access to the basic (most of it), string, table and math libraries. Well, I've been checking that stuff a long time ago though. Anyway, you might want to check the global scope to see what's in there, I wrote a plugin that lets you do that within LotRO: http://www.lotrointerface.com/downlo...BeDragons.html

Quote:

Originally Posted by Thurallor (Post 11370)
Coroutines do work, sort of. The following code
Code:

local func = coroutine.create(function(num)
    num = coroutine.yield("a" .. tostring(num));
    num = coroutine.yield("b" .. tostring(num));
    num = coroutine.yield("c" .. tostring(num));
    return "d" .. tostring(num);
end);

result, value = coroutine.resume(func, 1); Turbine.Shell.WriteLine("result = " .. tostring(result) .. "; value = " .. tostring(value));
result, value = coroutine.resume(func, 2); Turbine.Shell.WriteLine("result = " .. tostring(result) .. "; value = " .. tostring(value));
result, value = coroutine.resume(func, 3); Turbine.Shell.WriteLine("result = " .. tostring(result) .. "; value = " .. tostring(value));
result, value = coroutine.resume(func, 4); Turbine.Shell.WriteLine("result = " .. tostring(result) .. "; value = " .. tostring(value));
result, value = coroutine.resume(func, 5); Turbine.Shell.WriteLine("result = " .. tostring(result) .. "; value = " .. tostring(value));

produces the following output:
result = true; value = a1
result = true; value = b2
result = true; value = c3
result = true; value = d4
result = false; value = cannot resume dead coroutine
However, I don't think you can call any API functions within a coroutine (e.g. Turbine.Shell.WriteLine doesn't work), so it seems pretty useless. You can access global variables, though. So if you had a big number crunching task, you could put it in a coroutine that is resumed in an Update() event handler, and spread out the computations over time until complete. I haven't tried this, but it seems like it would work. :D

Edit: I suppose you could pass a function and arguments to coroutine.yield(), and call the function in Update() when it's returned by coroutine.resume().

Thanks for the info, guys. I did an environment dump (which was weird, because I'm used to a slightly different environment setup where I don't have to use a pairs loop on _G) and I found that a few functions are disabled;
  • loadfile
  • io and os libraries

And a few others which I probably didn't notice. :P

In fact, I'm actually surprised at how little sandboxing of the environment that LoTRO has; I can escape environment sandboxes using the __gc metamethod (I'm used to that being disabled, in fact, I hardly use it at all!) and make custom userdatas using newproxy.

Thurallor 05-31-2014 07:50 PM

Just curious, what does making custom userdatas allow you to do?

Digpoe 06-01-2014 08:41 AM

Quote:

Originally Posted by Thurallor (Post 11372)
Just curious, what does making custom userdatas allow you to do?

Well, in layman's terms, it allows you to create an OOP system. In Lua, most types of data are forms of userdatas; that is, file handles and similar. You can check the type of something using the 'type' function; you'll find that tables are used more in LoTRO, which don't allow for very detailed OOP systems.

Here's more on the subject; http://lua-users.org/wiki/HiddenFeatures

Evendale 06-03-2014 11:54 PM

What bloat was in CA? I think it was pretty efficient tbh (for the amount of data reported)

Digpoe 06-05-2014 04:55 AM

Quote:

Originally Posted by Evendale (Post 11379)
What bloat was in CA? I think it was pretty efficient tbh (for the amount of data reported)

Well, it wasn't as much bloated, but more just simply all over the place. I had a hard time finding out how some basic features like the Gui worked.
Right now, the new code is split into four scripts as of right now, most of which is just my way of setting up chat parsing and a custom Gui class for creating the interface.
Here's some snippets of code, the things which you can do with it:

Code:

main = Gui.new("Window")
main.Rect = {X=10, Y=10, Width=100, Height=100}
main.BackgroundTransparency = 0.5 -- sets the background transparency (not opacity, it uses the alpha channel)
main.BackgroundColor = Turbine.UI.Color(1, 0, 1) -- sets the colour. Not sure if it retains transparency though.

local a = Gui.new("Label")
a.Name = "TextLabel"
a.Parent = main

main.TextLabel.Text = "Hello World!"

main.Visible = true


magill 06-06-2014 12:29 PM

Quote:

Originally Posted by Garan (Post 11349)
. Since Narrel indicated that some of the data.lotro functionality may get resurrected at some distant point in the future there may also be hope for a solution to this issue.

"Distant" is probably an understatement. I asked Sapience in one of the recent TTHTI runs if any thing was happening --- his response was nothing in the foreseeable future.


All times are GMT -5. The time now is 05:34 PM.

vBulletin® - Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© MMOUI