Advertisement
guitarplayer616

Oblivion Perfect Persuasion Tool v1.2

Jul 8th, 2017
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.90 KB | None | 0 0
  1. shell.run("clear")
  2. print("from the top of the circle going clockwise put the 4 numbers from 1-4 representing the mood of the npc")
  3. print("ie top:4(happiest) right:1(angriest) etc")
  4. print(nil)
  5. print("next 4 numbers represent the size of the filled in circle from top going clockwise")
  6. print("ie top:1(smallest effect) bottom:4(largest effect) etc")
  7. print(nil)
  8. print("example: 2143 4132")
  9. print(nil)
  10.  
  11. function options(grid)
  12.     highest = 0
  13.     winner = ""
  14.     for i=1,5 do
  15.         for v = 1,5 do
  16.             if v~=i then
  17.                 for e = 1,5 do
  18.                     if (e~=v) and (e~=i) then
  19.                         for r = 1,5 do
  20.                             if (r~=e) and (r~=i) and (r~=v) then
  21.                                 for t = 1,5 do
  22.                                     if (t~=r) and (t~=e) and (t~=i) and (t~=v) then
  23.                                         local newValue = returnValue(""..i..v..e..r..t,grid)
  24.                                         if newValue > highest then
  25.                                             highest = newValue
  26.                                             winner = ""..i..v..e..r..t
  27.                                         end
  28.                                     end
  29.                                 end
  30.                             end
  31.                         end
  32.                     end
  33.                 end
  34.             end
  35.         end
  36.     end
  37. end
  38.  
  39. function shift(pos,times)
  40.     local result = (pos-(times-1))%4
  41.     if result == 0 then
  42.         result = 4
  43.     end
  44.     return result
  45. end
  46.  
  47. function createGrid()
  48.     local grid = {}
  49.     for i=1,5 do
  50.         grid[i] = {}
  51.         for v = 1,4 do
  52.             grid[i][v] = evaluateScore( tonumber( sInput:sub(v,v) ), tonumber( sInput:sub(shift(v,i)+4,shift(v,i)+4)) )
  53.         end
  54.     end
  55.     return grid
  56. end
  57.  
  58. function evaluateScore(attitude,potency)
  59.     local value = 0
  60.     if attitude == 4 then
  61.         value = 2
  62.     elseif attitude == 3 then
  63.         value = 1
  64.     elseif attitude == 2 then
  65.         value = -1
  66.     elseif attitude == 1 then
  67.         value = -2
  68.     end
  69.     return value * potency
  70. end
  71.  
  72. function returnValue(strnum,grid)
  73.     local result = 0
  74.     for i=1,5 do
  75.         local sel = tonumber(strnum:sub(i,i))
  76.         if sel == 5 then
  77.             result = result + 0
  78.         else
  79.             result = result + grid[i][sel]
  80.         end
  81.     end
  82.     return result
  83. end
  84.  
  85. local function translate(sNum)
  86.     local num = tonumber(sNum)
  87.     if num == 1 then
  88.         return "Top"
  89.     elseif num == 2 then
  90.         return "Right"
  91.     elseif num == 3 then
  92.         return "Bottom"
  93.     elseif num == 4 then
  94.         return "Left"
  95.     elseif num == 5 then
  96.         return "Rotate"
  97.     end
  98. end
  99.  
  100. function split(num)
  101.     sNum = tostring(num)
  102.     local result = ""
  103.     for i = 1,5 do
  104.         if i==5 and translate(sNum:sub(i,i))=="Rotate" then
  105.             result = result
  106.         else
  107.             result = result..translate(sNum:sub(i,i))
  108.         end
  109.         if i~=5 then
  110.             result = result.." "
  111.         end
  112.     end
  113.     return result
  114. end
  115.  
  116.  
  117. --options()
  118. --textutils.slowPrint(string3)
  119. --print(evaluateScore(3,2))
  120. --print(tonumber(sInput:sub(1,1)))
  121. while true do
  122.     term.setTextColor(colors.yellow)
  123.     sInput = read()
  124.     sInput = sInput:gsub("%s","")
  125.     term.setTextColor(colors.white)
  126.     newGrid = createGrid()
  127.     options(newGrid)
  128.     if tostring(highest):sub(1,1) == "-" then
  129.         print("Score: "..tostring(highest))
  130.     else
  131.         print("Score: +"..tostring(highest))
  132.     end
  133.     print(split(winner))
  134. end
  135. --print(returnValue(winner,newGrid))
  136. --textutils.pagedPrint(textutils.serialize(newGrid))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement