2DWorlds Forums
I got an error when a script cloned a model from Storage - Printable Version

+- 2DWorlds Forums (http://2dworlds.buildism.net/forum)
+-- Forum: 2DWorlds (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=4)
+--- Forum: Bug Reports (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=23)
+--- Thread: I got an error when a script cloned a model from Storage (/showthread.php?tid=7108)



I got an error when a script cloned a model from Storage - Qwertygiy - 07-22-2011

[Image: 34fjxy1.png]



RE: I got an error when a script cloned a model from Storage - Jacob__mybb_import1 - 07-22-2011

Can you post your code?


RE: I got an error when a script cloned a model from Storage - Qwertygiy - 07-22-2011

Unfortunately not -- it was a fatal error and wiped out my script.

It was something along the lines of

[lua]
table1 = {}
stuff = game.Storage:getChildren()
for q = 1, #stuff do
if stuff[q]:isA("Model") then
table.insert(table1, stuff[q])
end end

function PickItem()
local item = table1[math.random(1, #table1)]
return item
end

while true do
sleep(10)
local players = game.Players:getChildren()
if #players > 0 then
local item = PickItem():clone()
item.Parent = game.World
sleep(100)
item:remove()
end end
[/lua]

There were a few other little bits -- messages and a sort of clock -- but I think that's the skeleton of the script.


RE: I got an error when a script cloned a model from Storage - Jacob__mybb_import1 - 07-22-2011

Remember to always use gameConfusedcheduleTask(). That could be causing your problem.


RE: I got an error when a script cloned a model from Storage - Qwertygiy - 07-23-2011

I'll try and see if that works.
Sad I didn't even run the script and this happened.

error Wrote:java.lang.NegativeArraySizeException
org.jbox2d.dynamics.Island.a(Island.java:118)
org.jbox2d.dynamics.PhysicsWorld.a(PhysicsWorld.java:573)
net.buildism.t.r(World.java:723)
net.buildism.af.h(Game.java:217)
net.buildism.f.p(Main.java:685)
net.buildism.MainApplet.run(MainApplet.java:209)
java.lang.Thread.run(Unknown Source)



RE: I got an error when a script cloned a model from Storage - Jacob__mybb_import1 - 07-23-2011

(07-23-2011, 12:53 PM)Qwertygiy Wrote: I'll try and see if that works.
Sad I didn't even run the script and this happened.

error Wrote:java.lang.NegativeArraySizeException
org.jbox2d.dynamics.Island.a(Island.java:118)
org.jbox2d.dynamics.PhysicsWorld.a(PhysicsWorld.java:573)
net.buildism.t.r(World.java:723)
net.buildism.af.h(Game.java:217)
net.buildism.f.p(Main.java:685)
net.buildism.MainApplet.run(MainApplet.java:209)
java.lang.Thread.run(Unknown Source)

Can you send me the game file? Never seen that one before...



RE: I got an error when a script cloned a model from Storage - Qwertygiy - 07-23-2011

Alright, I'll go back into Build and rebuild the script and then save it.


RE: I got an error when a script cloned a model from Storage - Jacob__mybb_import1 - 07-23-2011

(07-23-2011, 01:48 PM)Qwertygiy Wrote: Alright, I'll go back into Build and rebuild the script and then save it.

Did the save button in the new error message work?


RE: I got an error when a script cloned a model from Storage - Qwertygiy - 07-23-2011

I didn't bother clicking it; it crashed before the script could run so I figured it wouldn't be worth it when I have the script pretty much written down here and the main World saved online.
Here's the game, with the script written the way it was when that last error happened.