本文知識點
1. 獲取時間
2. 時間格式要正確
3. 事件內如何設計
正文開始
1. 獲取時間
首先獲取當前時間 然后保存在 事件內的變量里面 后需要判斷時間是否相等
function 獲取當前日期(){const now = new Date();return now.toISOString();};
2. 時間格式要正確
now.toISOString(); 這句代碼很重要 RPGMZ游戲引擎 保存到變量之后再讀取的話就是這個格式
所以我們按照RPGMZ自帶的格式進行獲取
3.事件的設計
直接上圖片自己看
照著抄沒錯
日期判斷函數在這里
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論壇的小圈子 離開