Amuzet

TTS Card Importer Integration

May 12th, 2021
446
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local lastKnownImporter=nil
  2.  
  3. function findImporter()
  4.   if lastKnownImporter then return lastKnownImporter end
  5.   for _,o in pairs(getAllObjects())do
  6.     if o.getName():find('Card Importer')then
  7.       lastKnownImporter=o return o end end return false end
  8.  
  9. function passToImporter(o,c,a,data)
  10.   local Importer=findImporter()
  11.   local Modes=Importer.getVar('MODES')
  12.   if not Importer then
  13.     Player[c].broadcast('Card Importer not found!')
  14.   elseif not Modes then
  15.     Player[c].broadcast('Card Importer does not support Quick Import!\nUpdate to 1.82 or Later!')
  16.   elseif Importer then
  17.     --You can force values here!
  18.     local t={position=self.getPosition(),
  19.       player=Player[c].steam_id,
  20.       color=Player[c].color,
  21.       full=data,
  22.       mode=data:gsub('(http%S+)',''):match('(%S+)'),
  23.       name=data:gsub('(http%S+)',''):gsub(' ',''),
  24.       url=data:match('(http%S+)')}
  25.     t.position={
  26.       t.position[1]+Offset[POS][1],
  27.       t.position[2]+1,
  28.       t.position[3]+Offset[POS][2]}
  29.     if POS==#Offset then POS=1 else POS=POS+1 end
  30.     --Mode Checker, sees if mode is valid for the Card Importer
  31.     if t.mode then
  32.       local m,n=Modes:lower():find(t.mode:lower())
  33.       if m then
  34.         t.mode=Modes:sub(m,n)
  35.         t.name=t.name:lower():gsub(t.mode:lower(),'',1)
  36.       else t.mode=nil end end
  37.    
  38.     if t.name:len()<1 or not t.name:find('[%w_]')then t.name='island'else t.name=t.name:gsub('%s','')end
  39.     Importer.call('Importer',t)
  40. end end
RAW Paste Data