script communication

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

script communication

Post by sampits »

Ive been working with two script one move a conveyer depending on the proximity sensor state and for that i used the sysCall_sensing() function.
Now i want to go there with my robot but i can seem to be able to communicate between the scripts since the sensordetection variable doesnt work outside of the function sysCall_sensing or so i think.
Any ideas on how i can call that function on the robot script?

coppelia
Site Admin
Posts: 10339
Joined: 14 Dec 2012, 00:25

Re: script communication

Post by coppelia »

Hello,

you have many different ways to share information between scripts or the outside world. Signals are probably the easiest.

Cheers

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

Re: script communication

Post by sampits »

now i have a different problem, when i pass a 0 to the conveyer it runs and when i pass a 1 it stops, even tough it works, when i am in 0 it doesnt change to 1 and when i am in 1 it doesnt change to 0 its weird to explain but what im trying to say is that once it is in a a state it doesnt change to other.(doesnt update the state)

Code: Select all

   teste=sim.getFloatSignal("ok")
    
    if teste==0 then
        beltVelocity=sim.setFloatSignal("conveyorBeltVelocity",0.05)
    else 
    if teste==1 then
        beltVelocity=sim.setFloatSignal("conveyorBeltVelocity",0)
    end
    end
    

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

Re: script communication

Post by sampits »

coppelia wrote: 11 Feb 2020, 15:02 Hello,

you have many different ways to share information between scripts or the outside world. Signals are probably the easiest.

Cheers
now i have a different problem, when i pass a 0 to the conveyer it runs and when i pass a 1 it stops, even tough it works, when i am in 0 it doesnt change to 1 and when i am in 1 it doesnt change to 0 its weird to explain but what im trying to say is that once it is in a a state it doesnt change to other.(doesnt update the state)

Code: Select all

teste=sim.getFloatSignal("ok")

if teste==0 then
    beltVelocity=sim.setFloatSignal("conveyorBeltVelocity",0.05)
else
if teste==1 then
    beltVelocity=sim.setFloatSignal("conveyorBeltVelocity",0)
end
end

Post Reply