Page 2 of 3

Re: elist in IRE muds

Posted: Tue Feb 16, 2010 6:22 am
by kaeus
naftali wrote:Aha! Finally, that works! Maybe eventually I'll figure out a way to control what order the elixers are listed in.

@hempa Thanks so much! Just fyi though the function is string.rep() not string.repeat() at least in the latest dev version of Mudlet.
Glad to see it fixed, and that was my fault. Hempa was just going off what I posted as an example. I used string.rep() in my code, but for some reason used string.repeat() here.

Re: elist in IRE muds

Posted: Tue Feb 16, 2010 10:15 am
by hempa
@kaeus: of course, it's string.rep. I was just copying directly from the uploaded script and missed it :P

Re: elist in IRE muds

Posted: Fri Feb 19, 2010 7:46 pm
by naftali
Don't want to create a new topic, but I've run into a new problem. I've modified the code a bit, and it still works but I wanted to add something else and cannot figure out how.

What I have now takes the original table (as discussed above) and turns it into another table that comes out looking like this:

Code: Select all

table {
  'mana': 644
  'caloric': '154'
  'levitation': '47'
  'mending': '61'
  'mass': '197'
  'health': 206
  'frost': '164'
  'speed': '199'
  'immunity': '194'
  'restoration': '197'
  'venom': '162'
}
I then use the following to print it:
Code: [show] | [select all] lua
for ename, sips in pairs(elixers) do
	echo(ename .. string.rep(" ",26 - #ename) .. sips .. "\n")
end
What I want to do is color it based on the number of sips left.
If sips >= 100 then color = green
elseif sips >=50 then color = yellow
else color = red
end

What I can't figure out is how to use either fg() or cecho() to make that happen. Every time I try the code stops after echoing the first element of the table. Any suggestions?

Re: elist in IRE muds

Posted: Fri Feb 19, 2010 10:53 pm
by hempa
This snippet should do the trick for you:
Code: [show] | [select all] lua
for ename, sips in pairs(elixers) do
   echo(string.format("%-26s",ename))

   if sips >= 100 then fg("green")
   elseif sips >= 50 then fg("yellow")
   else fg("red")
   end

   echo(sips)
   resetFormat()
end

Re: elist in IRE muds

Posted: Sat Feb 20, 2010 4:04 am
by naftali
Never mind found the problem. Your script had the same problem as mine, but it was caused by the fact that some of the numbers were strings and others were numbers. For some reason the problem wasn't showing up until I tried to color things.

Re: elist in IRE muds

Posted: Wed Feb 24, 2010 12:29 pm
by hempa
Always, when adding the sips to the tables, make sure you put it in as a number if it is to be considered a number. tonumber(variable) will help you do that!

Re: elist in IRE muds

Posted: Sat Aug 14, 2010 1:10 pm
by pathris
Has anyone compiled a package for an elixlist summary? I suck too much at Lua to make my own...

Re: elist in IRE muds

Posted: Sat Aug 14, 2010 6:27 pm
by tsuujin
I do have a complete elixlist parser for achaea, however it stores data into my system in a way that prevents it from being a standalone solution (I have a full gear tracking system with database integration).

I could post the trigger when I get home tomorrow though.

Re: elist in IRE muds

Posted: Sat Aug 14, 2010 6:38 pm
by pathris
Sounds fancy!

Re: elist in IRE muds

Posted: Sun Aug 29, 2010 4:37 am
by Trilliana
Ok, slight necro. Any update on this?? *hope*