Elanthipedia Shops (script): Difference between revisions

From Elanthipedia
Jump to navigation Jump to search
Line 101: Line 101:


action setvariable shopheader $1 when ^(.+), you see:$
action setvariable shopheader $1 when ^(.+), you see:$
action setvariable tap $2 when ^You tap (a|an|some|the) (.+) (atop|inside) (an?|some)
action setvariable tap $2 when ^You tap (a|an|some|the) (.+) (atop|inside|under) (an?|some)
action setvariable short $2 when ^Short: (a|an|some|the) (.+)
action setvariable short $2 when ^Short: (a|an|some|the) (.+)
action setvariable costi $1 when ^Cost:\s+(\d+) (Kronars|Lirums|Dokoras)
action setvariable costi $1 when ^Cost:\s+(\d+) (Kronars|Lirums|Dokoras)


send shop $shop
send shop $shop
waitforre ^(On|In).+, you see:$
waitforre ^(On|In|Under).+, you see:$


if_2 goto ShopDesc
if_2 goto ShopDesc

Revision as of 00:42, 23 May 2011

Elanthipedia Shops (script)
Category information
Front-end Genie
Author Isharon


This script creates Elanthipedia forms for shops (that use the SHOP verb). The results are logged to the Shop file in Genie's Logs folder.

This script is intended for experience Elanthipedia contributors only. The forms that are created by this script require some manual editing. (See below for details.) Please check for errors before posting them to Elanthipedia.

Instructions

Syntax

