Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
dragonheart
Beginner


Joined: 09 Jun 2002
Posts: 15
Location: Norway

PostPosted: Sat Sep 30, 2006 12:58 pm   

List extraction and sorting
 
Greetings again all geniuses Very Happy
Again I have a certain "need" in the lands I play, and this is my idea.

When typing for example goods in a store, I get the following matrix up:
Code:

Sword     400g  900g   5      Mace       200g  400g   4
Knife     50g   200g   3      Axe        200g  400g   10
Staff     10g   100g   10     Sling      100g  200g   1
Pebble    1g    10g    3000

(due to font and such it doesn't always come neatly under each other. but anyways, that's not my real problem)
What I would like to do is to run through about 12 stores, extract the different fields (they're the same all the time, so that's a constant at least), keep the values, and then at the end present me with a list of stores whereI can buy one special item.
For instance, I'd like a listbutton where "Sword, Knife, Staff, Pebble, Mace, Axe and Sling" is listed. Then run through the 12 different stores (I can do that with one command so that's not an issue) look at the content, and at the end give me a list like this for example:

Code:

Swords found at:
Breland      2      200g   400g
Gothia        10    200g   400g
Southshore 3      220g   400g
Nivlheim     30    150g   500g
etc etc.


First column should be place they're found at, second is buy price, and third is sell price.

I'm not good at programming so I need to ask you wizards for help again. Anyone daring to venture along this with me?

I am very grateful for any help on this one.

Thanks

Best regards,
Dragonheart

--
Edit: TD code tags added to attempt to get the formatting viewed right
_________________
Best regards,

Dragonheart
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Tue Oct 03, 2006 10:00 am   
 
There are a few further requirements.

First is a few lines before and after the inventory list. This is needed so that the triggers begin and end capturing at the right times.

Second will be some way of identifying which shop is being captured. If this is part of some header information at the beginning of the inventory list then great; otherwise you will have to supply it. Some possible ways you could supply it are from the mapper information, or as an additional parameter to the command that causes the list to be shown.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
dragonheart
Beginner


Joined: 09 Jun 2002
Posts: 15
Location: Norway

PostPosted: Wed Oct 04, 2006 10:29 am   
 
Ok, there are two lines on top of this list.
Something like
Code:
Type    Stock    Buy    Sell    Type   Stock   Buy    Sell
===================================



There is no indicator on which shop I'm looking at. I can look at all shops from one location (some privileges I have in my city)
I can type "tradestock Breland", "tradestock Nivlheim" etc. Then I get the two line heading plus the list underneath.

I hope this helps...

Edit Vijilante: Added code tags to preserve formatting.
_________________
Best regards,

Dragonheart
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Oct 05, 2006 1:02 am   
 
Alright you seem to have missed that I need some sort of ending line, so I will wing it and guess a blank line. Also this entire thing will be written off the top of my head with no testing, good luck.
Code:
#CLASS ShopCapture
#VARIABLE ShopList {}
#VARIABLE TempShopCap {} {}
#ONINPUT "ShopCap" {^tradestock (%w)$} {#VARIABLE {%1} {} {_nodef} {ShopCapture}}
#CONDITION {^===================================$} {TempShopCap=""} {case}
#CONDITION {} {#IF (%line!="") {#ADDITEM TempShopCap {%insert("`",%line,29}} {#STATE ShopCap 4;#SET ShopCap 4 0} {Lopplines|param=20}
#CONDITION {*} {#SHOW Error In ShopCapture, excceded 20 line limit.}
#CONDITION {} {TempShopCap=%subchar(@TempShopCap,"| ","`|");#DELITEM TempShopCap {};TempShopCap=%subchar(@TempShopCap,"`|","| ");#FORALL @TempShopCap {#ADDKEY %t1 {%word(%i,1)} {%replace(%remove(%concat(%word(%i,1)," "),%i)," ","|")}};#ADDITEM ShopList {%t1};#STATE ShopCap 0}} {manual}
#ALIAS shoplist {#IF (%numparam=0) {#SHOW Usage shoplist itemType} {#FORALL @ShopList {#LOOPDB @{%i} {#IF (%lower(%1)=%lower(%key)) {#SHOW %key %word(%val,3) %word(%val,1) %word(%val,2)}}}}}
#CLASS 0

That should about cover it. I will leave it up to you to create buttons if you want. Otherwise shoplist wherever should do once you have captured some information. There might be some 'syntax errors' if you examine all of it, but as long as all the script looks to be there then it is right.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net