我对lua脚本很新...现在我试图在游戏老板中编码
local function SlitherEvents(event, creature, attacker, damage)
if(creature:GetHealthPct() <= 60) then
creature:SendUnitYell("Will punish you all",0)
creature:RegisterEvent(AirBurst, 1000, 0) -- 1 seconds
return
end
end
这应该让老板在他的健康状况= 60%或更低时说话,但它应该运行一次,当我运行代码时老板一直在说并且一直在攻击。如何让它运行一次?
答案 0 :(得分:2)
使用在函数回调范围之外创建的布尔值:
lc1.on('renderlet', function(lc1) {
var allDots1 = lc1.selectAll('circle.dot');
var allDots2 = lc2.selectAll('circle.dot');
var allDots3 = lc3.selectAll('circle.dot');
allDots1.on('click', function(d) {
var d2find = d.x;
var d2find2 = d3.select(this).datum();
console.log(myCSV);
alert('Captured:'+"\nX-axis (Date): "+d2find2.x +"\nY-axis (Value): "+ d2find2.y +"\nDesired: display corresponding values from all three charts for this (date/time) datapoint");
allDots2.filter(d=>d.x == d2find2).attr('fill','red');
findAllPoints(d2find2);
});//END allDots1.on(click);
function findAllPoints(datum) {
var objOut = {};
var arrLines=['car','bike','moto'];
for (var i = 0; i < 3; i++) {
thisSrx = arrLines[i];
console.log('thisSrx: '+thisSrx);
console.log(myCSV[i].date)
console.log(datum.x);
//loop thru myCSV obj, compare myCSV[i].date to clicked "x" val
//build objOut with data from each graph at same "X" (d/t) as clicked
objOut[i] = myCSV[i].filter(e => e.date === datum.x)[0][thisSrx];
}
$('#msg').html( JSON.stringify(objOut) );
console.log( JSON.stringify(objOut) );
}//END fn findAllPoints()
});//END lc1.on(renderlet)
如果您实际使用Eluna Engine's RegisterEvent
来电,请将重复次数设置为 1 而不是0.这将解析issue you had。