daily pastebin goal
68%
SHARE
TWEET

Persistent console storage

a guest Oct 19th, 2014 412 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Backing up and later retrieving the storage.* table of a console script.
  2.  
  3. -- In the console script:
  4. function init()
  5.   storage = console.configParameter("scriptStorage")
  6. end
  7.  
  8. function syncStorage()
  9.   world.callScriptedEntity(console.sourceEntity(), "onConsoleStorageRecieve", storage)
  10. end
  11.  
  12. -----------------------------------------------------------------------------------
  13.  
  14. -- In the object script:
  15. function onConsoleStorageRecieve(consoleStorage)
  16.   storage.consoleStorage = consoleStorage
  17. end
  18.  
  19. function onInteraction(args)
  20.   local interactionConfig = {
  21.     gui = {
  22.       background = {
  23.         zlevel = 0,
  24.         type = "background",
  25.         fileHeader = "/testconsole/consoleheader.png",
  26.         fileBody = "/testconsole/consolebody.png"
  27.       },
  28.       scriptCanvas = {
  29.         zlevel = 1,
  30.         type = "canvas",
  31.         rect = {40, 45, 434, 254},
  32.         captureMouseEvents = true,
  33.         captureKeyboardEvents = true
  34.       },
  35.       close = {
  36.         zlevel = 2,
  37.         type = "button",
  38.         base = "/interface/cockpit/xup.png",
  39.         hover = "/interface/cockpit/xdown.png",
  40.         pressed = "/interface/cockpit/xdown.png",
  41.         callback = "close",
  42.         position = {419, 263},
  43.         pressedOffset = {0, -1}
  44.       }
  45.     },
  46.  
  47.     scripts = {"/testconsole/testconsolegui.lua"},
  48.     scriptDelta = 5,
  49.     scriptCanvas = "scriptCanvas"
  50.   }
  51.  
  52.   interactionConfig.scriptStorage = storage.consoleStorage
  53.  
  54.   return {"ScriptConsole", interactionConfig}
  55. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top