a2ab91c992
fix usage of `math.random` in various places to provide both a minimum and a maximum number, instead of just maximum. also renamed some files very slightly.
36 lines
855 B
Lua
36 lines
855 B
Lua
blockgame.vector = blockgame.vector or {}
|
|
local api = blockgame.vector
|
|
|
|
-- TODO: replace direct sharing of api variables such as `sides` with functions that return them, to prevent other mods from mutating the shared data.
|
|
|
|
api.horizontal_directions = {
|
|
west = vector.new(-1, 0, 0),
|
|
east = vector.new(1, 0, 0),
|
|
south = vector.new(0, 0, -1),
|
|
north = vector.new(0, 0, 1),
|
|
}
|
|
api.sides = api.horizontal_directions
|
|
|
|
api.directions = {
|
|
west = vector.new(-1, 0, 0),
|
|
east = vector.new(1, 0, 0),
|
|
down = vector.new(0, -1, 0),
|
|
up = vector.new(0, 1, 0),
|
|
south = vector.new(0, 0, -1),
|
|
north = vector.new(0, 0, 1),
|
|
}
|
|
api.dirs = api.directions
|
|
|
|
|
|
|
|
function api.random_dir ()
|
|
return blockgame.random_element(api.dirs)
|
|
end
|
|
|
|
function api.random_side ()
|
|
return blockgame.random_element(api.sides)
|
|
end
|
|
|
|
function api.get_below (pos)
|
|
return pos + api.dirs.down
|
|
end
|