getValueAt, a tool for configuration

Share your scripts and packages with other Mudlet users.
Post Reply
User avatar
Posts: 647
Joined: Sat Dec 05, 2009 3:19 pm

getValueAt, a tool for configuration

Post by demonnic »


This will return the same value as if you had read the variable itself. For instance, getValueAt("") would be the same as referencing directly

"Why do this?", I hear you asking.

I dunno how many other people may ever use this, but I was thinking recently about how to make some basic UI stuff scriptable, automated, and flexible. Such that you can tell it what stats you want to track and what variables to look in to track them. Like I do with YATCO for chat stuff, but leaving all the tracking of statistics and such to other packages/modules.

So, as a basic example, I want to run a gauge for something. I need their current value and max value. But I don't want to track that myself, a lot of people are already tracking that, and I'm trying to make something that can be easily layered on top of an existing setup without modifying it or double tracking. So instead, I'll ask where you keep those values.

Maybe an example is easiest.
Code: [show] | [select all] lua
-- let's just assume I instantiated all the tables earlier, ok?
demonnic.ui.statGauges = {"Health"}
demonnic.ui.stats[1].max = "gmcp.Char.Vitals.maxhp"
demonnic.ui.stats[1].current = "gmcp.Char.Vitals.hp"

--in the function I update gauges in later
for statNum,gaugeName in ipairs(demonnic.ui.statGauges) do
  local current = getValueAt(demonnic.ui.stats[statNum].current)
  local max = getValueAt(demonnic.ui.stats[statNum].max)
  demonnic.ui.updateStatValues(statNum, current, max)
(706 Bytes) Downloaded 176 times

Post Reply