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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
OmegaDeus
Apprentice


Joined: 14 Sep 2005
Posts: 121

PostPosted: Thu Oct 13, 2005 4:46 pm   

Smart Spell Translation
 
I'm working on what I'd like to call a smart spell translation script. This means that using the rom translation keys, i can translate all spells to readable words, even if they add new spells. I've got the full list of what rom uses to translate a spell into the arcane words. Such as Cure Light = Judicandus Dies. But I'm having some trouble getting this to work, I don't know where to start to get just the spell to translate, without translating the whole mud.

Pattern:
%1 utters the words '(*)'

List:
abra = ar
kada = au
fido = bless
nose = blind
mosa = bur
judi = cu
oculo = de
unso = en
dies = light
hi = lo
zak = mor
sido = move
lacri = ness
illa = illa
duda = per
gru = ra
ima = fresh
re = candus
sabru = son
infra = tect
cula = tri
nofo = ven
a = a
b = b
q = c
e = d
z = e
y = g
o = h
p = h
u = i
y = j
t = k
r = l
w = m
i = n
a = o
s = p
d = q
f = r
g = s
h = t
j = u
z = v
x = w
n = x
l = y
k = z

What I'm looking to have it do:
Mercy the Healer utters the words 'Judicandus Sausabru'-> Mercy the Healer utters the words 'Cure Poison'

One of the things that I can also see that will be an issue for me, is getting it so once something is translated it's not subject to be re-translated

ex:
Judicandus - > cure -> cild

[edit] Also, when someone the same class as myself casts a spell, I don't see Blah utters the words 'wuffaf uwayz' I see Blah utters the words 'mirror image' and I don't wanna mess that up.

Any ideas on where to get started with this would be greatly appreciated.
_________________


Look at me I've got zSKILLS
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Oct 13, 2005 8:49 pm   
 
Do all your translations in a single trigger. This eliminates the problems of repeated translations. Next do all your translations as a single #SUBSTITUE, this would be accomplished by nesting %replaces inside a %subchar. The list you have for %subchar needs some work though:
Quote:
a = a
b = b
q = c
e = d
z = e
y = g
o = h
p = h
u = i
y = j
t = k
r = l
w = m
i = n
a = o
s = p
d = q
f = r
g = s
h = t
j = u
z = v
x = w
n = x
l = y
k = z
Note the "a=a" and 15 or so lines down "a=o". You would have to first build the series of %replaces for the syllables and then coordinate them with your subchar list. Some syllables may even need to be mistranslated to work within the %subchar.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
OmegaDeus
Apprentice


Joined: 14 Sep 2005
Posts: 121

PostPosted: Thu Oct 13, 2005 8:57 pm   
 
could you please elaborate a little further? and the way i got that list was by taking what it becomes and reversing it, i never paid attention to the fact that the a and the o are both a's any idea how i can get around that?

but what i mean by translating it, without it being retranslated is when i've alreayd had dies translated into light, i don't have light retranslated later on when the single letters come into play.
_________________


Look at me I've got zSKILLS
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Fri Oct 14, 2005 6:44 am   
 
static const struct syl_type syl_table[] =
{
{ " ", " " },
{ "ar", "abra" },
{ "au", "kada" },
{ "bless", "fido" },
{ "blind", "nose" },
{ "bur", "mosa" },
{ "cu", "judi" },
{ "de", "oculo" },
{ "en", "unso" },
{ "light", "dies" },
{ "lo", "hi" },
{ "mor", "zak" },
{ "move", "sido" },
{ "ness", "lacri" },
{ "ning", "illa" },
{ "per", "duda" },
{ "ra", "gru" },
{ "fresh", "ima" },
{ "re", "candus" },
{ "son", "sabru" },
{ "tect", "infra" },
{ "tri", "cula" },
{ "ven", "nofo" },
{ "a", "a" }, { "b", "b" }, { "c", "q" }, { "d", "e" },
{ "e", "z" }, { "f", "y" }, { "g", "o" }, { "h", "p" },
{ "i", "u" }, { "j", "y" }, { "k", "t" }, { "l", "r" },
{ "m", "w" }, { "n", "i" }, { "o", "a" }, { "p", "s" },
{ "q", "d" }, { "r", "f" }, { "s", "g" }, { "t", "h" },
{ "u", "j" }, { "v", "z" }, { "w", "x" }, { "x", "n" },
{ "y", "l" }, { "z", "k" },
{ "", "" }
};

