【scene1.ks】
ここは通常のゲーム画面です。デバック画面に移行します。[p]
[if exp="f.debug_mode == 1"][call storage="debug.ks" target="*debug_input"][endif]
[if exp="f.switch01 == 0"][button graphic="icon2.png" storage="kiw_01.ks" target="*02_tyoko" x=910 y=550 enterimg="icon.png"][endif][if exp="f.switch02 == 0"][button graphic="icon2.png" storage="kiw_01.ks" target="*03_yari" x=1210 y=350 enterimg="icon.png"][endif]
[s]
;=================================================【ui_common.ks】
*debug_input[cm][if exp="f.debug_mode != 1"][return][endif]
[tb_show_message_window]変数変更コマンドを入力してください。[r]; gold→お金変更; HP→HP変更; MP→MP変更
入力方法:例:HP=100 例:js:f.HP=100; f.MP=100;[p]
[edit name="f.debug_text" width="900" height="70" size="40" left="420" top="520" maxchars="200" initial=""]
[button graphic="ok.png" text="送信" storage="debug.ks" target="*debug_apply" x="420" y="620" width="260" height="80"][button graphic="ok_n.png" text="戻る" storage="debug.ks" target="*debug_return" x="720" y="620" width="260" height="80"]
[s]
*debug_apply
;入力フォームの内容を変数へ反映[commit]
[cm]
[iscript]var cmd = String(f.debug_text || "").trim();f.debug_result = "";
try {
if (cmd === "") { f.debug_result = "入力なし"; }
// ============================== // 変数名=数値 の共通処理 // ============================== else if (cmd.indexOf("=") !== -1 && cmd.indexOf("js:") !== 0) {
var parts = cmd.split("="); var key = String(parts[0] || "").trim(); var val = Number(String(parts[1] || "").trim());
if (isNaN(val)) { f.debug_result = "数値ではありません:" + cmd; } else {
// 変更を許可する変数リスト var allow = [ "gold", "HP", "MP", ];
if (allow.indexOf(key) === -1) { f.debug_result = "変更不可の変数です:" + key; } else { f[key] = val; f.debug_result = key + " を " + val + " に変更しました"; } } }
// ============================== // js:自由実行 // 例 js:f.HP=100; f.MP=100; // ============================== else if (cmd.indexOf("js:") === 0) { var js = cmd.replace("js:", ""); Function("f", "sf", "tf", js)(f, sf, tf); f.debug_result = "JS実行完了:" + js; }
else { f.debug_result = "未対応コマンド:" + cmd; }
} catch(e) { f.debug_result = "エラー:" + e.message;}[endscript]
[tb_show_message_window][emb exp="f.debug_result"][p]
[eval exp="f.debug_text = ''"]
[jump storage="debug.ks" target="*debug_input"]
*debug_return[cm][return][cm]