You are not logged in.

Applications: [GameMaster: OPEN] | [Volunteer Testers: OPEN]


This forum will be permanently shut down on Friday 13.07.2018
Please copy or save all important information from old forum before they will be deactivated
We have moved to new board. https://forum.runesofmagic.gameforge.com/Come join us.

1

Thursday, January 5th 2012, 8:00am

Damage Meter

Hello all,
I was wondering if there is any damage meter that works similar to how Recount works in WoW (if there is anyone that has used that addon).
I looked on curse, but couldn't find anything like what I wanted.

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

2

Thursday, January 5th 2012, 12:22pm

It's been asked before (see here: http://forum.us.runesofmagic.com/showthread.php?t=46776)

The last post there was my attempt to show that a line graph can be drawn in RoM, but no-one ever asked to see the code.
2013... The year from hell....

3

Thursday, January 5th 2012, 3:56pm

OMG I completely forgot about this. I would love to see the code Peryl.
Jacobmo 97Scout/97Warden/95Warrior/97Rogue/88D/85M
Allenmo 78S/77R/56P/1W/1K/1M - retired
Bteam all the way

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

4

Friday, January 6th 2012, 2:24am

Here's the code. Nothing overly special, a bunch of comments in there to explain a bit what it is doing.

Basically, uses a texture of a line segment and positions and rotates/scales it to correct locations to draw the graph. Another texture is used for the background/filled graph part.

Here's the code (uses dynamic frames/textures)
Peryl has attached the following file:
  • GraphConcept.zip (3.83 kB - 20 times downloaded - latest: Mar 2nd 2017, 11:49pm)
2013... The year from hell....

5

Friday, January 6th 2012, 11:59am

Wow, I think this can be add in AAH's history price.

1Rausch1

Beginner

Posts: 42

Location: Midwest

Occupation: Network Engineer

  • Send private message

6

Friday, January 6th 2012, 6:52pm

Looking at your graph I see potential for what I want to do, but I have a few issues.

So let me explain

I want a resizeable graph marked in incriments of 10% showing threat over time.

Something like this but probably looking more like the threat meter in pbinfo

http://i387.photobucket.com/albums/oo320…ris/Capture.png

This part I cant do for sure. I just dont know how to make a moveable resizeable window and Id also like color change options and transparency but again know nothing on that

I have a threat meter with a small single bar to monitor just my threat Id like to use this to make my graph

Currently you account for 20 calls of data on your graph and up to 255 locational points. A line graph only needs only 1 data and 100 locational points. With math I can turn 100% into a number between 1 and 255 or I can just change your graphs code to allow for 1 - 100 making it smaller but

How do I store 20 sets of updates and then call them as the data for the graph? would I use an array? can I call data from one addon and use it in another?

Im sure you can see where Im going with this and was wondering if you would be interested in helping me with this.
I Tank For Guildies!
K 80 / S 73 / W 65
[img][/img]

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

7

Saturday, January 7th 2012, 1:31am

Quoted from "1Rausch1;499771"

This part I cant do for sure. I just dont know how to make a moveable resizeable window and Id also like color change options and transparency but again know nothing on that

I haven't played with the scrollbars much, but the one time I used one (in TransportMap) I basically rolled my own. Used the scrollbar to figure out what to display in the window area, and displayed that portion. You could do the same kind of thing for the threat graph window. Just display the portion of the data you want.

As for transparency and color. Change the textures used so that they are pure white instead of red (graph background) and yellow (the line). Then in the code, change the *:SetColor() calls to use the red,green, and blue color components you want (parameters are in that order, values are between 0 and 1 inclusive). Change the *:SetAlpha() calls to something other than 1.0 to get transparency. 0 is fully transparent, 1.0 is fully opaque, 0.5 would be half transparent etc.

Edit:
Don't change the transparency and color of the actual frame used, just the textures. If you change the transparency on the frame itself, this will also affect the textures (which might be what you want, but probably better to just do the textures)


Quoted from "1Rausch1;499771"

I have a threat meter with a small single bar to monitor just my threat Id like to use this to make my graph

Currently you account for 20 calls of data on your graph and up to 255 locational points. A line graph only needs only 1 data and 100 locational points. With math I can turn 100% into a number between 1 and 255 or I can just change your graphs code to allow for 1 - 100 making it smaller but

How do I store 20 sets of updates and then call them as the data for the graph? would I use an array? can I call data from one addon and use it in another?

Use an array to store the data. You could have much more than 20 data points, I used 20 simply because I didn't want to type in more random numbers (it's just an example after all).

The display size I used in this example was 256 by 256. I got lazy and made the data points values from 1 to 255 so that I could easily see if the graph was displaying correctly. There really isn't anything magical about those values.

As to sharing data between add-ons, well yes you could do that, but far better to incorporate the algorithm into your own code. This way you can create a function to display the data in any fashion you wish.
2013... The year from hell....

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

8

Saturday, January 7th 2012, 3:51am

Re-reading Rausch's question, it may be better if I explained in more detail what this graphing example code is actually doing.

The concept is rather simple. The assumption here is that the area between two data points is linear and spans more than one pixel on screen. This allows the use of textures as a replacement for a line drawing function since RoM doesn't have a line drawing function built in.

A simple 1 pixel tall texture is used to represent the line. This is then rotated, stretched and placed in such a way that the end-points of the line/texture coincide with two data points on the graph. This is the yellow line part of the graph.

For the filled red area of the graph, two more textures are used. The idea is to break the graph into two parts. First is the section where the data points are, this is again assumed to be linear and a triangular texture is used to cover this area, from lowest to highest point, flipping the texture in the left tot right direction as needed. Everything below this part is taken up by the second texture which is merely a filled square.

