用户:
YDS尹子查看:10 回复:15 评论:10 创建时间:2020-08-08T13:39:02

喵=n c
world.onPlayerJoin(({entity})=>{
entity.player.call="旅行者";
entity.player.interactTimes=0;
entity.enableInteract=true;
entity.interactRadius=3;
entity.interactHint="互动"+entity.player.name;
entity.interactColor.set(1,1,1);
entity.onInteract(async({entity,targetEntity})=>{
const result=await entity.player.dialog({
type: Box3DialogType.TEXT,
title: targetEntity.player.name,
lookEye: entity,
lookTarget: targetEntity,
content: `你好,${entity.player.call}${entity.player.name},很高兴认识你。`,
})
entity.player.interactTimes++;
if(entity.player.interactTimes>=5){
entity.player.call="交流者";
}
})
})
其实大家可以看到 https://docs.box3.codemao.cn/box3dialogcall.html
有文本框,选项框和输入框
这个更新让游戏交互更加好
框还可以有特别的样式
点赞0
评论
补充一下hh
world.onPlayerJoin(({ entity }) => {//有玩家进入地图时
entity.player.showName = false //为有更好的效果,隐藏玩家的名字(否则会很奇怪)
entity.enableInteract = true //允许实体互动
entity.interactRadius = 5 //互动范围
entity.interactHint = `和 "${entity.player.name}" 互动` //可以互动时显示的文字
})
world.onInteract(async ({ entity, targetEntity }) => {
const result = await entity.player.dialog({
type: Box3DialogType.SELECT,
title: "系统",
lookEye: entity,
lookTarget: targetEntity,
content: `向" ${targetEntity.player.name} "互动`,
options: ['对话', '取消'],
});
if (result.index === 0) {
const result1 = await entity.player.dialog({
type: Box3DialogType.INPUT,
title: "系统",
lookTarget: entity,
content: `请输入对话内容`,
confirmText: "发出对话"
});
if (result1 != null) {
targetEntity.player.dialog({
type: Box3DialogType.TEXT,
title: entity.player.name,
content: result1,
});
}
}
});点赞0
评论