本文知识点
-
获取时间
-
时间格式要正确
-
事件内如何设计
正文开始
1. 获取时间
首先获取当前时间 然后保存在 事件内的变量里面 后需要判断时间是否相等
javascript
function 获取当前日期(){
const now = new Date();
return now.toISOString();
};
2. 时间格式要正确
now.toISOString(); 这句代码很重要 RPGMZ游戏引擎 保存到变量之后再读取的话就是这个格式
所以我们按照RPGMZ自带的格式进行获取
3.事件的设计
直接上图片自己看
照着抄没错
日期判断函数在这里
javascript
function 日期判断(dateStr2) {
const d1 = new Date(获取当前日期());
const d2 = new Date(dateStr2);
const year1 = d1.getFullYear();
const month1 = d1.getMonth() + 1;
const date1 = d1.getDate();
const House1 = d1.getHours();
const year2 = d2.getFullYear();
const month2 = d2.getMonth() + 1;
const date2 = d2.getDate();
const House2 = d2.getHours();
// 输出格式化后的日期(符合日常习惯)
console.log(`日期1: ${year1}-${month1}-${date1}-${House1}`);
console.log(`日期2: ${year2}-${month2}-${date2}-${House2}`);
if(year1 === year2 && month1 === month2 && date1 === date2 && House1 === House2){
return true;
}
return false;
};
如果日期相等 年月日时都相等 返回 true
返回 false 就继续开启副本就可以了
结尾总结
请Project1论坛的小圈子 离开