As a visual aid, the breakdown is like this (*s are the actual data point):

Source code

1
2
3
4
5
6
7
         *
        /|
       / |   <-- this is the triangular texture part
     *---
     |   |
     |   |   <-- this is the full square part
     ----

Again, the textures are scaled and stretched as needed, based on the data points.

Because textures are being used, it is best if the distance between to data points on the visual part of the graph is at least two pixels wide, otherwise the math and or the displayed textures may not come out right.

The example code presented merely shows how this can be achieved. It isn't even in a function. It merely creates the base frame and a bunch of textures and slaps it on screen.
2013... The year from hell....

9

Saturday, January 7th 2012, 4:37am

Does this remind anyone else of the rectangular approximation method of integral calculus? (It's used to calculate the area beneath a curve of a function by finding the limit of successive approximations of its area, calculated by taking the sum of the areas of inscribed rectangles with diminishing widths. The method is effectively the definition of an integral.)

Or is it just me? :)

Thanks for the code snippet Peryl! The use of dynamic graphs opens a wide world of addon possibilities.

1Rausch1

Beginner

Posts: 42

Location: Midwest

Occupation: Network Engineer

  • Send private message

10

Monday, January 9th 2012, 7:27am

Well Ive been trying to make this work but I know so little about LUA its quite frustrating
I Tank For Guildies!
K 80 / S 73 / W 65
[img][/img]

1Rausch1

Beginner

Posts: 42

Location: Midwest

Occupation: Network Engineer

  • Send private message

11

Monday, January 9th 2012, 7:47am

so I can make this array of data fields as shown

Source code

1
2
3
4
5
6
local a = {}    -- new array
    for i=1, 20 do
      a[i] = 10
    end
 
local DataPoints = {a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15],a[16],a[17],a[18],a[19],a[20]};


I think you can understand this, every array point currently = 10

somewhere I will have a process or function or w/e that will

check threat %
threat % = something
save to array
wait .5
check again

so I could have it save each one individualy but what would be correct is to initialize the array to 0 and then save to array point a[20] and then when you check again

a[20] becomes

a[19] and then

a[20] gets filled with new data

Obvisouly this would shuffle the 0's out of the array and soon populate the threat graph.

but I cant find how to do that. any help???

Thanks
I Tank For Guildies!
K 80 / S 73 / W 65
[img][/img]

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

12

Monday, January 9th 2012, 11:41am

Quoted from "1Rausch1;500360"

so I can make this array of data fields as shown

Source code

1
2
3
4
5
6
local a = {}    -- new array
    for i=1, 20 do
      a[i] = 10
    end
 
local DataPoints = {a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15],a[16],a[17],a[18],a[19],a[20]};


Or you could use the a array directly since it is an array. Or you could also do

Source code

1
local DataPoints = a

This makes DataPoints use the same data as a.

Quoted from "1Rausch1;500360"

so I could have it save each one individualy but what would be correct is to initialize the array to 0 and then save to array point a[20] and then when you check again

a[20] becomes

a[19] and then

a[20] gets filled with new data

Obvisouly this would shuffle the 0's out of the array and soon populate the threat graph.

but I cant find how to do that. any help???

Thanks

What you are asking for is called a queue. Works in a FIFO (first in, first out) fashion. Lua has facilities to do this via the table.insert() and table.remove() functions.

So to do what you want, simply do:

Source code

1
table.remove(a,1)

This will remove the first entry in the array (a[1]) and shuffle all the other elements down. Now you can add new data to a[20].

These questions are basic Lua and data structures related and it would be best if you familiarize yourself with such things. I suggest you read the following:

It may be a lot to read up on, but it'll save you a lot of headaches in the long run.
2013... The year from hell....

1Rausch1

Beginner

Posts: 42

Location: Midwest

Occupation: Network Engineer

  • Send private message

13

Monday, January 9th 2012, 6:12pm

OK well Ive been reading as you suguested, and Im sure the answer is in there but I thought Id give you a little progress of what Ive learned today at work haha

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
local count = 0
local a = {}    -- new array
    for i=1, 20 do
      a[i] = 0
    end
local DataPoints = a
--Print count
print("Current Count " .. count)
--Count
while count < 10 do
  count = count + 1
 table.remove(a,1)
 table.insert(a,os.time) 
   for i=1, 20 do 
    print(a[i])
   end
  print("Count " .. count)
 end
 
 print("Nearing End of File")
 
-- print all data points one more time from name 
 
 for i=1, 20 do 
  print(DataPoints[i])
 end


So as I havnt read through enough to understand os.time or a timer, Ive used count to emulate the idea.

eventualy I would get the current time add the update interval to it and then trigger when current time matched the update time

I see how what you have posted works and Ive used those parts in code to understand them better. Im concerned that DataPoints = a wont populate the graph tho.

when I

print(DataPoints) I get the table id or memory location or something like that. Will that happen if I leave your code and set DataPoints = a ? If so I guess I could go back to defining each DataPoint in order so that

DataPoints = {(a[1]),(a[2]), ......
I Tank For Guildies!
K 80 / S 73 / W 65
[img][/img]

1Rausch1

Beginner

Posts: 42

Location: Midwest

Occupation: Network Engineer

  • Send private message

14

Tuesday, January 10th 2012, 1:49am

Well I did finaly make it work...

but its such a hack job its causing major lag.

probably because I havnt gone through it the right way and made it work.

Seems Im calling a few wrong chunks of the graphing process. I maybe only need to update the draw and the data but Im pretty sure Im updating the whole thing.

either way Im not sure how much more drive I have to make this work.

Ive attacehd a screen shot to show it with agro tho
1Rausch1 has attached the following image:
  • Capture.jpg
I Tank For Guildies!
K 80 / S 73 / W 65
[img][/img]