Advertisement
Encreedem

AddOn Example

Jul 17th, 2013
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.17 KB | None | 0 0
  1. objects = [[
  2. <objects>
  3.   <object>
  4.     objectID=idInput
  5.     objectType=Input
  6.   </object>
  7.   <object>
  8.     objectID=messageInput
  9.     objectType=Input
  10.   </object>
  11.   <object>
  12.     objectID=messageSender
  13.     objectType=Button
  14.     defaultWidth=14
  15.     defaultHeight=3
  16.     text=Send!
  17.   </object>
  18. </objects>
  19. ]]
  20.  
  21. local args = { ... }
  22. local callType
  23. local objectID
  24. local systemInfo
  25.  
  26. -- Gets called when an object with type "Custom"
  27. -- needs to be displayed.
  28. function showObject()
  29.  
  30. end
  31.  
  32. -- Gets called when a button or a custom object
  33. -- with canClick attribute gets clicked.
  34. function callFunction()
  35.   if (objectID == "messageSender") then
  36.     id = tonumber(systemInfo["userInputs"]["idInput"])
  37.     message = systemInfo["userInputs"]["messageInput"]
  38.     if (id == nil or message == nil) then
  39.       return
  40.     end
  41.    
  42.     rednet.open("left")
  43.     rednet.send(id, message)
  44.   end
  45. end
  46.  
  47. function main()
  48.   if (#args == 3) then
  49.     callType = args[1]
  50.     objectID = args[2]
  51.     systemInfo = textutils.unserialize(args[3])
  52.    
  53.     if (callType == "Show") then
  54.       showObject()
  55.     elseif (callType == "Click") then
  56.       callFunction()
  57.     end
  58.   end
  59. end
  60.  
  61. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement