vectorA:mul

From ComputerCraft Wiki
Jump to: navigation, search


Grid Redstone.png  Function vector:mul
Multiplies a vector with a scalar and returns the resulting vector.
Syntax vector:mul(number multiplier)
Returns vector
Part of ComputerCraft
API vector

Examples

Grid paper.png  Example
Multiplies a vector by a number and prints the resulting vector.
Code
local a = vector.new(1, 2, 3)
local b = 2.5

local c = a:mul(b)
--local c = a * b

print(c.x)
print(c.y)
print(c.z)
--2.5
--5
--7.5



Grid paper.png  Example
Code to recreate the function. Gives insight into what the function does.
Code
local a = vector.new(1, 2, 3)
local b = 2

local c = vector.new((a.x * b), (a.y * b), (a.z * b))
--c.x = 2
--c.y = 4
--c.z = 6
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox