spellBook.qsrc 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #spellBook
  2. ! Make a table of Spells to Cast from a given list. the list is in the form of the lists as done in thespellList file.
  3. !
  4. ! $ARGS[0] = the name of the array to use for the spell list.
  5. ! $ARGS[1] = (optional) return Action Code - a dynamic piece of code to run instead of generic return.
  6. ! $ARGS[2] = (optional) Additional code to put in spell link (all spells)
  7. !
  8. $spellBookVar['Array'] = $ARGS[0]
  9. $spellBookVar['ActionCode'] = $ARGS[1]
  10. $spellBookVar['CodeAfterSpell'] = $ARGS[2]
  11. ! Make sure opptional variables have defaults
  12. if $spellBookVar['ActionCode'] = '':
  13. $spellBookVar['ActionCode'] = "gt '<<$loc>>', '<<$metka>>'"
  14. end
  15. if $spellBookVar['CodeAfterSpell'] = '':
  16. $spellBookVar['CodeAfterSpell'] = "gt '<<$loc>>', '<<$metka>>'"
  17. end
  18. ! lets the user back out if they don''t want ot cast.
  19. act 'Never mind':dynamic spellBookVar['ActionCode']
  20. ! This just makes sure the current spellLists are loaded
  21. if spellMana['fog'] = 0:
  22. gs 'spellList'
  23. end
  24. ! Build the table
  25. $SpellListStr = "
  26. <center>
  27. <h1>Choose a Spell to cast.</h1>
  28. <br>
  29. <table CELLPADDING = '5'>
  30. <tr>
  31. <th align='left'>Spell</th>
  32. <th align='left'>Mana</th>
  33. <th align='left'>Description</th>
  34. </tr>"
  35. i = 0
  36. spellBookVar['ArraySize'] = dyneval("result = arrsize('<<$spellBookVar['Array']>>')")
  37. numSpellsKnown = 0
  38. :SpellListLoop
  39. $ThisSpellName = dyneval("$result = <<$spellBookVar['Array']>>[<<i>>]")
  40. if i < spellBookVar['ArraySize']:
  41. if spellKnown[$ThisSpellName] = 1:
  42. $SpellListStr = $SpellListStr + "
  43. <tr>
  44. <td align='left'><a href=""EXEC: gs 'castSpell', '<<$ThisSpellName>>'& <<$spellBookVar['CodeAfterSpell']>>""><<$spellName[$ThisSpellName]>></a></td>
  45. <td align='right'><<spellMana[$ThisSpellName]>></td>
  46. <td align='left'><<$spellDesc[$ThisSpellName]>></td>
  47. </tr>"
  48. numSpellsKnown += 1
  49. end
  50. i += 1
  51. jump 'SpellListLoop'
  52. end
  53. $SpellListStr = $SpellListStr + "
  54. </table>
  55. </center>"
  56. if numSpellsKnown = 0:
  57. "You don't know any spells of this type."
  58. else
  59. *pl func('cleanHTML',$SpellListStr)
  60. end
  61. killvar 'i'
  62. killvar 'numSpellsKnown'
  63. killvar '$ThisSpellName'
  64. killvar '$SpellListStr'
  65. killvar '$spellBookVar'
  66. killvar 'spellBookVar'
  67. --- spellBook ---------------------------------