Page 1 of 1

object creation

Posted: 27 Feb 2020, 12:19
by sampits
Hi im using this code to create objects infinitely once in a while

Code: Select all

local CULLED_BACKFACES=1
	local VISIBLE_EDGES=2
	local APPEAR_SMOOTH=4
	local RESPONDABLE_SHAPE=8
	local STATIC_SHAPE=16
	local CYL_OPEN_ENDS=32
    local tblSize={0.06,0.06,0.06}--cube size

while true do 

    local hndShape=sim.createPureShape(0,RESPONDABLE_SHAPE+VISIBLE_EDGES,tblSize,0.1,NULL)
        sim.setObjectPosition(hndShape,-1,{-0.3750,-0.2000,0.0500})
--maje cube detectable
        sim.setObjectSpecialProperty(hndShape,sim.objectspecialproperty_detectable_all)

    sim.wait(15)
    end
The problem is that when i press to finish simulating it creates like 200 objects in an instant and it always crashes my computer but i cant find a reason why can anyone help ?

Re: object creation

Posted: 27 Feb 2020, 14:53
by fferri
Is that a non-threaded child script?

Maybe use a threaded script if you need to use sim.wait and continue the simulation meanwhile.

Recommended reading: Child scripts

Re: object creation

Posted: 27 Feb 2020, 15:47
by sampits
I was indeed using a non-threaded child script but now i have changed to a threaded child script and the problem still happens

Re: object creation

Posted: 27 Feb 2020, 16:27
by fferri
Replace while true with while sim.getSimulationState()~=sim.simulation_advancing_abouttostop

Re: object creation

Posted: 27 Feb 2020, 16:32
by sampits
It worked thanks!!