Page 1 of 1

check the dialog diaplay

Posted: 27 Jul 2021, 13:43
by lwang87
Hello,
I want to check the dialog display. I've thought about a code like: "

Code: Select all

if dialog_A is displaying then sim.endDialog(dialog_A)  end
.” But I don't know how to achieve this. Please tell me, thanks for your reply!

Re: check the dialog diaplay

Posted: 27 Jul 2021, 19:49
by coppelia
Hello,

please use custom user interfaces: they are extremely powerful and flexible to use, and they are used for almost all custom UI across all demo scenes and models, and most add-ons also use them. Then, inspect the code of those models, scenes and add-ons to get an idea how to achieve wht you need.

Cheers

Re: check the dialog diaplay

Posted: 28 Jul 2021, 16:46
by lwang87
Thanks for your reply. And, the problem I have is: I've used the following code to check for collisions and give a hint:


Code: Select all

local current_state=sim.checkCollision(car_body,wall_1)
            if(current_state==1 and last_collision_state==0 and collide_start_T==0)then ---record state collisiont time
                collide_start_T=simulationtime
                dialog_H=sim.displayDialog('Attention','Colliding with wall',sim.dlgstyle_message,true)
            end
            if(untouch_times<6) then  
            else   
                collisionTimes=collisionTimes+1
                collide_start_T=0
                untouch_times=0
                sim.endDialog(dialog_H)
            end 
My model will be transferred to a new place when it get to a specify position. But when the model collide with the wall, the dialog was showed and my model get to a place at the same time, the dialog will always be displayed on the interface and cannot be removed. So I want to add an if conditional statement to determine whether the Dialog exists, and if so, remove it. But I can't find any way to achieve this, please give me some suggestions, thank you so much!