Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.96 KB | None | 0 0
  1. Alright guys I will show you the scripts, aliases and triggers I have for a research function. Basically in our mud every skill has a percentage that they can be researched up to. Right now my code helps me capture all the skills on research and their percentage values, then start researching them.
  2.  
  3. Scripts:
  4. function removefromlist()
  5. table.remove(researchthese, 1)
  6. research.skill = researchthese[1]
  7. cecho("\n<yellow>Skill changed to: "..research.skill)
  8. send("research "..research.skill)
  9. end
  10.  
  11. -------
  12. function moveskills()
  13. researchthese = {}
  14. for i,v in pairs(mySkills) do
  15. if (v<80) then
  16. table.insert(researchthese,i)
  17. end
  18. end
  19. end
  20.  
  21. -------------------------------------------------------------
  22. Triggers:
  23.  
  24. You study for hours on end, but fail to gather any knowledge. | Exact match
  25. if researching then
  26. cecho("\n<yellow>Study harder, bitch!")
  27. send("research "..research.skill)
  28. end
  29.  
  30. -------
  31. You finish your studies and feel much more skilled. | Exact match
  32. research.percent = research.percent + 15
  33. if researching then
  34. if research.percent < 81 then
  35. send("research "..research.skill)
  36. cecho("\n<yellow>Current percentage: "..research.percent.."%")
  37. else
  38. table.remove(researchthese, 1)
  39. research.skill = researchthese[1]
  40. research.percent = research.percent
  41. cecho("\n<yellow>Skill changed to: "..research.skill)
  42. send("research "..research.skill)
  43. end
  44. end
  45. --------
  46. You can't learn any more about that from books! | Exact match
  47. if researching then
  48. if research.percent >= 80 then
  49. cecho("\n<yellow>Percent is higher than 80.")
  50. table.remove(researchthese, 1)
  51. research.skill = researchthese[1]
  52. cecho("\n<yellow>Skill changed to: "..research.skill)
  53. send("research "..research.skill)
  54. else
  55. cecho("\n<red>Something is wrong here.. You are below 80 percent?")
  56. end
  57. end
  58. --------
  59. I got various syntaxes refusing to research skills saying they cannot be researched. Or that I am done researching them so what it does is;
  60.  
  61. tempTimer( 2, [[removefromlist()]] )
  62. --------
  63. The Skills capture parser:
  64. ---------------------------------Skills----------------------------------- | exact match
  65. mySkills = {}
  66. --------
  67. ^\{Tone:
  68. ^\[HP: | Both perl regex (To end the capture I think)
  69. setTriggerStayOpen("skills", 0)
  70. display(mySkills)
  71. --------
  72. \s*([a-zA-z\- ]+\d+)% | Perl regex (No output just the folder name and this trigger)
  73. --------
  74. ([a-zA-z \-]+)(\d+) | Perl regex
  75.  
  76. if string.trim(matches[2]) ~= "" then
  77. mySkills[string.trim(matches[2])] = tonumber(matches[3])
  78. end
  79. --------
  80. Aliases:
  81.  
  82. I have two aliases, one is called msnow.
  83. Output: moveskills()
  84.  
  85. -----
  86.  
  87. The second alias is ^tr (\w+)$
  88. if matches[2] == "on" then
  89. research = {}
  90. research.skill = researchthese[1]
  91. research.percent = tonumber(mySkills[researchthese[1]])
  92. researching = true
  93. send("research "..research.skill)
  94. cecho("\n<green>Research Mode - Enabled")
  95. elseif matches[2] == "off" then
  96. researching = false
  97. cecho("\n<red>Research Mode - Disabled")
  98. end
  99.  
  100. ------------------------------------------------------------------------------------------------
  101.  
  102. I will paste you an example of practice window's output from mud and my prompt to help you understand. (Also the research capture displaying the table)
  103.  
  104. ------------------------------------Skills ------------------------------------
  105. dock 0% fly 0% navigation 100%
  106. ship systems 100% small spacecraft 100% space combat 1 0%
  107. tractor beams 0% weapon systems 20%
  108. ------------------------------------ Feats ------------------------------------
  109. To see a shorter practice list, type PRACTICE <class name>.
  110.  
  111. [HP: 3273/3273] [OOC: 6] Time: [ day] Tone: [none] [Movement: 2770/2770] [Near: ] [Mana: 0/0]
  112. [Ambience: average]{
  113. ["weapon systems"] = 20,
  114. ["tractor beams"] = 0,
  115. dock = 0,
  116. fly = 0,
  117. ["ship systems"] = 100,
  118. ["small spacecraft"] = 100,
  119. navigation = 100
  120. }
  121.  
  122. You finish your studies and feel much more skilled.
  123.  
  124. ----------------------------------------------------------------------------------------
  125.  
  126. I have 3 problems as it stands:
  127. 1- When I trigger my research code via;
  128. - practice
  129. - msnow
  130. - tr on
  131. The script will capture the numbers and then take the first item on the list and then research it all the way above 80 percentage value. Once that one is above 80, it will move to the next skill, ---it will research it only once---. Once the final skill is researched it will stop the code.
  132.  
  133. I would like it so that I am able to research every skill to its potential. Not the first to its potential and then rest only once.
  134.  
  135. 2- My capture does not capture skills named "space combat 1" "space combat 2" etc. It's not a huge problem, I simply was wondering if it can easily be fixed, if not no huge deal.
  136.  
  137. 3- This is within number 1 too. As it stands the code will move to the next skill, but refuse to take its research value. Is there a way to force the code to go back to the table and capture whatever number its value is?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement