Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Manual = false -- True if you will config the file manually;
- local Mode = "vertical" -- 'horizontal' will output plain function, 'vertical' will make a new line for each item and add a comment with the item name
- local fileName = "fileName.xbst" -- Name of file to gather loot list from;
- local itemsToIgnore = {} -- Put here the id of the items to ignore separated by;
- local stackableIndex = 0 -- Index of deposit bp to put stackables;
- local nonStackableIndex = 1 -- Same but for non stackables.
- local outputName = "fileName.lua"
- local talkstate = "fileName"
- function Receive(log, msg)
- log:SendYellowMessage(Self.Name().." ["..Self.Level().."] ", msg)
- if talkstate == "fileName" then
- if msg:find(".xbst") then
- fileName = msg
- talkstate = "lua"
- log:SendOrangeMessage("Xenobot ", "Type the name you want for the lua file")
- else
- log:SendOrangeMessage('Xenobot ', "That's not a valid file format, example : FileName.xbst")
- end
- elseif talkstate == 'lua' then
- if msg:find('.lua') then
- outputName = msg
- talkstate = 'stackable'
- log:SendOrangeMessage("Xenobot ", "Type the Depot BP Index number for stackable items")
- else
- log:SendOrangeMessage('Xenobot ', "That's not a valid file format, example : FileName.lua")
- end
- elseif talkstate == 'stackable' then
- if tonumber(msg) then
- stackableIndex = msg
- talkstate = 'non'
- log:SendOrangeMessage("Xenobot ", "Type the Depot BP Index number for non-stackable items")
- else
- log:SendOrangeMessage("Xenobot ", "That's not a number, try again")
- end
- elseif talkstate == 'non' then
- if tonumber(msg) then
- nonStackableIndex = msg
- talkstate = 'final'
- log:SendOrangeMessage("Xenobot ", "List created, copy from below or in '"..outputName.."' on 'Scripts' folder")
- OutPut()
- else
- log:SendOrangeMessage("Xenobot ", "That's not a number, try again")
- end
- end
- end
- function Close()
- end
- Scripter = Channel.New("Setup", Receive, Close)
- Scripter:SendOrangeMessage("Xenobot ", "Type the name of the file with .xbst in the end where the Loot list is")
- function OutPut()
- local GatherIDS
- local GatherLabels
- local foundIDS = {}
- local foundLabels = {}
- for lines in io.lines("..//Settings//"..fileName) do
- if lines:find('<control name="LootList"') then
- GatherIDS = true
- elseif lines:find('<control name="WaypointList">') then
- GatherLabels = true
- end
- if GatherIDS then
- if lines:find('</control>') then
- GatherIDS = false
- else
- ID = lines:match('<item ID="(%d+)"')
- if ID then
- table.insert(foundIDS, ID)
- end
- end
- elseif GatherLabels then
- if lines:find('</control>') then
- GatherLabels = false
- else
- Label = lines:match('<item text="(.+):" tag="255"/>')
- if Label then
- table.insert(foundLabels, Label)
- end
- end
- end
- end
- if itemsToIgnore then
- for i = 1, #foundIDS do
- local er = table.fastfind(foundIDS[i], itemsToIgnore)
- if er then
- table.remove(i, foundIDS)
- end
- end
- end
- str = "Self.DepositItems("
- local ind
- if foundIDS then
- local len = #foundIDS
- for i = 1, len do
- local item = foundIDS[i]
- if Mode == "vertical" then
- nl = '\n'
- comment = ' -- '..Item.GetName(item):titlecase()
- else
- nl = ""
- comment = ""
- end
- if Item.isStackable(item) then
- ind = stackableIndex
- else
- ind = nonStackableIndex
- end
- if i == len then
- str = str..nl..'{'..item..','..ind..'})'..comment
- else
- str = str..nl..'{'..item..','..ind..'},'..comment
- end
- end
- end
- if foundLabels then
- lstr = '\nfunction onWalkerSelectLabel(label)'
- local len = #foundLabels
- for i = 1, len do
- if i == 1 then
- lstr = lstr..'\n if label = "'..foundLabels[i]..'" then \n --code'
- else
- lstr = lstr..'\n elseif label = "'..foundLabels[i]..'" then \n --code'
- end
- end
- lstr = lstr..'\nend\nregisterEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")'
- end
- fstr = '--[[\n'..str..'\n]]\n\n'..lstr
- Scripter:SendOrangeMessage("Copy", str)
- file = io.open("..//Scripts//"..outputName,"w+")
- file:write(fstr)
- file:flush()
- file:close()
- wait(1000)
- os.execute('start C:'..os.getenv('HOMEPATH')..'\\Documents\\XenoBot\\Scripts\\'..outputName)
- end
- function table.fastfind(value, table)
- local data = table
- for i = 1, #data do
- if value == data[i] then
- return value
- end
- end
- return false
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement