Mar 212009
 

Achaea MUD ZMud huge script to store all the contents of shops. You can then interrogate the database to find the cheapest cost of any item.

#CLASS {Aliases|aSystem|ShoppingA}
#ALIAS _DelShop {;  DBOFFLINE causes delete to fail it simply doesn't delete  anything;;#PRIORITY {;#DBLOAD Shop;#DBFIRST;#IF (%null( %1)) {#VIEW  Current} {#VIEW CurrentDen};#DBFIRST;;  #DBOFFLINE;#WHILE (not %null(  %rec)) {#DBDELETE &num};;  #DBONLINE;;  #DBRESET }
#ALIAS  _UpdateShops {#PRIORITY {#DBRESET;#DBLOAD Shop;#DBFIRST;#VIEW All;#QUERY  ((&Date<%time( yyyy:mm:dd)) and (&Update=1)) Shops  1;#DBFIRST;#EXEC _Debug {Found Room: %roomname( &RoomId)};#WHILE  (%null( %walk( &RoomId)) and not %null( %rec)) {#DBNEXT;#WAIT  10};#SLOW %walk( &RoomID);#DBRESET}}
#ALIAS _SetUpdate {#PRIORITY  {#DBLOAD Shop;#DBFIRST;#WHILE (!%null( %rec)) {#DBPUT &Num  Update=1;#DBNEXT}}}
#ALIAS _PutRoomNumbers {#PRIORITY {#DBLOAD  Shop;#VIEW All;#QUERY ((&RoomId=0)&(&Update=1)) Shops  1;#DBFIRST;#WHILE (not %null( %rec)) {#VAR SQLString "" _nodef  ShoppingA;#VAR PutRoomNumbersFound 0 _nodef ShoppingA;SQLString =  {[Name] = '%replace( &Room, "'", "''")'};#VAR  PutRoomNumbersFoundRooms %mapquery( @SQLString) _nodef ShoppingA;#IF  (%numitems( @PutRoomNumbersFoundRooms)=1) {#DBPUT &Num  {RoomID=%roomnum( @PutRoomNumbersFoundRooms)|ZoneID=%roomzone(  @PutRoomNumbersFoundRooms)}};#DBNEXT};#DBRESET}}
#ALIAS  _UpdateAllShops {#WHILE (True) {#EXEC _UpdateShops;#WHILE %inwalk {#WAIT  1000};#EXEC _SendCommandOnPrompt wares;#WAIT 5000}}
#ALIAS  _FindListLess {#PRIORITY {#VAR SQLString "" _nodef ShoppingA;#VAR  FindListLessFound 0 _nodef ShoppingA;#VAR FindListLessWalking 0 _nodef  ShoppingA;;SQLString = {[Color] = 16744703};#VAR FindListLessFound  %mapquery( "[Color] = 16744703") _nodef ShoppingA;#DBOFFLINE;#DBLOAD  Shop;#DBFIRST;#VIEW All;#FORALL @FindListLessFound {#IF (not  @FindListLessWalking) {#QUERY ((&RoomId=%i)&(&Update=1))  Shops 1;#DBFIRST;#IF (%null( %rec)) {#EXEC _Debug {Walking to %roomname(  %i) ID: %i};#SLOW %walk( %i);FindListLessWalking =  1};#DBRESET}};#DBONLINE}}
#ALIAS _FindListLessB {#PRIORITY {#VAR  SQLString "" _nodef ShoppingA;#VAR FindListLessFound 0 _nodef  ShoppingA;#VAR FindListLessWalking 0 _nodef ShoppingA;#VAR  FindListLessRecords "" _nodef ShoppingA;;SQLString = {[Color] =  16744703};#VAR FindListLessFound %mapquery( "[Color] = 16744703") _nodef  ShoppingA;#DBOFFLINE;#DBLOAD Shop;#DBFIRST;#VIEW All;#FORALL  @FindListLessFound {#IF (not @FindListLessWalking and %eval( %ismember(  %i, @FindListLessAlreadyChecked)=0)) {FindListLessRecords = %query(  (&RoomId=%i)&(&Update=1), All|sh);#IF (%null(  @FindListLessRecords) and not %null( %db( @FindListLessRecords.1,  Update))) {#EXEC _Debug {Walking to %roomname( %i) ID: %i};#SLOW %walk(  %i);FindListLessWalking = 1;#DBRESET} {#ADDITEM  FindListLessAlreadyChecked %i}}};#DBONLINE}}
#ALIAS _ShopQuery  {sShopQuery = %1;#VAR QueryShopSearching 0 _nodef ShoppingA;#VAR  QueryShopResults "" _nodef ShoppingA;#PRIORITY {#DBOFFLINE;#DBLOAD  Shop;#DBFIRST;#VIEW MyQuery;#DBFIRST;#IF (%null( %rec)) {" ";#ECHO None  Found} {#WHILE (@QueryShopSearching <> 10) {QueryShopResults =  %additem( {~>~> &Description from &Room costs &Cost  ~<~<}, @QueryShopResults);#DBNEXT;#IF (%null( %rec))  {QueryShopSearching = 10};#ADD QueryShopSearching 1}};#IF (not %null(  @QueryShopResults)) {#IF (%null( %2)) {" ";#ECHO %replace(  @QueryShopResults, "|", %crlf)} {msg write %2  @QueryShopResults}};#DBONLINE;#DBRESET}}
#ALIAS _SendWhatever {#VAR  QueryShopSearching 1 _nodef ShoppingA;#VAR QueryShopResults "" _nodef  ShoppingA;#PRIORITY {#DBLOAD Shop;#DBFIRST;#VIEW WhatEver;#DBFIRST;#IF  (%null( %rec)) {" ";#ECHO None Found} {#WHILE (@QueryShopSearching)  {#ADDITEM QueryShopResults {~>~> &Description from &Room  costs &Cost ~<~<};#DBNEXT;;      #ECHO %eval( %numitems(  @QueryShopResults)=10);QueryShopSearching = %if( (%null( %rec)) or  (%eval( %numitems( @QueryShopResults)=20)), 0, 1)}};#IF (not %null(  @QueryShopResults)) {#IF (%null( %1)) {" ";#ECHO %replace(  @QueryShopResults, "|", %crlf)} {msg write to %1  @QueryShopResults}};#DBRESET}}
#ALIAS _ReSetShopNames {#DBLOAD  Shop;#DBFIRST;#VIEW All;#DBFIRST;#WHILE (not %null( %rec))  {&DenShopName = "";#DBNEXT}}
#ALIAS _AskChattyForWares {#VAR  ChattD "" _nodef ShoppingA;#DBLOAD Items;#DBFIRST;#VIEW  DenizensChatty;#DBFIRST;#WHILE (not %null( %rec)) {#ADDITEM ChattD  &RoomId;#DBNEXT};#WHILE (not %null( @ChattD)) {#SLOW %walk( %pop(  ChattD));#WHILE (%inwalk) {#WAIT 1000};#EXEC _SendCommandOnPrompt  "ih";#WAIT 1000;#LOOPDB @RoomObjects {#VAR AskingD %find( {%val},  DenizensChatty|Items, Name) _nodef ShopA;#IF (not %null( @AskingD))  {#VAR AskKey "" _nodef ShopA;#NOOP %match( {%key}, "(%w)", AskKey);#EXEC  _SendCommandOnPrompt "ask @AskKey wares";#WAIT 3000}}}}
#VAR  SQLString {Name = 'Centre Crossing.'}
#VAR UpdateShopsFoundRooms  {166|1626|1968|2906}
#VAR PutRoomNumbersFound {0}
#VAR  FindListLessFound {}
#VAR FindListLessWalking {0}
#VAR  FindListLessRecords  {2041sh|2042sh|2043sh|2044sh|2045sh|2046sh|2047sh|2048sh|2049sh|2050sh|2051sh|2052sh|2053sh}
#VAR  FindListLessAlreadyChecked  {63|135|145|163|165|166|168|169|170|171|174|176|178|179|181|183|185|186|187|188|190|191|196|218|220|221|223|252|253|254|255|258|260|261|267|824|826|872|1546|1547|1548|1549|1550|1552|1557|1558|1585|1597|1598|1599|1600|1601|1602|1603|1609|1610|1611|1615|1616|1626|1661|1727|1728|1729|2752|2753|2755|2758|2870|2872|2873|3510|1961|1968|1969|1970|1971|1972|1973|1974|1975|1976|1977|2013|2034|2046|2336|2381|2540|2541|2542|2543|2544|2545|2546|2548|2549|2554|2567|2568|2574|2576|2580|2581|2585|2586|2587|2601|2602|2603|2614|2622|2655|2656|2658|2659|2661|2662|2665|2667|2670|2672|2674|2747|2773|2888|2889|2890|2891|2892|2893|2894|2895|2897|2900|2901|2904|2905|2906|2907|2908|2909|3044|3145|3146|3148|4831|2903|2911|2960|2961|3014|3032|3035|3036|3037|3096|3170|3174|5857|4814|4816|4823|5220|5243|5448|5503|5504|5605|5606|5644|5645|5646|5647|6149|6178|6875|7078|7209|7230|7441|7487|7489|7491|7534|7552|7560|7593|7860|7887|7921|6148|7923|7924|7926|7928|7929|7931|7932|7933|7937|7941}
#VAR  sShopQuery {Bloodroot}
#VAR QueryShopSearching {10}
#VAR  QueryShopResults {>> a bloodroot leaf from This and That. costs 50  <<|>> a group of 5 bloodroot leaves from Ogre's Arms and  Armour. costs 100 <<|>> a bloodroot leaf from The  Sarcophagus. costs 100 <<|>> a bloodroot leaf from The  Sarcophagus. costs 100 <<|>> a bloodroot leaf from The  Sarcophagus. costs 100 <<|>> a bloodroot leaf from The  Sarcophagus. costs 100 <<|>> a group of 10 bloodroot leaves  from The Tent. costs 250 <<|>> a group of 10 bloodroot  leaves from Lunar Crossroads. costs 300 <<|>> a group of 10  bloodroot leaves from Enlightened Imports. costs 300 <<|>> a  group of 10 bloodroot leaves from Shop of the Black Lotus. costs 300  <<}
#VAR WhereIsFound {2046}
#VAR DenShopName {}
#VAR  ChattD {}
#ONINPUT "TrigWares" {^wares$} {#BUTTON bHeartBeat;#EXEC  _DelShop;#VAR DenShopName "" _nodef ShoppingA;#BUTTON  bHeartBeat;#DBOFFLINE;#VAR _RunOnPrompt "#DBONLINE" "" Stats;#ADDKEY Mud  ResetTrigger TrigWares;#T+ TrigNewPrompt;#TEMP TrigCommsShop  {^Commodity%sWe Buy At%sStock%sWe Sell At%s$} {#STATE TrigWares 2}  ShoppingA}
#COND {^%s(%w%d) (*%x)%s(%d)%s(%d){gp|cr}$} {#NEW  Current|sh  {Room=@sRoomName|Item=%1|Description=%2|Count=%3|Cost=%4|Date=%time(  yyyy:mm:dd)|ZoneId=%zonenum|RoomId=%roomnum}} {looplines|param=999}
#COND  {^(%w)%s(%x)[ gp]%s(%d)%s(%d) gp$} {#NEW Current|sh  {Room=@sRoomName|Item=%1|Description=%2|Count=%3|Cost=%4|Date=%time(  yyyy:mm:dd)|ZoneId=%zonenum|RoomId=%roomnum}} {looplines|param=100}
#ONINPUT  "TrigMore" {^more$} {#IF  ((@Mud.CommandLast=wares)or(@Mud.CommandLast=more)) {#DBOFFLINE;#STATE  TrigWares 1;#VAR _RunOnPrompt "#DBONLINE" "" Stats;#ADDKEY Mud  ResetTrigger TrigWares;#T+ TrigNewPrompt}}
#TRIGGER "TrigShopMore"  {^Type MORE to continue reading. ~(%d~% shown~)$} {_SendCommandOnPrompt  more} "" {case}
#TRIGGER {~"I have nothing to sell.~"$} {#STATE  TrigWaresDen 0;#VAR AskingD "" _nodef ShopA}
#ONINPUT "TrigWaresDen"  {^ask (%w) wares$} {#EXEC _DelShop %1;#VAR DenShopName %1 _nodef  ShoppingA;#DBOFFLINE;#VAR _RunOnPrompt "#DBONLINE;#DBRESET;#VIEW All" ""  Stats;#ADDKEY Mud ResetTrigger TrigWaresDen;#T+ TrigNewPrompt;;#TEMP  TrigCommsShop {^Commodity%sWe Buy At%sStock%sWe Sell At%s$} {#STATE  TrigWares 2} ShoppingA}
#COND {^%s(%w%d) (*%x)%s(%d)%s(%d){gp|cr}$}  {#IF (not %null( @AskingD)) {#DBPUT @AskingD Sells=1;AskingD = ""};#NEW  CurrentDen|sh {Room=@sRoomName} {Item=%1} {Description=%2} {Count=%3}  {Cost=%4} {DenShopName=@DenShopName} {Date=%time( yyyy:mm:dd)}  {ZoneId=%zonenum} {RoomId=%roomnum}} {looplines|param=999}
#COND  {^(%w)%s(%x)[ gp]%s(%d)%s(%d) gp$} {#NEW CurrentDen|sh  {Room=@sRoomName|Item=%1|Description=%2|Count=%3|Cost=%4|DenShopName=@DenShopName|Date=%time(  yyyy:mm:dd)|ZoneId=%zonenum|RoomId=%roomnum}} {looplines|param=100}
#TRIGGER  {^There is nothing for sale here.$} {#STATE TrigWares 0}
#CLASS 0
Share

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>