drexor Newbie
Joined: 21 Aug 2008 Posts: 4 Location: Topeka, KS
|
Posted: Thu Aug 28, 2008 7:36 pm
Named numbers and -TH wording |
the mud i play on frequently uses commands like:
read first page
take coins from fourth corpe
etc
usually not a hassle, until you start getting to things like examine one hundred fifty seventh herb
so i made a few aliases to handle this for me:
nn {verb} {number} {object}
nn read 57 page --> read fifty seventh page
NamedNumber {number}
stores the string version of the number in @VarNamedNumber
NamedNumberIth
argumentless, updates the @VarNamedNumber variable to -th wording
one becomes first, two second, etc
supports up to 999,999,999, easily updateable beyond that with addidtions to the @NamedNumbers variable listed below
written in 5.55, so there's quite a bit of back support
Dependancies:
Variable NamedNumbers
Code: |
one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty|thirty|fourty|fifty|sixty|seventy|eighty|ninety|hundred|thousand|million |
Alias NamedNumber
Code: |
#VA VarNamNum ""
#VA VarNamNumT ""
#VA VarNumNam %1
#VA VarNumNamT %trim(%format("&10.0n",@VarNumNam))
#IF (%len(%eval(%word(@VarNumNamT,1,",")))=3) {#VA VarNamNum %concat(%item(@NamedNumbers,%left(%word(@VarNumNamT,1,","),1))" ",@VarNamNum)
#VA VarNamNum %concat(@VarNamNum,%item(@NamedNumbers,28)" ")
#VA VarNumNam %rightback(@VarNumNam,%len(@VarNumNam)-1)
#VA VarNumNamT %trim(%format("&10.0n",@VarNumNam))}
#IF (%eval(%word(@VarNumNamT,1,",")<20) AND %eval(%word(@VarNumNamT,1,",")>9)) {#VA VarNamNum %concat(@VarNamNum,%item(@NamedNumbers,%eval(%word(@VarNumNamT,1,",")))" ")
#VA VarNumNam %rightback(@VarNumNam,%eval(%len(@VarNumNam)-%len(%word(@VarNumNamT,1,","))))
#VA VarNumNamT %trim(%format("&10.0n",@VarNumNam))}
#IF (%len(%eval(%word(@VarNumNamT,1,",")))=2) {#VA VarNamNum %concat(@VarNamNum,%item(@NamedNumbers,%eval(%left(%word(@VarNumNamT,1,","),1)+18))" ")
#VA VarNumNam %rightback(@VarNumNam,%len(@VarNumNam)-1)
#VA VarNumNamT %trim(%format("&10.0n",@VarNumNam))}
#IF (%len(%eval(%word(@VarNumNamT,1,",")))=1) {#VA VarNamNum %concat(@VarNamNum,%item(@NamedNumbers,%left(%word(@VarNumNamT,1,","),1))" ")
#VA VarNumNam %rightback(@VarNumNam,%len(@VarNumNam)-1)}
#IF (%len(@VarNumNam)=3) {#VA VarNamNum %concat(@VarNamNum,%item(@NamedNumbers,29)" ")}
#IF (%len(@VarNumNam)=6) {#VA VarNamNum %concat(@VarNamNum,%item(@NamedNumbers,30)" ")}
#IF (%len(@VarNumNam)=9) {#VA VarNamNum %concat(@VarNamNum,%item(@NamedNumbers,31)" ")}
#VA VarNamedNumber %concat(@VarNamedNumber,@VarNamNum)
#IF (%eval(@VarNumNam)>0) {NamedNumber @VarNumNam}}
|
Alias NamedNumberIthWord
Code: |
#VA VarNamedNumber %trim(@VarNamedNumber)
#VA VarNamedNumberIth ""
#VA VarLastNamedNumber %word(@VarNamedNumber,%eval(%numwords(@VarNamedNumber)))
#IF (@VarLastNamedNumber="one") {#VA VarNamedNumberIth "first"}
#IF (@VarLastNamedNumber="two") {#VA VarNamedNumberIth "second"}
#IF (@VarLastNamedNumber="three") {#VA VarNamedNumberIth "third"}
#IF (%rightback(@VarLastNamedNumber,1) ="y" AND @VarNamedNumberIth="") {#VA VarNamedNumberIth %left(@VarLastNamedNumber,%len(@VarLastNamedNumber)-1)"ieth"}
#IF (%rightback(@VarLastNamedNumber,2) ="ve" AND @VarNamedNumberIth="") {#VA VarNamedNumberIth %left(@VarLastNamedNumber,%len(@VarLastNamedNumber)-2)"fth"}
#IF (%rightback(@VarLastNamedNumber,1) ="t" AND @VarNamedNumberIth="") {#VA VarNamedNumberIth %left(@VarLastNamedNumber,%len(@VarLastNamedNumber)-1)"th"}
#IF (%rightback(@VarLastNamedNumber,1) ="e" AND @VarNamedNumberIth="") {#VA VarNamedNumberIth %left(@VarLastNamedNumber,%len(@VarLastNamedNumber)-1)"th"}
#IF (@VarNamedNumberIth="") {#VA VarNamedNumberIth %concat(@VarLastNamedNumber,"th"}
#VA VarNamedNumber {%concat(%left(@VarNamedNumber,%len(@VarNamedNumber)-%len(%word(@VarNamedNumber,%eval(%numwords(@VarNamedNumber))))),@VarNamedNumberIth}
|
Alias nn
Code: |
#VA VarNamedNumber ""
#VA VarNamNum ""
#VA VarNumNam ""
NamedNumber {%2}
NamedNumberithWord
%1 @VarNamedNumber %3
|
Hope it helps some of you
DreX |
|