Add vector.random
This commit is contained in:
parent
e02b24eb74
commit
83e669cb70
@ -1907,6 +1907,8 @@ global record vector
|
||||
rotate: function(Vec3, number): Vec3
|
||||
rotate_around_axis: function(Vec3, Vec3, number): Vec3
|
||||
dir_to_rotation: function(Vec3, Vec3): Vec3
|
||||
|
||||
random: function(number, number, number, number, number, number): Vec3
|
||||
end
|
||||
|
||||
global record Vec2
|
||||
@ -2012,4 +2014,6 @@ global record GameSoundDispatcher
|
||||
plant_sounds: function (NodeSoundSpec): NodeSoundSpec
|
||||
glass_sounds: function (NodeSoundSpec): NodeSoundSpec
|
||||
wool_sounds: function (NodeSoundSpec): NodeSoundSpec
|
||||
end
|
||||
end
|
||||
|
||||
global function random_range(min: number, max: number): number print(min,max) end
|
@ -1,9 +1,4 @@
|
||||
local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local ipairs = _tl_compat and _tl_compat.ipairs or ipairs; local string = _tl_compat and _tl_compat.string or string; local table = _tl_compat and _tl_compat.table or table
|
||||
|
||||
function println(...) end
|
||||
|
||||
|
||||
function switch(input, ...)
|
||||
local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local ipairs = _tl_compat and _tl_compat.ipairs or ipairs; local math = _tl_compat and _tl_compat.math or math; local string = _tl_compat and _tl_compat.string or string; local table = _tl_compat and _tl_compat.table or table; function switch(input, ...)
|
||||
local tableized = { ... }
|
||||
for k, v in ipairs(tableized) do
|
||||
if ((k + 1) % 2 == 0) then
|
||||
@ -71,3 +66,17 @@ function concat(...)
|
||||
end
|
||||
return accumulator
|
||||
end
|
||||
|
||||
function random_range(min, max)
|
||||
return (math.random() * (max - min) + min)
|
||||
end
|
||||
|
||||
local rr = random_range
|
||||
|
||||
function vector.random(min_x, max_x, min_y, max_y, min_z, max_z)
|
||||
return vector.new(
|
||||
rr(min_x, max_x),
|
||||
rr(min_y, max_y),
|
||||
rr(min_z, max_z))
|
||||
|
||||
end
|
||||
|
@ -1,8 +1,3 @@
|
||||
|
||||
|
||||
global function println(...: any) end
|
||||
|
||||
|
||||
global function switch(input: any, ...: any | function(any): any): any
|
||||
local tableized = {...}
|
||||
for k,v in ipairs(tableized) do
|
||||
@ -70,4 +65,18 @@ global function concat(...: string): string
|
||||
accumulator = accumulator .. v
|
||||
end
|
||||
return accumulator
|
||||
end
|
||||
|
||||
global function random_range(min: number, max: number): number
|
||||
return (math.random() * (max - min) + min)
|
||||
end
|
||||
|
||||
local rr = random_range
|
||||
|
||||
function vector.random(min_x: number, max_x: number, min_y: number, max_y: number, min_z: number, max_z: number): Vec3
|
||||
return vector.new(
|
||||
rr(min_x, max_x),
|
||||
rr(min_y, max_y),
|
||||
rr(min_z, max_z)
|
||||
)
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user