As Viji says you have an issue, the code above provides the final output and of course it has no duplicates going from english to garble. You would however have to decide when going from garble to english what to do with the duplicates, it may well be that it was done on purpose in order to defeat automatic translation back to english or you may find that if you do the words first followed by any remaining letters there may be no issue.
_________________
Taz :)
Reply with quote
OmegaDeus
Apprentice


Joined: 14 Sep 2005
Posts: 121

PostPosted: Fri Oct 14, 2005 6:51 am   
 
But therein lies the issue...how? I've pretty much figured that part out, but I'm trying to go about figuring out how to do so without retranslating the words back into some extra garble. Is there maybe a way to move a word from one variable to another after it's translated?
_________________


Look at me I've got zSKILLS
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Fri Oct 14, 2005 11:46 am   
 
I would translate by taking the string using a character at a time to build up a substring to see if it matches any known syllable when it does this can be knocked off your original string for building the substring and the translated match put in a new variable, carry on. If there are no matches then take the first character and do a character translation put this in a new variable and remove the character from your original string then follow through the whole process again with the remaing string. Eventually you end up with a translated string but nothing was ever worked on more than once. You see the issue of using %replace is that for simplicity you need to nest it relying on the fact this won't do repeated replaces or use a much more extended method of removing the substring that matched the first replace but keep its position in the original string in order that further replaces don't get added to your new string in the wrong place.
_________________
Taz :)
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Fri Oct 14, 2005 11:50 am   
 
Personally I wouldn't bother, you say you've worked out the translation table yourself so in this case you more than likely already know just by looking at the strings what they really mean, won't that suffice it does for most people, do a net search and you'll find most people rely upon learning what they mean over time.
_________________
Taz :)
Reply with quote
Slaem
Apprentice


Joined: 20 Sep 2005
Posts: 135

PostPosted: Fri Oct 14, 2005 6:31 pm   
 
Are there a limited amount of spells? It may end up being easier to just create a class with a group of #SUB triggers that match specific spell phrases and sub in full translations.

#CLASS Spell_Translations
#TR {'judicandus noselacri'} {#CW cyan;#SUB {'judicandus noselacri' (Cure blindness)}}
#CLASS 0
_________________
Show your love.
Support Zugg Software!
Donate to zugg@zuggsoft.com with PayPal Send Money.
Reply with quote
OmegaDeus
Apprentice


Joined: 14 Sep 2005
Posts: 121

PostPosted: Sat Oct 15, 2005 2:03 am   
 
I'm onto something, but I may need some help. I'm thinking using deletes and inserts to remove and re-add the text into a new variable, but one question is this. how do i do this so that when the text is removed and it's position recorded, it won't mess up when inserted since insert follows this:

Syntax: %insert(p,s,i)

return the string s with string p inserted at position i.

if i could get this and a delete in conjunction with each other, i may have solved my problem cuz i've already ported from a datarecord variable into two arrays instead and can loop through the text to replace instances of the value of the first array with the value from the second.

also i bumped into %word, is there anything maybe that can be done with this?
_________________


Look at me I've got zSKILLS
Reply with quote
OmegaDeus
Apprentice


Joined: 14 Sep 2005
Posts: 121

PostPosted: Sun Oct 16, 2005 12:46 am   
 
can anyone give me any good examples of delete, insert, and word?
_________________


Look at me I've got zSKILLS
Reply with quote
OmegaDeus
Apprentice