.ESHOP [ITEM NOUN] (YES): Type yes if you want the script to create the Store At A Glance and ShopDescription sections. Otherwise, just type the item noun. (Store At A Glance is used once per shop. ShopDescription is used once per room.

Most of the time, the script needs to type shop/appraise X on Y, but sometimes, the required preposition is in. In these cases, edit the first line of the script before running it:

setvariable preposition on

A menu will prompt you to select the type of item you're adding:

  1. Weapon
  2. Shield
  3. Armor
  4. Item: Clothing
  5. Item: Jewelry
  6. Item: Housing
  7. Item: Food/Drink
  8. Item: Other


Required Genie Settings

You must install and use this alias to set the shop surface variable.

#alias {shopv} {#var shop $0}


The "shop surface" is the thing on which the item is placed (for example, table, second rack, or oak shelf).

You must install and run this script to set your currency variable. (It only needs to be run once unless you go to another province.) If you don't wear a ring, change the item to something that you wear.

put app my ring quick

matchre dokoras ^You .+ worth .+ dokoras
matchre kronars ^You .+ worth .+ kronars
matchre lirums ^You .+ worth .+ lirums
matchwait

dokoras:
put #var currency Dokoras
goto end

kronars:
put #var currency Kronars
goto end

lirums:
put #var currency Lirums
goto end

end:

echo
echo Currency set to $currency
echo

Required Manual Editing

Store At A Glance and ShopDescription

The script will add "Store At A Glance" and "ShopDescription" every time you run it. Delete all but the first ones.

Store Name: You'll probably need to edit this, as most room names have extra text. For example, if the room is "Gersvinda's Natural Studies, Studio," it should be changed to just "Gersvinda's Natural Studies."

ShopDescription

If there is not a "You also see" line in the room, the script will print a line that is only one line break (<br>). Delete that.

Changelog

05/13/2011

  • The script now adds the room objects and room exits to the ShopDescription.
  • Fixed a bug that caused the script to list the last item twice.
  • The "Store At A Glance" and "ShopDescription" sections are now optional.

05/14/2011

  • Added store types to "Store At A Glance." (Erase the ones that don't apply to the shop that you're editing.)

Script

put #class rp on
put #class combat off
put #class arrive off

setvariable preposition on
var source $roomname
action goto end when ^I could not find what (you|you were) referring to\.$
var numbers first|second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth|eleventh
var numbers.index 0

action setvariable shopheader $1 when ^(.+), you see:$
action setvariable tap $2 when ^You tap (a|an|some|the) (.+) (atop|inside|under) (an?|some)
action setvariable short $2 when ^Short: (a|an|some|the) (.+)
action setvariable costi $1 when ^Cost:\s+(\d+) (Kronars|Lirums|Dokoras)

send shop $shop
waitforre ^(On|In|Under).+, you see:$

if_2 goto ShopDesc
goto StartShop

ShopDesc:
put #log >Shop.txt {{Store At A Glance
put #log >Shop.txt |Store Name       =$roomname
put #log >Shop.txt |Province         =
put #log >Shop.txt |Town             =
put #log >Shop.txt |MapNumber        =
put #log >Shop.txt |Owner            =
put #log >Shop.txt |NumRooms         =
put #log >Shop.txt |restrict         =
put #log >Shop.txt |levelres         =
put #log >Shop.txt |Store Type       =guild,Alchemy,Armor,Barber,Casino,Clothing,Container,Cosmetics,Drink,Dye,Embroidery,Engraving,Face Painting,Fishing Supply,Fletching,Florist,Food,Forging Supply,Gem,General,Heraldry,Herb,Horse,Housing,Jewelry,Locksmithing,Magic,MAMAS,Map,Miscellaneous,Music,Origami,Perfume,Pet,Repair,Shield,Tack,Tanning,Tattoo,Tobacco,Trinket,Weapon
put #log >Shop.txt |Fest             =
put #log >Shop.txt |Coin             =$currency
put #log >Shop.txt }}

put #log >Shop.txt {{ShopDescription
put #log >Shop.txt |roomname=$roomname
put #log >Shop.txt |desc=$roomdesc<br>
put #log >Shop.txt $roomobjs<br>
put #log >Shop.txt $roomexits
put #log >Shop.txt }}
put #log >Shop.txt

StartShop:
put #log >Shop.txt "{{ShopHeader|title=%shopheader}}"
echo
echo ITEM TYPE:
echo
echo 1:	Weapon
echo
echo 2:	Shield
echo
echo 3:	Armor
echo
echo 4:	Item: Clothing
echo
echo 5:	Item: Jewelry
echo
echo 6:	Item: Housing
echo
echo 7:	Item: Food/Drink
echo
echo 8:	Item: Other
echo
echo Enter Type Number:

matchre Weapon ^1
matchre Shield ^2
matchre Armor ^3
matchre Clothing ^4
matchre Jewelry ^5
matchre Housing ^6
matchre Food ^7
matchre Item ^8
matchwait

Weapon:
var type w
goto Shop1
Shield:
var type s
goto Shop1
Armor:
var type a
goto Shop1
Clothing:
var type c
goto Shop1
Jewelry:
var type j
goto Shop1
Housing:
var type h
goto Shop1
Food:
var type f
goto Shop1
Item:
var type i
goto Shop1

Shop1:
var number %numbers(%numbers.index)
gosub Shop2
math numbers.index add 1
if %numbers.index > 11 then goto end
goto Shop1

number1:
var number first
return
number2:
var number second
return
number3:
var number third
return
number4:
var number fourth
return
number5:
var number fifth
return
number6:
var number sixth
return
number7:
var number seventh
return
number8:
var number eighth
return
number9:
var number ninth
return
number10:
var number tenth
return
number11:
var number eleventh
return

Shop2:
send tap %number %1 %preposition $shop
waitforre ^You
send shop %number %1 %preposition $shop
waitforre ^Short
pause
gosub CommaCost
put #log >Shop.txt "{{ShopItem|t=%type|%tap|%cost}}"
put #log >Shop.txt
return

CommaCost:
var commanumber %costi
eval length len(%commanumber)
var cost %commanumber
if %length < 4 then goto return
evalmath length %length - 3
eval temp substr(%commanumber, %length, 3)
var cost %temp
topcost:
if %length < 3 then goto lastcost
evalmath length %length - 3
eval temp substr(%commanumber, %length, 3)
var cost %temp,%cost
goto topcost
lastcost:
if %length > 0 then
{
eval temp substr(%commanumber, 0, %length)
var cost %temp,%cost
}
goto return

return:
return

end:
put #log >Shop.txt |}
send shop
waitfor [Type SHOP [ITEM] to see what's on it.]
send shop $shop
waitfor [Type SHOP [GOOD] to see some details about it.]
echo Last noun: %1 (%preposition $shop)
exit