- 追加された行はこの色です。
- 削除された行はこの色です。
#author("2024-03-07T14:23:39+09:00","default:discord","discord")
#author("2024-04-14T12:08:02+09:00","default:discord","discord")
WMSを使うと、様々なことが可能になりますが、非プログラマにとっては、一から書き上げるのがたいへんです。
そこで、こういう場合はこれを使う、というコピペ事例集をこちらのページにまとめます。
&br;
* メッセージウインドウ、フォント、横書きなどの初期化をする [#j2b9f551]
func main() {
s2_set_config("msgbox.tategaki", "0"); #横書き
s2_set_config("font.file", "VL-PGothic-Regular.ttf"); #フォント名指定
s2_set_config("msgbox.bg.file", "msgbox-bg.png");
s2_set_config("msgbox.fg.file", "msgbox-fg.png");
s2_set_config("msgbox.x", "0"); #メッセ―ジボックスのx座標
s2_set_config("msgbox.y", "457"); #メッセ―ジボックスのy座標
s2_set_config("msgbox.margin.left", "80"); #メッセージボックスの左マージン
s2_set_config("msgbox.margin.right", "80"); #メッセージボックスの右マージン
s2_set_config("msgbox.margin.top", "59"); #メッセージボックスの上マージン
s2_set_config("sysmenu.hidden", "0"); #システムメニューを隠さない
s2_set_config("namebox.hidden", "0"); #名前ボックスは隠さない
s2_set_config("click.move", "0"); #クリックカーソルは隠さない
s2_set_config("click.x", "1170"); #クリックカーソルのx座標
s2_set_config("click.y", "645"); #クリックカーソルのy座標
s2_reflect_msgbox_and_namebox_config(); #メッセージ&名前ボックス設定変更
s2_reflect_font_config(); #フォント設定の変更
}
&br;
* 変数を取得し、計算した後、ゲーム内変数に書き込む [#x11859c2]
func main() {
// 変数を取得する
a = s2_get_variable(0);
b = s2_get_variable(1);
c = s2_get_variable(2);
// 合計を計算する
sum = a + b + c;
// 変数100番に書き込む
s2_set_variable(100, sum);
}
* ゲーム内で現実の日時を取得 [#ne63d10e]
get-datetime.txt (wmsフォルダ) に以下のように記述します。
func main() {
// 日時を取得
now_y = s2_get_year();
now_mo = s2_get_month();
now_d = s2_get_day();
now_h = s2_get_hour();
now_mi = s2_get_minute();
now_s = s2_get_second();
now_w = s2_get_wday(); // 0=日、 1=月、 2=火……
// ゲーム内の変数$1と$2に、月と日にちの値を代入
s2_set_variable(1, now_mo);
s2_set_variable(2, now_d);
}
そして、例えばシナリオファイルで以下のようにすると、あらかじめ設定していた誕生日の日のみにメッセージを出すなどができます。
@wms get-datetime.txt
@if $1 == 4 april
@goto not_birthday
:april
@if $2 == 14 birthday
@goto not_birthday
:birthday
お誕生日おめでとう!
@goto common
:not_birthday
誕生日ではありません。
:common
# 以下略
また、時間帯によってメッセージを変えるなどに使えます。