Jump to content

change marker color randomly


Samking

Recommended Posts

  • Moderators

Only between this 3 color?

local random_number = math.random(1, 3) -- pick a random number between [1, 3]

local r, g, b
if random_number == 1 then
    r, g, b = 255, 0, 0
elseif random_number == 2 then
    r, g, b = 0, 255, 0
elseif random_number == 3 then
    r, g, b = 0, 0, 255
end

createMarker(0, 0, 3, "cylinder", 2, r, g, b)

 

  • Like 1
Link to comment
On 17/04/2020 at 09:17, Patrick said:

Only between this 3 color?


local random_number = math.random(1, 3) -- pick a random number between [1, 3]

local r, g, b
if random_number == 1 then
    r, g, b = 255, 0, 0
elseif random_number == 2 then
    r, g, b = 0, 255, 0
elseif random_number == 3 then
    r, g, b = 0, 0, 255
end

createMarker(0, 0, 3, "cylinder", 2, r, g, b)

 

Thanks,

and in  line 3 you should add

local r, g, b = 0,0,0

 

else  it will generate marker colors other than green,blue and red when using loop 

☺️

Edited by Samking
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...