object creation

Typically: "How do I... ", "How can I... " questions
Post Reply
sampits
Posts: 20
Joined: 11 Feb 2020, 11:15

object creation

Post 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 ?

fferri
Posts: 1230
Joined: 09 Sep 2013, 19:28

Re: object creation

Post 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

sampits
Posts: 20
Joined: 11 Feb 2020, 11:15

Re: object creation

Post 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

fferri
Posts: 1230
Joined: 09 Sep 2013, 19:28

Re: object creation

Post by fferri »

Replace while true with while sim.getSimulationState()~=sim.simulation_advancing_abouttostop

sampits
Posts: 20
Joined: 11 Feb 2020, 11:15

Re: object creation

Post by sampits »

It worked thanks!!

Post Reply