Joined: 14 Sep 2005
Posts: 121

PostPosted: Sun Oct 16, 2005 1:50 am   
 
Here's the best I can figure is the actual code to make the translation work for zmud, can anyone maybe help me figure out how to make this into zuggsoft script?

Code:
for ( pName = skill_table[sn].name; *pName != '\0'; pName += length )
    {
   for ( iSyl = 0; (length = strlen(syl_table[iSyl].old)) != 0; iSyl++ )
   {
       if ( !str_prefix( syl_table[iSyl].old, pName ) )
       {
      strcat( buf, syl_table[iSyl].new );
      break;
       }
   }


i know that the for in zmud isn't all that intensive, but using the arrays this could probably be done, but i'm still wondering what the str_prefix is and how it's populated, and what it does. I have figured out that the skills are run through here by their skillnum, so I know where i can put the variable in, to get the string, but i need to figure out how to take the code above and turn that into what they're doing.
_________________


Look at me I've got zSKILLS
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sun Oct 16, 2005 12:30 pm   
 
A little bit of untested code off the top of my head.
Code:
#CLASS Translator
#VARIABLE Syllables {abra ar|kada au|fido bless|nose blind|mosa bur|judi cu|oculo de|unso en|dies light|hi lo|zak mor|sido move|lacri ness|illa illa|duda per|gru ra|ima fresh|re candus|sabru son|infra tect|cula tri|nofo ven}
#VARIABLE Letters {a a|b b|q c|e d|z e|y f|o g|p h|u i|y j|t k|r l|w m|i n|a o|s p|d q|f r|g s|h t|j u|z v|x w|n x|l y|k z}
#VARIABLE MatchNumber {0} {0}
#VARIABLE SourceText {} {}
#VARIABLE OutputText {} {}
#ALIAS Translate {
 #WHILE (@SourceText!="") {
  MatchNumber=1
  #WHILE ((@MatchNumber<=%numitems(@Syllables)&(!%begins(%word(%item(@Syllables,@MatchNumber),1),@SourceText))) {
   #ADD MtachNumber 1
  }
  #IF (@MatchNumber>%numitems(@Syllables)) {
   MatchNumber=1
   #WHILE ((@MatchNumber<=%numitems(@Letters)&(!%begins(%word(%item(@Letters,@MatchNumber),1),@SourceText))) {
    #ADD MtachNumber 1
   }
   #IF (@MatchNumber>%numitems(@Letters)) {
    #ECHO Error translating: @SourceText remaining, @OutputText done.
    SourceText=""
   } {
    OutputText=%concat(@OutputText,%word(%item(@Letters,@MatchNumber),2))
    SourceText=%delete(@SourceText,1,1)
   }
  } {
   OutputText=%concat(@OutputText,%word(%item(@Syllables,@MatchNumber),2))
   SourceText=%delete(@SourceText,1,%len(%word(%item(@Syllables,@MatchNumber),1)))
  }
 }
}
#CLASS 0
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
OmegaDeus
Apprentice


Joined: 14 Sep 2005
Posts: 121

PostPosted: Mon Oct 17, 2005 2:54 pm   
 
well this is what i'd come up with at work yesterday, much less intensive than vijilante's and it semi-works. if the spell is one word, it works like a charm. but if it has more than one word it gets all screwy.

Code:
#var spell %2
#show @spell
#if ( %ismember( @spell, @known) ) {#noop} {
  #until (@spell= "") {#loop 0,47 {#if (%pos( %arrget( arcan, %i), @spell) = 1) {
        #var spell %delete( @spell, 1, %len( %arrget( arcan, %i)))
        #var trans %concat( @trans, %arrget( text, %i))
        #show {@spell : @trans}
        } {#noop}}}
  #substitute {%1 utters the words '@trans'}
  #var trans ""
  }


when someone say utters the words yrl or gpuzre i get fly and shield, but when they cast a spell that has two or more words it only ends up showing the first word with as many spaces as the whole spell has ex: judicandus dies comes out cu re. any idea what may be causing this?

