Item Database

Posted by Ishnaf on Mon 14 Apr 2003 01:45 PM — 8 posts, 33,077 views.

Australia #0
Gday - I just downloaded the MudDatabase plugin - its brilliant :)

I've fiddled with some bits and pieces and managed to connect to my database and make it automatically update itself when i find out about new EQ, the only problem is that when i call up the information I get:

Item ItemType ItemIs ForgeLevel DiceNo DiceSize Weight Value Rent ACApply Armor CON INTEL WIS DEX CHA STR Hitroll Damroll maxhit maxmana Uselevel Age
Cloak of the Innocents ARMOR GLOW !GOOD !NEUTRAL NOBITS0 0 0 5 200000 480 0 0 0 0 0 0 0 1 0 3 0 0 0 0

which is hard to read :P

Could someone please help me with making a snippet of code to display this that:
1.Doesnt display Null values (e.g. 0 or just a blank field)
2.Displays it like:
Item:A cloak of the innocents ItemType:ARMOR ItemIs:GLOW etc

Dont worry about showing every field, just showing a few to get me started would be great :) And nobody comment on my database structure - it started off neat but i kept adding new fields :P

Thankye,
Ishnaf


Australia Forum Administrator #1
This code from that plugin shows the general idea:


  Do Until rst.EOF

    count = count + 1

    mud_name     = rst.Fields ("mud_name").Value
    ip_address   = rst.Fields ("ip_address").Value
    port         = rst.Fields ("port").Value
    description  = rst.Fields ("description").Value

    world.ColourTell "white", "darkred", mud_name
    world.ColourTell "white", "black", " IP: " & ip_address
    world.ColourTell "white", "black", " Port: " & port
    world.Note ""

    world.ColourNote "silver", "black", description

    world.Note ""

    rst.MoveNext
  
  Loop


Here I am pulling out individual fields (eg. rst.Fields ("port").Value) and then using them in individual ColourTell lines.
Canada #2
Hmmm. I went to the list of plugins and I can't find this one. It'd be great to use on the MUDs I play as there's a chest system like Diablo 2 and I walk around with anywhere between 20 and 50 new items due to the random item generation code.

If you know where it is, lemme know.
Australia Forum Administrator #3
See:

http://www.gammon.com.au/mushclient/plugins/

Half-way down the page is the plugin "MudDatabase".
Canada #4
ah. Thanks Nick. Oh yeah, i made a topic called Numeric/Calculator or something. Wanna check it out for me?
USA #5
Umm. Think you missed the point there Nick.

The trick here is to pad values using the length of the result. For instance, say you have the following:


Item   AC  Value       Description
Cloak   5    500 gold  A fur cloak.

So if you do this:

Item_Name = rst.Fields ("item_name").Value
Item_AC = rst.Fields ("item_ac").Value
Item_Value = rst.Fields ("value").Value
Item_Description = rst.Fields ("descrip").Value

You would then do this to get it to look like above:

MaxColumns = 80
pad = space(5 - len(Item_Name))
tell Item_Name & pad & " "
pad = space(2 - len(Item_AC))
tell pad & Item_AC & " "
pad = space(5 - len(Item_Value))
tell pad & Item_Value & " gold "
note left(Item_Description, MaxColumns - 22)

Of course you would need to adjust your own column values to make sure it all fits and make sure that the total length of an items name, value, etc. doesn't go over the space you provide for it. If it does, then you will get something like space(5 - 7), which will crash. The last item in the list is designed to show as much of a description as possible for the line. It results in a line that is 79 characters, this is so that you don't get a line wrap resulting from the last character hitting the 80th column and causing two charage returns. It might do this, or it might not, but I prefer to avoid the risk or wondering why every line got doublespaced do to such a mistake. ;)

In any case, it simply comes down to figuring out 'how' you want stuff to appear and setting the right kind of padding to make it do it. numbers get padding added to the left, while strings have it added on the right. Simple. ;)
Australia Forum Administrator #6
Quote:

Umm. Think you missed the point there Nick.


In April, you mean?
Amended on Sun 31 Aug 2003 07:02 AM by Nick Gammon
USA #7
Sigh.... Well, when people reply to posts that are that old... lol

Seriously though, there is no imeddiate way on here to tell 'which' post out of a group of them are new besides the date. I am used to most forums marking them visually in some way that is immediately obvious. Sigh...