fix transform:set_pos
This commit is contained in:
parent
a105a4f2c7
commit
ee768f878c
@ -2,10 +2,12 @@ history = session.get_entry("commands_history")
|
|||||||
history_pointer = #history
|
history_pointer = #history
|
||||||
|
|
||||||
function setup_variables()
|
function setup_variables()
|
||||||
local x,y,z = player.get_pos(hud.get_player())
|
local pid = hud.get_player()
|
||||||
|
local x,y,z = player.get_pos(pid)
|
||||||
console.set('pos.x', x)
|
console.set('pos.x', x)
|
||||||
console.set('pos.y', y)
|
console.set('pos.y', y)
|
||||||
console.set('pos.z', z)
|
console.set('pos.z', z)
|
||||||
|
console.set('entity.id', player.get_entity(pid):get_uid())
|
||||||
end
|
end
|
||||||
|
|
||||||
function on_history_up()
|
function on_history_up()
|
||||||
|
|||||||
@ -106,10 +106,14 @@ console.add_command(
|
|||||||
)
|
)
|
||||||
|
|
||||||
console.add_command(
|
console.add_command(
|
||||||
"tp obj:sel=$obj.id x:num~pos.x y:num~pos.y z:num~pos.z",
|
"tp entity:sel=$entity.id x:num~pos.x y:num~pos.y z:num~pos.z",
|
||||||
"Teleport object",
|
"Teleport entity",
|
||||||
function (args, kwargs)
|
function (args, kwargs)
|
||||||
player.set_pos(unpack(args))
|
local eid, x, y, z = unpack(args)
|
||||||
|
local entity = entities.get(eid)
|
||||||
|
if entity ~= nil then
|
||||||
|
entity.transform:set_pos({x, y, z})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
console.add_command(
|
console.add_command(
|
||||||
|
|||||||
@ -9,7 +9,9 @@ static int l_transform_get_pos(lua::State* L) {
|
|||||||
|
|
||||||
static int l_transform_set_pos(lua::State* L) {
|
static int l_transform_set_pos(lua::State* L) {
|
||||||
if (auto entity = get_entity(L, 1)) {
|
if (auto entity = get_entity(L, 1)) {
|
||||||
entity->getTransform().setPos(lua::tovec3(L, 2));
|
auto vec = lua::tovec3(L, 2);
|
||||||
|
entity->getTransform().setPos(vec);
|
||||||
|
entity->getRigidbody().hitbox.position = vec;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user