Advertisement
Guest User

Problematic message code

a guest
Feb 13th, 2013
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.70 KB | None | 0 0
  1. function runonce()
  2.     entitybindkey(this, "sumbitsay", 13, 0, -1)
  3.     entitybindkey(this, "deletechar", 8, 0, -1)
  4. end
  5.  
  6. function initialized()
  7.     saystr = ""
  8.     cc = 0
  9.     timer = 10
  10. end
  11.  
  12. function main()
  13.     textupdate()
  14.     char()
  15.     pos()
  16.     drawsay()
  17.     drawlog()
  18. end
  19.  
  20. function always()
  21.  
  22. end
  23.  
  24. function submitsay()
  25.     --if string.len(saystr) > 0 then
  26.         gamedatasave(tostring(cc), "Me: " .. tostring(saystr))
  27.         print(gamedataread(cc))
  28.         saystr = ""
  29.         print(saystr)
  30.         cc = cc + 1
  31.     --end
  32. end
  33.  
  34. function char()
  35.     if timer <= 0 then
  36.         if getentitytilechar(this) == 0 then
  37.             setentitytilechar(this, 219)
  38.             timer = 10
  39.         elseif getentitytilechar(this) == 219 then
  40.             setentitytilechar(this, 0)
  41.             timer = 10
  42.         end
  43.     else
  44.         timer = timer - 1
  45.     end
  46. end
  47.  
  48. function deletechar()
  49.     if string.len(saystr) > 0 then
  50.         saystr = string.sub(saystr, 1, -2)
  51.     else
  52.         saystr = ""
  53.     end
  54. end
  55.  
  56. function pos()
  57.     entityposition(this, 6 + string.len(saystr), 38)
  58. end
  59.  
  60. function drawsay()
  61.     if string.len(saystr) > 31 then
  62.         saystr = string.sub(saystr, 1, -2)
  63.     end
  64.    
  65.     drawset(0, 27, 48)
  66.     drawtext(6, 38, tostring(saystr))
  67. end
  68.  
  69. function drawlog()
  70.     for i=1, 35, 1 do
  71.         if gamedataexists(tostring(cc - i)) then
  72.             drawtext(1, 36 - i, gamedataread(tostring(cc - i)))
  73.         end
  74.     end
  75. end
  76.  
  77. function textupdate()
  78.     for i=48, 57, 1 do
  79.         if keyhit(i) then
  80.             local char = getchar()
  81.             saystr = tostring(saystr .. string.char(char))
  82.             flushkeys()
  83.         end
  84.     end
  85.    
  86.     for i=65, 90, 1 do
  87.         if keyhit(i) then
  88.             local char = getchar()
  89.             if keyhit(160) then
  90.                 saystr = tostring(saystr .. string.upper(string.char(char)))
  91.                 flushkeys()
  92.             else
  93.                 saystr = tostring(saystr .. string.char(char))
  94.                 flushkeys()
  95.             end
  96.         end
  97.     end
  98. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement