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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » Finished MUD Scripts
Caled
Sorcerer


Joined: 21 Oct 2000
Posts: 821
Location: Australia

PostPosted: Sun Oct 20, 2002 3:30 pm   

achaean shop pricing script
 
In the following script, I have given the example of someone who wants to drop and price clothing, based on all of the clothes in their inventory which is not worn. I also have another one which drops and prices all the vials in my "elixlist" list.

There are 3 parts to the script.
(1) Aliases to create and edit the pricelist
(2) Triggers to construct a list of items from "info inv"
(3) An alias to drop and price everything

I will list the actual script here, and in the following post I will explain how it works and how to use it. Before going further though, note that while I have verified that this script works for use with elixlist data, I have only tested the "info inv" section by using the zmud editor as a simulator. I did not write that part for myself, but for someone else. It should work, but if there is a bug I missed, let me know and I'll fix it for you.

Feel free also, to suggest other things you would like it to do - I'm happy to work on it further.



#CLASS {Pricingscript}
#ALIAS addpr {#ADDKEY pricelist %1 %2}
#ALIAS prvenom {#LOOPDB @venomlist {#WAIT 150;drop %key;price %key %db( @pricelist, %val)}}
#ALIAS prvials {#LOOPDB @elixlist {#WAIT 150;drop %key;price %key %db( @pricelist, %val)}}
#ALIAS delpr {#DELKEY pricelist %1 %2}
#ALIAS showpr {#SHOWDB @pricelist}
#ALIAS prbelt {#LOOPDB @belts {#WAIT 150;drop %key;price %key %db( @pricelist, %val)}}
#ALIAS prcloak {#LOOPDB @cloaks {#WAIT 150;drop %key;price %key %db( @pricelist, %val)}}
#VAR addpr {}
#VAR pricelist {}
#VAR cloaks {}
#VAR elixlist {}
#VAR venomlist {}
#VAR belts {}
#TRIGGER "infoinv" {^You are holding:$} {cloaks=%null;belts=%null;#T+ pricelist}
#COND "infoinv" {Type MORE to continue reading.} {more} {manual}
#TRIGGER {^You are wearing:$} {#STATE infoinv 0;#T- pricelist}
#TRIGGER {Vial Elixir Sips Months Left} {elixlist=%null;venomlist=%null}
#TRIGGER {vial(%d)%sa|an (%w) salve} {#ADDKEY elixlist %1 %2}
#TRIGGER {vial(%d) %s a salve of (%w)} {#ADDKEY elixlist %1 %2}
#TRIGGER {vial(%d)%san elixir of (%w)} {#ADDKEY elixlist %1 %2}
#TRIGGER {vial%d)%sthe venom (%w)} {#ADDKEY venomlist %1 %2}
#MENU {Add Inv Price} {#PROMPT addpr "What price would you like:";#IF (0 < %pos( " an ", %selline)) {#SHOW %ansi( 14)You have chosen to price %replace( %replace( %right( %selline, %eval( 2+%pos( " an ", %selline))), " ", ""), ".", "") as: %ansi( 13)@addpr %ansi( 14)gold sovereigns.;addpr %replace( %replace( %right( %selline, %eval( 2+%pos( " an ", %selline))), " ", ""), ".", "") @addpr} {#SHOW %ansi( 14)You have chosen to price %replace( %replace( %right( %selline, %eval( 1+%pos( " a ", %selline))), " ", ""), ".", "") as: %ansi( 13)@addpr %ansi( 14)gold sovereigns.;addpr %replace( %replace( %right( %selline, %eval( 1+%pos( " a ", %selline))), " ", ""), ".", "") @addpr}} ""
#MENU {Add Elixlist Price} {#PROMPT addpr "What price would you like:";#IF (%pos( "salve ", %selline) > 0) {addpr %word( %selline, 3) @addpr};#IF (%pos( "a salve of", %selline) > 0) {addpr %word( %selline, 5) @addpr};#IF (%pos( "an elixir of", %selline) > 0) {addpr %word( %selline, 5) @addpr};#IF (%pos( "the venom", %selline) > 0) {addpr %word( %selline, 4) @addpr}} ""
#MENU {Editprice} {#PROMPT addpr "What would you like the new price to be?";addpr %left( %selline, %eval( %pos( ":", %selline)-1)) @addpr} ""
#MENU {Delprice} {delpr %left( %selline, %eval( %pos( ":", %selline)-1)) %right( %selline, %eval( %pos( ":", %selline)+1))} ""
#CLASS 0

#CLASS {Pricingscript|Pricelist}
#TRIGGER {~"belt(%d)~" %s [a|an] (*).} {#ADDKEY belts %1 %replace( %2, " ", "")}
#TRIGGER {~"cloak(%d)~" %s [a|an] (*).} {#ADDKEY cloaks %1 %replace( %2, " ", "")}
#CLASS 0

Caled
Reply with quote
Caled
Sorcerer


Joined: 21 Oct 2000
Posts: 821
Location: Australia

PostPosted: Sun Oct 20, 2002 4:03 pm   
 
In this reply I will explain each part of the script, but I will not explain how to use it until the following reply.

As I said earlier, there are 3 parts to the script.
(1) Aliases to create and edit the pricelist
(2) Triggers to construct a list of items from "info inv"
(3) An alias to drop and price everything

(1) The Pricelist

The prices for each item are stored in a database variable called "pricelist". For those who do not know, a database variable is a list of names, each with a corresponding value. In this case the name is the item type, and the value is the price.

There are two ways to add an item to the list: (1) Direct use of the "addpr" alias, (2) By using the mouse "speedmenus", which is much faster and easier.

If you choose to use the alias method, you should take care to choose the exact same name the speedmenu would choose, otherwise the trigger in later stages will not work. I'll explain that further later on.


(2) The List of Goods

Whenever you type "info inv", or "elixlist", triggers will add items from those in-game lists, to more database variables (one database var for each type of item, eg cloaks, belts, vials, venoms etc). In this case the name is the unique number of the item, and the value is the name of the item (snowhitecloak, mending, health, eurypteria).

The reason I chose to have a separate database variable for each type of item (cloaks, belts, pants, venoms etc) is so the shop can be organised neater, with all the cloaks together, etc.

Triggers will manipulate the "pricelist" class, to ensure you do not try to drop and price stuff you are wearing.

When adding new triggers to the "pricelist" class, create them in the image of the others, but also add the line "newdatabasevarname=%null" to the trigger #TRIGGER "infoinv" {^You are holding:$} {cloaks=%null;belts=%null;#T+ pricelist}



(3)Dropping-and-Pricing Aliases

These aliases sort through the database variable in question, check the corresponding price for each, then drop and price each item.

I have used a #WAIT command in these aliases. It is there because Achaea tends to dislike it if you spam too much. If you find yourself still getting the "You must wait a while before you can do that" message, increase the "#WAIT 150" to "#WAIT 200"




Caled
Reply with quote
Caled
Sorcerer


Joined: 21 Oct 2000
Posts: 821
Location: Australia

PostPosted: Sun Oct 20, 2002 4:26 pm   
 
Yep, there are three stages to operate the system:
(1) Getting the pricelist right
(2) Typing "info inv", or "elixlist"
(3) Running the drop-and-price aliases


(1) Setting prices (info-inv)
An example of info-inv data, is:
"cloak1111" an azure cloak.

Adding a New Item
Using the mouse, place the cursor so that it is somewhere over the line in "info-inv" which represents the item you wish to choose a price for. Right-click with the mouse, and choose "Add Inv Price" from the right-click menu.
When asked to enter the price you wish, type in the number and press enter.
The item is now in the pricelist with the price you selected.

This method automatically chooses the correct name for the item. This is important for the triggers to work later on. The name chosen in this case would be:
azurecloak
The important part being the lack of spaces, and choosing everything after the "an", yet not the period (.)

If you choose to enter the name directly for some reason, using the "addpr" alias, you would do so by typing the following:
addpr azurecloak 450
where 450 is the price

I stress again though - if you do it this way, get the name right....


Viewing the Pricelist
This is done by running the alias called "showpr"

Changing a Price
After viewing the pricelist, use the mouse to place the cursor over the item in the pricelist you wish to change, right-click and choose "Editprice". Enter the new price when prompted.

Alternatively, you could type "info inv", and simply re-add the item to the list - it will override the current one and will not create multiple entries of the same item.

Deleting an Item from the List
Run the "showpr" alias. Right-click the item you wish to delete. Choose "Delprice".


Notes for Elixlist Data
Use the same process for elixlist data, the only difference being that naming manually is easier - mending, restoration, curare, etc. There are only two groups in the elixlist data - venoms, and all the others.


(2) Typing "Info Inv", and "Elixlist"

If you need instructions on how to do this, go back to primary school

(3) Running the Drop-and-Price Aliases

The drop and price aliases are all named something like:
prvial
prcloak
prbelt

All you do is run one, wait till its finished, then run the next one. Dont forget that the order in which you run them determines the order in which types of items appear in your shop's wares list. To use this system to organise your shop neatly though, you need to pick everything up off the floor first - but you should not have to do that every day, just when it is getting a bit messy.

Don't forget to put your own stuff away before picking it all up though, especially with vials. Sorting vials out sucks.



Caled
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » Finished MUD Scripts 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