[edit] i've got it translating all the words, but for some reason now it turns out as cu re light. bah, something about this still isn't right, refresh ends up coming out rem. I'm getting close, but something still isn't quite right.
_________________


Look at me I've got zSKILLS
Reply with quote
OmegaDeus
Apprentice


Joined: 14 Sep 2005
Posts: 121

PostPosted: Mon Oct 17, 2005 3:35 pm   
 
I know what's causing all my abnormalities, well except for the cu re light thing. Is there some way to break from a loop if you've met your condition? Or is there some way to set up a loop that will only go til %pos( %arrget( arcan, %i) =1) is met, then break from that and go back through until it finishes the until loop?
_________________


Look at me I've got zSKILLS
Reply with quote
OmegaDeus
Apprentice


Joined: 14 Sep 2005
Posts: 121

PostPosted: Tue Oct 18, 2005 5:15 pm   
 
I just tried out vijilante's code too. After much tweaking I finally got it to run, but strangely enough it still doesn't solve the problem. No matter what spell i put through the ringer it errors out.
_________________


Look at me I've got zSKILLS
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Tue Oct 18, 2005 9:14 pm   
 
Oddly, I never put any sort of catch in for spaces in that code. Also as I say it is off the top of my head (hence no testing and likely errors), and as my first post to this topic mentioned there is at least one character that does not reverse properly. The function you are trying to reverse is not 1 to 1 and there will always be errors in translating if you create a general function.

I seriously have no interest in solving this problem, because I know the #SUBSTITUTE's will be a further problem. If you really want to #SUB the text make a series of triggers, if you want a #SHOW to follow with the translation work off what I posted.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
OmegaDeus
Apprentice


Joined: 14 Sep 2005
Posts: 121

PostPosted: Tue Oct 18, 2005 9:38 pm   
 
a substitution won't be any sort of problem, i'm just trying to generally get it working, and with yours even without spaces it doesn't work right, given yrl it should come out with fly but it just errors out :( I may end up having to give up on this one and go back to the dumb spell translator, but at least i can say i've learned quite a bit during this trip. I think with the current abilities of zScript it's not possible, but if zmudxp has some more of the standard loops, or maybe even add to the msscript to allow for c coding it could quite possibly be possible then.
_________________


Look at me I've got zSKILLS
Reply with quote
Slaem
Apprentice


Joined: 20 Sep 2005
Posts: 135

PostPosted: Sun Nov 06, 2005 10:36 am   
 
I'm sure you made your list already, but I found the full ROM spell list at rom.org the other day and figured it would be good for this thread.

http://rrp.rom.org/spells.html

It has an alphabetical listing by spell name and by utterance.
_________________
Show your love.
Support Zugg Software!
Donate to zugg@zuggsoft.com with PayPal Send Money.
Reply with quote
OmegaDeus
Apprentice


Joined: 14 Sep 2005
Posts: 121

PostPosted: Sun Nov 06, 2005 7:25 pm   
 
that's pretty good and all, but most of that i've already commited to memory. that's why i wanted to make a smart spell translation tool, so that if they made a new spell not on anyones list i could already have means of translation for it.
_________________


Look at me I've got zSKILLS
Reply with quote
Slaem
Apprentice


Joined: 20 Sep 2005
Posts: 135

PostPosted: Fri Nov 18, 2005 6:20 am   
 
Did you see this thread in Finished Scripts?
http://forums.zuggsoft.com/phpbb/viewtopic.php?t=12604&highlight=spelltrans
_________________
Show your love.
Support Zugg Software!
Donate to zugg@zuggsoft.com with PayPal Send Money.
Reply with quote
OmegaDeus
Apprentice


Joined: 14 Sep 2005
Posts: 121

PostPosted: Fri Nov 18, 2005 7:32 am   
 
edit: i answered my own question
_________________


Look at me I've got zSKILLS
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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