Elanthipedia Shops (script)

From Elanthipedia
Revision as of 03:24, 3 November 2011 by ISHARON (talk | contribs)
Jump to navigation Jump to search
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 experienced 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.

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

  1. Weapon
  2. Shield
  3. Armor/Barding
  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 {sv} {#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 these triggers to set the currency variable. (Appraise something once to set it.)

#trigger {^You .+ worth .+ dokoras} {#var currency Dokoras}
#trigger {^You .+ worth .+ kronars} {#var currency Kronars}
#trigger {^You .+ worth .+ lirums} {#var currency Lirums}



You must install these triggers to set the preposition variable. (Appraise something once to set it.)

#trigger {^In .+, you see:$} {#var preposition in}
#trigger {^On .+, you see:$} {#var preposition on}
#trigger {^Under .+, you see:$} {#var preposition under}

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

11/2/2011

  • Added barding (horse armor) to the menu.

05/23/2011

  • The script now uses triggers to set the currency and preposition variables.

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

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            =n
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,Wedding
put #log >Shop.txt |Fest             =Hollow Eve Festival 403
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/Barding
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