Easy One-Color Rename Programs

For builders to discuss and ask building questions.
Post Reply
User avatar
Harroghty
Staff
Staff
Posts: 9655
Joined: Tue Jul 27, 2004 5:38 pm

Easy One-Color Rename Programs

Post by Harroghty » Thu Apr 09, 2020 5:17 am

If you have four choices and 15 colors you may find yourself writing out 60 different options in a renaming prog on an NPC. This can be problematic if your prog is so long that it doesn't work (yes, this happens). Instead you can copy this format and change your 60 options in only 19 (15 colors in one prog and four choices in a second prog). Here is an example vendor from Waterdeep:

A prog that details the color options:

Code: Select all

>speech_prog pack packs pouch pouches spellpouch spellpouches~
if questr(8400, 20, 1, $n) == 0
  smote steps back and points to his table.
  sayto $n I sell all manner of pouches and packs.
  pause 1
  sayto $n Two gold coins will buy you one in the color of your choosing.
  smote looks @$N over.
  pause 1
else
  if questr(8400, 20, 1, $n) == 1
    smote nods to @$N.
    sayto $n Which did you say that you wanted?
    pause 1
  endif
endif
mpechoat $n {B0}OOC {F0}To order:
mpechoat $n {F0}1. Pay Koogan two gold.
mpechoat $n {F0}2. Select a type of container: pack, pouch, spellpouch, moneypouch
mpechoat $n {F0}3. Select a color:
mpechoat $n {00}..{10}ochre{00}..{20}green{00}..{30}brown{00}..{40}navy{00}..{50}purple{00}..{60}turquoise{00}..{70}gray{00}..{80}black{00}..{90}red{00}..
mpechoat $n {00}..{A0}lime{00}..{B0}yellow{00}..{C0}ultramarine{00}..{D0}violet{00}..{E0}cyan{00}..{F0}white{00}..
mpechoat $n {00}.
mpechoat $n {00}..{F0}order3 type color
mpechoat $n {00}..{F0}e.g. {90}order3 pouch red{F0} or {20}order3 pack green
~
A prog that translates the order from words to color codes and passes on the other choices as variables:

Code: Select all

>intercept_prog order3~
if questr(8400, 20, 1, $n) == 1
  smote nods to @$N and fetches an item from his table.
  sayto $n Come again if you have a need.
  if string($1) == pouch
  or string($1) == spellpouch
  or string($1) == moneypouch
  or string($1) == pack
    if string($2) == ochre
      mpforce $n convertorder3 $1 {10}
    else
      if string($2) == green
        mpforce $n convertorder3 $1 {20}
      else
        if string($2) == brown
          mpforce $n convertorder3 $1 {30}
        else
          if string($2) == navy
            mpforce $n convertorder3 $1 {40}
          else
            if string($2) == purple
              mpforce $n convertorder3 $1 {50}
            else
              if string($2) == turquoise
                mpforce $n convertorder3 $1 {60}
              else
                if string($2) == gray
                  mpforce $n convertorder3 $1 {70}
                else
                  if string($2) == black
                    mpforce $n convertorder3 $1 {80}
                  else
                    if string($2) == red
                      mpforce $n convertorder3 $1 {90}
                    else
                      if string($2) == lime
                        mpforce $n convertorder3 $1 {A0}
                      else
                        if string($2) == yellow
                          mpforce $n convertorder3 $1 {B0}
                        else
                          if string($2) == ultramarine
                            mpforce $n convertorder3 $1 {C0}
                          else
                            if string($2) == violet
                              mpforce $n convertorder3 $1 {D0}
                            else
                              if string($2) == cyan
                                mpforce $n convertorder3 $1 {E0}
                              else
                                if string($2) == white
                                  mpforce $n convertorder3 $1 {F0}
                                else
                                  mpechoat $n {90}That is not a valid color option.
                                endif
                              endif
                            endif
                          endif
                        endif
                      endif
                    endif
                  endif
                endif
              endif
            endif
          endif
        endif
      endif
    endif
  else
    mpechoat $n {90}That is not a valid choice.
  endif
else
  smote shakes his head from side to side.
  sayto $n You need to pay first.
endif
~
A third prog that receives the corrected codes and variables to execute the rename:

Code: Select all

>intercept_prog convertorder3~
if questr(8400, 20, 1, $n) == 1
  if string($1) == pouch
    mpjunk all.i8414
    mpoload 8414
    mposet i8414 name i8414 leather pouch
    mposet i8414 short $2a leather pouch
    mposet i8414 long $2A leather pouch lies here.
    mpmset $n questr 8400 20 1 0
    mpgive $1 $n
  else
    if string($1) == spellpouch
      mpjunk all.i68
      mpoload 68
      mposet i68 name i68 leather spell pouch spellpouch
      mposet i68 short $2a leather spell pouch
      mposet i68 long $2A leather spell pouch lies here.
      mpmset $n questr 8400 20 1 0
      mpgive $1 $n
    else
      if string($1)== moneypouch
        mpjunk all.i8132
        mpoload 8132
        mposet i8132 name i8132 leather money pouch moneypouch
        mposet i8132 short $2a leather money pouch
        mposet i8132 long $2A leather money pouch lies here.
        mpmset $n questr 8400 20 1 0
        mpgive $1 $n  
      else
        if string($1)== pack
          mpjunk all.i8036
          mpoload 8036
          mposet i8036 name i8036 leather pack
          mposet i8036 short $2a leather pack
          mposet i8036 long $2A leather pack lies here.
          mpmset $n questr 8400 20 1 0
          mpgive $1 $n
        endif
      endif
    endif
  endif
endif
~ 
"A man may die yet still endure if his work enters the greater work, for time is carried upon a current of forgotten deeds, and events of great moment are but the culmination of a single carefully placed thought." - Chime of Eons
Post Reply