====== Change the color of materials ====== This example VCI changes the color of a material when the grip button is pressed. ===== VCI script ===== function onUse(self) print("onUse") local r = math.random() local g = math.random() local b = math.random() vci.assets._ALL_SetMaterialColorFromIndex(0, Color.__new(r,g,b)) end math.random() is a pseudo-random number that returns a random value.\\ They randomly decide the value for red, blue and green to create a color. ===== About random ===== -- a = 0 ~ 1 a = math.random() -- b = 1 ~ 100 b = math.random(100) -- c = 1000 ~ 2000 c = math.random(1000, 2000) When you specify no argument, it returns a value between or equal to 0 and 1.\\ When you specify one argument, it returns a value between or equal to 1 and the argument value.\\ When you specify two arguments, it returns a value between or equal to the first argument and the second argument. [[http://lua-users.org/wiki/MathLibraryTutorial|math.random]]