Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function wrapP(peripheralName)
- if peripheralName==nil then
- print("Fehler")
- end
- local peripherals = peripheral.getNames()
- local i = 1
- while i < #peripherals and peripheral.getType(peripherals[i])~=peripheralName do
- i=i+1
- end
- if peripheral.getType(peripherals[i])==peripheralName then
- return peripheral.wrap(peripherals[i])
- else
- return nil
- end
- end
- function listItems(me)
- itemsTab=me.listItems()
- itemsRaw=textutils.serialize(itemsTab)
- i=1
- items={}
- itemName={}
- while string.find(itemsRaw,",") do
- items[i]=tonumber(string.sub(itemsRaw,string.find(itemsRaw,"{")+2,string.find(itemsRaw,"]")-1))
- itemsRaw="{"..string.sub(itemsRaw,string.find(itemsRaw,",")+1)
- i=i+1
- end
- end
- function say(message)
- print(message)
- if c~=nil then
- c.say(message)
- end
- end
- me=wrapP("meBridge")
- c=wrapP("chat")
- function main()
- listItems(me)
- list2=itemsTab
- list2Sort=items
- while true do
- list1=list2
- list1Sort=list2Sort
- sleep(1) say("debug")
- listItems(me)
- list2=itemsTab
- list2Sort=items
- if textutils.serialize(list1)~=textutils.serialize(list2) then
- for i=1,#list1Sort do
- if list2[list1Sort[i]]==nil then
- id=math.fmod(list1Sort[i],32768)
- dmg=math.floor(list1Sort[i]/32768)
- say(tostring(id)..":"..tostring(dmg).." wurde dem System entnommen")
- end
- end
- for i=1,#list2Sort do
- if list1[list2Sort[i]]==nil then
- id=math.fmod(list2Sort[i],32768)
- dmg=math.floor(list2Sort[i]/32768)
- say(tostring(id)..":"..tostring(dmg).." wurde dem System hinzugefügt")
- end
- end
- end
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement