Difference between revisions of "VectorA:mul"
From ComputerCraft Wiki
(Changing int to number) |
|||
(3 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
− | + | {{lowercase}} | |
− | + | {{Function | |
− | + | |name=vector:mul | |
− | + | |args={{type|number}} multiplier | |
− | + | |returns=[[vector (API)|vector]] | |
− | + | |api=vector | |
− | + | |addon=ComputerCraft | |
− | + | |desc=Multiplies a vector with a scalar and returns the resulting vector. | |
− | + | |examples= | |
− | + | {{Example | |
− | + | |desc=Multiplies a vector by a number and prints the resulting vector. | |
− | + | |code=local a = vector.new(1, 2, 3) | |
− | + | ||
− | + | ||
local b = 2.5 | local b = 2.5 | ||
local c = a:mul(b) | local c = a:mul(b) | ||
+ | --local c = a * b | ||
print(c.x) | print(c.x) | ||
Line 23: | Line 22: | ||
--5 | --5 | ||
--7.5 | --7.5 | ||
+ | }} | ||
+ | {{Example | ||
+ | |desc=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 | ||
+ | }} | ||
+ | }} | ||
+ | |||
+ | [[Category:API_Functions]] |
Latest revision as of 13:11, 18 July 2013
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