用户:
小宏XeLa查看:25 回复:24 评论:25 创建时间:2023-06-18T18:11:15
world.onPlayerJoin(({ entity }) => {
entity.point = new GameVector3(0, 0, 0);
entity.player.onPress(({ raycast, button }) => {
if (button === "action0")
entity.point = raycast.voxelIndex.clone();
});
entity.player.enable3DCursor = true;
gui.init(entity, {
"panel": {
display: true,
data: `<dialog width="300" percentHeight="100" top="60" right="20" id="">
<group percentWidth="100" height="120" y="0">
<label text="玩家坐标" height="35" y="5" x="10" percentWidth="100" color="#fff" fontSize="20"></label>
<label text="" height="25" y="35" x="10" percentWidth="100" color="#fff" id="positionshowdx"></label>
<label text="" height="25" y="60" x="10" percentWidth="100" color="#fff" id="positionshowdy"></label>
<label text="" height="25" y="85" x="10" percentWidth="100" color="#fff" id="positionshowdz"></label>
</group>
<group percentWidth="100" height="120" y="130">
<label text="记录点坐标" height="35" y="5" x="10" percentWidth="100" color="#fff" fontSize="20"></label>
<label text="" height="25" y="35" x="10" percentWidth="100" color="#fff" id="pointshowx"></label>
<label text="" height="25" y="60" x="10" percentWidth="100" color="#fff" id="pointshowy"></label>
<label text="" height="25" y="85" x="10" percentWidth="100" color="#fff" id="pointshowz"></label>
</group>
</dialog>`
}
})
var recordY = entity.position.y;
world.onTick(() => {
var space = entity.position.y - recordY;
var isup = space > 0;
var isdown = space < 0;
var Ystatus = `${isdown ? "下降" : (isup ? "上升" : "")}中,变化幅度:`;
recordY = entity.position.y;
gui.setAttribute(entity, "#positionshowdx", "text", `X:${~~entity.position.x}`);
gui.setAttribute(entity, "#positionshowdy", "text", `Y:${~~entity.position.y}` + (Ystatus.length > 7 ? `(${Ystatus}${(space).toFixed(2)})` : ""));
gui.setAttribute(entity, "#positionshowdz", "text", `Z:${~~entity.position.z}`);
gui.setAttribute(entity, "#pointshowx", "text", `X:${~~entity.point.x}`);
gui.setAttribute(entity, "#pointshowy", "text", `Y:${~~entity.point.y}`);
gui.setAttribute(entity, "#pointshowz", "text", `Z:${~~entity.point.z}`);
gui.setAttribute(entity, "#flystatus", "text", `状态:${entity.player.canFly ? "启用" : "禁用"}`);
});
})