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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
complex
Apprentice


Joined: 12 Apr 2004
Posts: 134
Location: USA

PostPosted: Mon Oct 04, 2010 8:07 pm   

Beta Autosell
 
The script is functional now, but still has a few hiccups, I figured since it was really built with the help of the community I would post it up here for narcotizing, and possible suggestions.

Code:

<class name="AutoSell" id="61">
  <class name="SellMatch" id="63">
    <trigger name="matchWeapon" priority="780" trigontrig="false" enabled="false" id="94">
      <pattern>(*)({@drWeapon})</pattern>
      // Check the master list of weapons for matched from your inventory, then add the number to the sell list
      // Pattern matched example (13) A Sword of the Hero
      <value>#switch (%match(%1,"~(( %d)~) ",$num)
      or %match(%1,"~((%d)~) ",$num)) {}
        (%match(%1,"%s"))
        {$num = 1}   
#LOOP $num {sellQueue = %addItem(@drWeapon.%2,@sellQueue)}
</value>
    </trigger>
    <trigger name="trAutoAdd" priority="1120" trigontrig="false" enabled="false" id="112">
      <pattern>You sell (*) for</pattern>
      //Prompt the user for the list to check, once that is done check that master list against the matched value
      //Pattern matched example You sell A Sword of the Hero for 50 gold
      //If that patter is not in the list, then add it.
      <value>#VAR listName %pick("p:Type of item","o:1","weapon","armor")
#SWITCH (@listName="weapon") {
#If (%ismember(%1,@drWeapon)) {}
  { drWeapon = %addkey(@drWeapon,%1,%lastcom) }
} (@listName="armor") {
#If (%ismember(%1,@drArmor)) {}
  { drArmor = %addkey(@drArmor,%1,%lastcom) }
}</value>
    </trigger>
    <trigger name="matchArmor" priority="780" trigontrig="false" enabled="false" id="114">
      <pattern>(*)({@drArmor})</pattern>
      <value>#switch (%match(%1,"~(( %d)~) ",$num)
      or %match(%1,"~((%d)~) ",$num)) {}
        (%match(%1,"%s"))
        {$num = 1}   
#LOOP $num {sellQueue = %addItem(@drArmor.%2,@sellQueue)}
</value>
    </trigger>
  </class>
  <alias name="emptySellQueue" id="69">
    <value>#t- matchArmor
#t- matchWeapon
#if (@sellQueue) {
#SEND {%pop(sellQueue)}
} {
}</value>
  </alias>
  <class name="Lists" id="71">
    <var name="drWeapon" type="Record" id="65">
      <value></value>
      <json>{}</json>
    </var>
    <var name="drArmor" type="Record" id="74">
      <value></value>
      <json>{}</json>
    </var>
    <var name="sellQueue" type="StringList" id="93">
      <json>[]</json>
    </var>
    <var name="listName" id="117">armor</var>
  </class>
  <trigger priority="770" trigontrig="false" id="77">
    <pattern>You sell*</pattern>
    // Toggles the poplist command until the sellQueue is empty.
    <value>emptySellQueue</value>
  </trigger>
  <alias name="sellarmor" id="79">
    <value>#T+ matchArmor
#T- trAutoAdd
i
#WA 2000
EmptySellQueue</value>
  </alias>
  <alias name="sellweapon" id="80">
    <value>#T+ matchWeapon
#T- trAutoAdd
i
#WA 2000
EmptySellQueue</value>
  </alias>
  <trigger priority="1020" trigontrig="false" id="102">
    <pattern>%w tells you 'You don't have that item'.</pattern>
   //Incase a null value got added to the list, check the sellQueue one more time
    <value>emptySellQueue</value>
  </trigger>
  <class name="SellMenu" submenu="true" id="125">
    <menu priority="1260" id="126">
      <caption>Sell armor</caption>
      <value>sellarmor</value>
    </menu>
    <menu priority="1270" id="127">
      <caption>Sell weapon</caption>
      <value>sellweapon</value>
    </menu>
    <menu priority="1280" id="128">
      <caption>Enable Match</caption>
      <value>#t+ trAutoAdd</value>
    </menu>
  </class>
  <menu subclass="SellMenu" priority="1290" id="129">
    //Right click to pull the menu up, before you are selling new items make sure to enable match,
   // selling items disables match to prevent loops.
    <caption>Sell</caption>
  </menu>
</class>


It would be fairly easy to modify this script for another mud, the only portions that would need to be altered would be the patterns. I marked thought the code the portions that would need to be changed, and the examples that I use to match them for my mud.
_________________
<Clever text here>
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Tue Oct 05, 2010 12:36 am   
 
You should also consider posting this to the Package Library
_________________
Asati di tempari!
Reply with quote
complex
Apprentice


Joined: 12 Apr 2004
Posts: 134
Location: USA

PostPosted: Tue Oct 05, 2010 2:21 am   
 
I did not know about that, Im new and all. I will look into it. Very Happy
_________________
<Clever text here>
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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