Posted 17 February 2015 - 12:29 PM
Hey there.
I currently have 2 little problem within the same script so i think its not necessary to post 2 threads.
If thats not ok, or its better to post 2 threads just say something! :P/>
I'm building a large room to control mobspawner with CC.
My system should check the items inside of my ME system and if mobdrops are missing it should start the mobspawner.
The script in general is working fine except 2 little problems.
I'm using many variables and because of that i decided to throw the variables into a second script.
I'm loading the script with os.loadAPI and sometimes its working, sometimes not.
This is my main script (pastebin):
this is the script that holds all the different variables (pastebin):
When i reboot the computer sometimes its loading just fine and starts the main script.
But sometimes its not loading the "items" and prints errors about missing tables blahblah…
Is there anything i did wrong or why does this happen?
The second problem is the bigger problem.
The script is working realy nice but sometimes it just crashes with
I will have no clue what "Java exception thrown" means.
And i have absolutly no clue why this happens.
There is no way to reproduce this.
Sometimes it happens after a few seconds and sometimes the script runs for hours without problems.
I realy hope someone here knows a solution for my problems.
Sorry for my bad english, i hope its not to hard to understand.
I currently have 2 little problem within the same script so i think its not necessary to post 2 threads.
If thats not ok, or its better to post 2 threads just say something! :P/>
I'm building a large room to control mobspawner with CC.
My system should check the items inside of my ME system and if mobdrops are missing it should start the mobspawner.
The script in general is working fine except 2 little problems.
I'm using many variables and because of that i decided to throw the variables into a second script.
I'm loading the script with os.loadAPI and sometimes its working, sometimes not.
This is my main script (pastebin):
Spoiler
os.loadAPI("items")
local me = peripheral.find("tileinterface")
local m = peripheral.find("monitor")
local sSide = "right"
local function centerText(text, y)
mX = m.getSize()
x = math.floor(mX/2) - math.floor(string.len(text)/2)
m.setCursorPos(x,y)
m.write(text)
end
local function setupMonitor()
m.clear()
m.setTextColor(colors.white)
m.setBackgroundColor(colors.black)
centerText("Global Mob-Spawn System",1)
m.setCursorPos(1,3)
m.write("Mob:")
m.setCursorPos(16,3)
m.write("State:")
m.setCursorPos(34,3)
m.write("Color:")
m.setCursorPos(1,4)
m.write("--------------------------------------------------")
end
local function setOnline()
rs.setBundledOutput(sSide, colors.combine(rs.getBundledOutput(sSide), curcolor))
m.setCursorPos(16,curline)
m.setBackgroundColor(colors.green)
m.write(" ONLINE ")
m.setBackgroundColor(colors.gray)
m.write(" OFFLINE ")
end
local function setOffline()
rs.setBundledOutput(sSide, colors.subtract(rs.getBundledOutput(sSide), curcolor))
m.setCursorPos(16,curline)
m.setBackgroundColor(colors.gray)
m.write(" ONLINE ")
m.setBackgroundColor(colors.red)
m.write(" OFFLINE ")
end
local function updateList()
local list = me.getAvailableItems()
for num, item in pairs(list) do
for n, i in pairs(mobdrops) do
curline = i.line
curcolor = i.color
if i.mob == "Pech" then
if item.fingerprint.nbt_hash == i.nbt then
if item.size < i.qty then
if i.nbt == "ad5cc1bd74d2230c5c483e4c1bbc7948" then ignis = "1"
elseif i.nbt == "bb9211b894dea99a6b674ebe63759333" then terra = "1"
elseif i.nbt == "64630f917da3a7214b1ef2c91a90d090" then aer = "1"
elseif i.nbt == "358c318e194980b0c0835a9f1ce41750" then aqua = "1"
elseif i.nbt == "a77c4b35bbb1a4c84b15122dd52354bf" then ordo = "1"
elseif i.nbt == "18add493aeeb97a3fe71cf8130fe8675" then perditio = "1" end
elseif item.size >= i.qty then
if i.nbt == "ad5cc1bd74d2230c5c483e4c1bbc7948" then ignis = "2"
elseif i.nbt == "bb9211b894dea99a6b674ebe63759333" then terra = "2"
elseif i.nbt == "64630f917da3a7214b1ef2c91a90d090" then aer = "2"
elseif i.nbt == "358c318e194980b0c0835a9f1ce41750" then aqua = "2"
elseif i.nbt == "a77c4b35bbb1a4c84b15122dd52354bf" then ordo = "2"
elseif i.nbt == "18add493aeeb97a3fe71cf8130fe8675" then perditio = "2" end
end
end
if ignis == "2" and terra == "2" and aer == "2" and aqua == "2" and ordo == "2" and perditio == "2" then
setOffline()
else
setOnline()
end
else
if item.fingerprint.id == i.id and item.fingerprint.dmg == i.dmg and item.size < i.qty then
setOnline()
elseif item.fingerprint.id == i.id and item.fingerprint.dmg == i.dmg and item.size >= i.qty then
setOffline()
end
end
m.setBackgroundColor(colors.black)
m.setCursorPos(1,i.line)
m.write(i.mob)
m.setCursorPos(36,i.line)
m.setBackgroundColor(i.color)
m.write(" ")
m.setBackgroundColor(colors.black)
end
end
sleep(1)
end
local function startScan()
rs.setBundledOutput(sSide, 0)
while true do
updateList()
sleep (1)
end
end
setupMonitor()
startScan()
this is the script that holds all the different variables (pastebin):
Spoiler
ignis = "2"
terra = "2"
aer = "2"
aqua = "2"
ordo = "2"
perditio = "2"
mobdrops = {
leather = {
mob = "Horse",
color = colors.red,
id = "minecraft:leather",
nbt = "",
dmg = 0,
qty = 64,
line = 5
},
feather = {
mob = "Chicken",
color = colors.green,
id = "minecraft:feather",
nbt = "",
dmg = 0,
qty = 64,
line = 6
},
blazerod = {
mob = "Blaze",
color = colors.brown,
id = "minecraft:blaze_rod",
nbt = "",
dmg = 0,
qty = 128,
line = 7
},
witherskull = {
mob = "WhiterSkeleton",
color = colors.blue,
id = "minecraft:skull",
nbt = "",
dmg = 1,
qty = 30,
line = 8
},
inksack = {
mob = "Squid",
color = colors.purple,
id = "minecraft:dye",
nbt = "",
dmg = 0,
qty = 128,
line = 9
},
wool = {
mob = "Sheep",
color = colors.cyan,
id = "minecraft:wool",
nbt = "",
dmg = 0,
qty = 128,
line = 10
},
bones = {
mob = "Skeleton",
color = colors.lightGray,
id = "minecraft:bone",
nbt = "",
dmg = 0,
qty = 128,
line = 11
},
gunpowder = {
mob = "Creeper",
color = colors.gray,
id = "minecraft:gunpowder",
nbt = "",
dmg = 0,
qty = 256,
line = 12
},
slimeball = {
mob = "Slime",
color = colors.pink,
id = "minecraft:slime_ball",
nbt = "",
dmg = 0,
qty = 128,
line = 13
},
ghasttear = {
mob = "Ghast",
color = colors.lime,
id = "minecraft:ghast_tear",
nbt = "",
dmg = 0,
qty = 64,
line = 14
},
pinkslimeball = {
mob = "Pink Slime",
color = colors.yellow,
id = "MineFactoryReloaded:pinkslime",
nbt = "",
dmg = 0,
qty = 72,
line = 15
},
mana_ignis = {
name = ignis,
mob = "Pech",
color = colors.lightBlue,
id = "Thaumcraft:ItemManaBean",
nbt = "ad5cc1bd74d2230c5c483e4c1bbc7948",
dmg = 0,
qty = 256,
line = 16
},
mana_terra = {
name = terra,
mob = "Pech",
color = colors.lightBlue,
id = "Thaumcraft:ItemManaBean",
nbt = "bb9211b894dea99a6b674ebe63759333",
dmg = 0,
qty = 256,
line = 16
},
mana_aer = {
name = aer,
mob = "Pech",
color = colors.lightBlue,
id = "Thaumcraft:ItemManaBean",
nbt = "64630f917da3a7214b1ef2c91a90d090",
dmg = 0,
qty = 256,
line = 16
},
mana_aqua = {
name = aqua,
mob = "Pech",
color = colors.lightBlue,
id = "Thaumcraft:ItemManaBean",
nbt = "358c318e194980b0c0835a9f1ce41750",
dmg = 0,
qty = 256,
line = 16
},
mana_ordo = {
name = ordo,
mob = "Pech",
color = colors.lightBlue,
id = "Thaumcraft:ItemManaBean",
nbt = "a77c4b35bbb1a4c84b15122dd52354bf",
dmg = 0,
qty = 256,
line = 16
},
mana_perditio = {
name = perditio,
mob = "Pech",
color = colors.lightBlue,
id = "Thaumcraft:ItemManaBean",
nbt = "18add493aeeb97a3fe71cf8130fe8675",
dmg = 0,
qty = 256,
line = 16
}
}
When i reboot the computer sometimes its loading just fine and starts the main script.
But sometimes its not loading the "items" and prints errors about missing tables blahblah…
Is there anything i did wrong or why does this happen?
The second problem is the bigger problem.
The script is working realy nice but sometimes it just crashes with
Java exception thrown
I will have no clue what "Java exception thrown" means.
And i have absolutly no clue why this happens.
There is no way to reproduce this.
Sometimes it happens after a few seconds and sometimes the script runs for hours without problems.
I realy hope someone here knows a solution for my problems.
Sorry for my bad english, i hope its not to hard to understand.