elist in IRE muds

kaeus
Posts: 50
Joined: Thu Dec 31, 2009 4:33 pm

Re: elist in IRE muds

Post 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.

hempa
Posts: 48
Joined: Sat Jan 02, 2010 1:07 pm

Re: elist in IRE muds

Post by hempa »

@kaeus: of course, it's string.rep. I was just copying directly from the uploaded script and missed it :P

naftali
Posts: 138
Joined: Wed Jan 20, 2010 8:42 pm

Re: elist in IRE muds

Post 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?

hempa
Posts: 48
Joined: Sat Jan 02, 2010 1:07 pm

Re: elist in IRE muds

Post 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

naftali
Posts: 138
Joined: Wed Jan 20, 2010 8:42 pm

Re: elist in IRE muds

Post 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.

hempa
Posts: 48
Joined: Sat Jan 02, 2010 1:07 pm

Re: elist in IRE muds

Post 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!

pathris
Posts: 12
Joined: Fri Aug 06, 2010 9:00 pm

Re: elist in IRE muds

Post by pathris »

Has anyone compiled a package for an elixlist summary? I suck too much at Lua to make my own...

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: elist in IRE muds

Post 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.

pathris
Posts: 12
Joined: Fri Aug 06, 2010 9:00 pm

Re: elist in IRE muds

Post by pathris »

Sounds fancy!

Trilliana
Posts: 21
Joined: Tue Nov 24, 2009 2:47 am

Re: elist in IRE muds

Post by Trilliana »

Ok, slight necro. Any update on this?? *hope*

Post Reply