![見出し画像](https://assets.st-note.com/production/uploads/images/111332997/rectangle_large_type_2_8c65aa5bc2e75e8b2a301aca6e4fd72d.png?width=1200)
【ティラノスクリプト】数字をカウントアップ・ダウンさせるサンプル
![](https://assets.st-note.com/production/uploads/images/111332376/picture_pc_bc32929c2ad9fc104bd200803962a1a1.gif?width=1200)
【scene1.ks】
[iscript]
f.point = 100;
f.updated_point = 100;
[endscript]
[call storage="counter.ks"]
*action
[glink target="*result" text="体力が10上昇" x="377" y="100" width="400" exp="f.updated_point += 10"]
[glink target="*result" text="体力が10減少" x="377" y="200" width="400" exp="f.updated_point -= 10"]
[s]
*result
[call storage="counter.ks" target="*update"]
[jump target="action"]
【counter.ks】
*set
[layopt layer="fix" visible="true"]
[ptext layer="fix" text="&f.point" x="100" y="100" size="100" color="yellow" bold="bold" edge="black" name="point"]
*update
[iscript]
let counter = setInterval(function(){
if(f.point == f.updated_point){
clearInterval(counter);
TYRANO.kag.ftag.nextOrder();
return false;
} else if (f.point < f.updated_point) {
f.point++;
} else if (f.point > f.updated_point) {
f.point--;
}
$('p.point').text(f.point);
}, 100);
[endscript stop="true"]
[return]
この記事が気に入ったらサポートをしてみませんか?