HSPポータル
サイトマップ お問い合わせ


HSPTV!掲示板


未解決 解決 停止 削除要請

2011
0716
backdropとある格ゲーのツール作成にて6解決


backdrop

リンク

2011/7/16(Sat) 19:44:14|NO.40012

ある格闘ゲーム[M.U.G.E.N]というソフト専用のツールを作っています。
自分で作ったキャラがあり、それを登録するという簡単なものですが
なぜか実行ファイルにすると、ファイルを開く段階でエラーが出てしまいます。
(エクスプローラ上で、実行ファイルの上に目的のselect.defをドラックドロップして実行する形式です)
これは、ドラックドロップのコマンドラインが通常のコマンドプロンプトとは違うのか、
あるいは他に原因があるのでしょうか?

なお画面のX SIZE,Y SIZEは画面の横枠・縦枠の数です。枠の大きさではありません。
MUGENについて→http://www.elecbyte.com/mugen/

#packopt name "mugenSelect-def" #include "mod_regexp.as" #include "hsp3util.as" #module #deffunc d4box int x, int cx, int cy, int r, int g, int b, str sn, str st color 0, 0, 0 line cx, cy, cx+x, cy line cx, cy, cx, cy+x line cx, cy+x, cx+x, cy+x line cx+x, cy, cx+x, cy+x color r, g, b boxf cx+1, cy+1, cx+x-1, cy+x-1 color 0, 0, 0 pos cx+2, cy+2 font msgothic, 10.5 mes sn st2 = replace( st, "/", "\\" ) mes getpath( st2, 9 ) return #global title "MUGEN Select.def Editor" extlist = "" screen 0, 300, 200, 4 x = 0 : y = 0 : cellsize = 40 chardir="C:\\mugen" mes "SIZE X:" input x mes "SIZE Y:" input y mes "CELL SIZE:" input cellsize mes "MUGEN DIR" objsize 300, input chardir button "OK", *home stop *home xc = 0 yc = 0 sdim name, 30, x*y foreach name : name( cnt ) = "<---SPACE--->" : loop sdim stage, 100, x*y foreach stage : stage( cnt ) = ";(NO STAGE)" : loop gosub *load screen 0, 1280, 720, 0, 15, 15 width cellsize*x,720 x = int( x ) y = int( y ) cellsize = int( cellsize ) chdir chardir chdir "chars" lc="" dirlist lc, "*", 5 lc += "<---SPACE--->" chdir ".." chdir "stages" lc2="" dirlist lc2, "*.def", 1 lc2 += ";(NO STAGE)" notesel lc2 foreach stageindex : kc2 = notemax-1 : stageindex.cnt = kc2 : loop noteunsel chdir "..\\chars" pos 0, y*cellsize mes "CHARACTER TARGET:" objsize 300, gname="" gstage="" listbox kc, 70, lc namebox = stat button "(Edit Char.DEF)", *edit button "(Open Directory)", *opendir mes "COMMON STAGE:" listbox kc2, 50, lc2 stagebox = stat button "(ADD EXTRA)", *addext button "(Edit Stg.DEF)", *edit2 k="" button gosub "OK", *chg pos x/2*cellsize, y*cellsize mes "EXTRA STAGES:" listbox kc3, 120, extlist gs = stat button "DELETE", *delext mes "" mes "" button "CHARS ALL CLEAR", *clear mes "" mes "" button "RELOAD", *home *main repeat gosub *drawcell stick kk, 15 if kk & 1 : xc-- : if xc < 0 : xc = x-1 if kk & 2 : yc-- : if yc < 0 : yc = y-1 if kk & 4 : xc++ : if xc >= x : xc = 0 if kk & 8 : yc++ : if yc >= y : yc = 0 if kk == 128 : gosub *save if kk == 32 : gosub *move onclick gosub *clicked if kk == 1024 : gosub *chg await 1 loop *clear foreach name : name( cnt ) = "<---SPACE--->" : loop foreach stage : stage( cnt ) = ";(NO STAGE)" : loop goto *main *opendir notesel lc noteget txt,kc exec "explorer "+txt goto *main *edit notesel lc noteget txt,kc noteunsel exec "NOTEPAD.EXE \""+txt+"\\"+txt+".def\"" goto *main *edit2 notesel lc2 noteget txt,kc2 noteunsel exec "NOTEPAD.EXE \"..\\stages\\"+txt+"\"" goto *main *clicked if ( mousex <= cellsize*x ) and ( mousey <= cellsize*y ){ xc = mousex/cellsize yc = mousey/cellsize } return *addext notesel lc2 noteget txt, kc2 noteunsel notesel extlist noteadd "stages/"+txt, -1, 0 noteunsel objprm gs, extlist goto *main *delext if kc3 != -1{ notesel extlist notedel kc3 noteunsel objprm gs, extlist } goto *main *move notesel lc repeat notemax noteget txt, cnt if txt == name( yc*x+xc ) : kc = cnt objprm namebox, kc loop noteunsel return *drawcell redraw 0 repeat y c = cnt repeat x if ( cnt == xc ) and ( c == yc ){ d4box cellsize, cnt*cellsize, c*cellsize, $ff, $ff, 0, name( c*x+cnt ), stage( c*x+cnt ) }else{ if name( c*x+cnt ) == "<---SPACE--->"{ d4box cellsize, cnt*cellsize, c*cellsize, $ff, $80, 0, name( c*x+cnt ), stage( c*x+cnt ) }else{ d4box cellsize, cnt*cellsize, c*cellsize, 0, $ff, $ff, name( c*x+cnt ), stage( c*x+cnt ) } } loop loop redraw 1 return *chg notesel lc noteget txt, kc noteunsel notesel lc2 noteget txt2, kc2 noteunsel name( yc*x+xc ) = txt stage( yc*x+xc ) = "stages/" + txt2 goto *main *save dialog "def", 17, "MUGEN SELECT.DEF" if stat != 1 : return savebuf="" notesel savebuf noteadd "[Characters]", 0, 1 foreach name noteadd name( cnt ) + ", " + stage( cnt ), -1, 0 loop noteadd "[ExtraStages]", -1, 0 noteadd extlist, -1, 0 noteadd "[Options]", -1, 0 noteadd "arcade.maxmatches = 6,1,1,0,0,0,0,0,0,0", -1, 0 noteadd "team.maxmatches = 4,1,1,0,0,0,0,0,0,0", -1, 0 notesave refstr noteunsel return *load c = dir_cmdline if c != ""{ buf="" notesel buf noteload c repeat notemax noteget txt, cnt if txt == "[Characters]" : stch = cnt+1 if txt == "[ExtraStages]" : edch = cnt-1 : stex = cnt+1 if txt == "[Options]" : edex = cnt-1 loop repeat edch-stch, stch noteget txt, cnt if instr( txt, 0, match( txt, "\\s*;" ) ) == 0 : skipped++ : continue //ステージ割り振りがあるかチェック if instr( txt, 0, "," ) != -1{ chname = stname = "" split txt, ",", chname, stname name( cnt-stch-skipped ) = chname if stname != "" : stage( cnt-stch-skipped ) = replace( stname, "\\s\\s+", "" ) }else{ if ( txt != "" ) or ( txt != "<---SPACE--->" ){ name( cnt-stch-skipped ) = txt stage( cnt-stch-skipped ) = ";(NO STAGE)" }else{ name( cnt-stch-skipped ) = "<---SPACE--->" stage( cnt-stch-skipped ) = ";(NO STAGE)" } } loop repeat edex-stex, stex noteget txt, cnt extlist += txt + "\n" loop } return



この記事に返信する


KA

リンク

2011/7/16(Sat) 21:21:07|NO.40013

長いスクリプトが悪いとは言いませんが、再現できる最小限の部分だけ
載せましょう、そうする事で自己解決する場合も有ります。



木村

リンク

2011/7/16(Sat) 23:32:38|NO.40014

 とりあえず軽く流し読みしての所感。あくまで承知の上でしたら御免なさい。

1,意味の無いif式

/*255行目*/ if ( txt != "" ) or ( txt != "<---SPACE--->" ){
 この条件式は、txtがどんな値でも真になると思います。どういう意味でしょうか。


2,超巨大な省略可能if節
/*233行目*/  if c != ""{
/*----中略部分----*/ /*269行目*/ } /*270行目*/ return
 この部分は条件式を変えるだけで超巨大なif節を解消できます。以下は一例
if c = "" : return
/*----中略部分----*/ return


3,多分キャラの処理抜けが生じる部分(238行目から245行目、265行目)
 例えば[Characters]の行が1行目、[ExtraStages]の行が5行目だとすると、stchは2、edchは4になります。
 ところが[Chara...]と[Extra...]の間の行数は3行、edch-stchは2なので1人処理抜けが生じる事になる気がします。


4,lineとboxfの併せ技(6行目から12行目)
 line命令4回とboxf命令1回で動かしている部分ですが、boxf命令2回で処理できます。以下は一例
color 0, 0, 0
boxf cx, cy, cx+x, cy+x //cy+xは誤字では無いので注意 color r, g, b boxf cx+1, cy+1, cx+x-1, cy+x-1


5,無意味な代入命令
/*250行目*/  chname = stname = ""
/*251行目*/ split txt, ",", chname, stname
 250行目はstnameが""だったならchnameに1を、それ以外なら0を返すと言う意味合いでしょうが、251行目で双方split命令で上書きされてしまいます。
 txtに","が含まれていなければstnameの値は生き残りそうなものですが、実はsplit命令が発令された段階でstnameもchnameもNullに初期化されます。以下は実例
	m = "ひゃっはー"
a = "0" : b = "0" : c = "0" split m, ",", a, b, c mes "A="+a+" : B="+b+" : C="+c


6,オブジェクト部分が画面外にはみ出たり干渉する恐れあり(多分)
 *homeラベルの部分で1280×720サイズのウィンドウを1つ取得しています。y*cellsizeより上を描画部分、それより下をボタン等のオブジェクト部分としています。
 ところで、このオブジェクト部分のY幅は結構長いです。デフォルトのY幅のボタンが5基(24*5=120pixel)、mes命令が2回(16*2=32pixel)、listbox命令の拡張Y幅が合計120pixel、まとめて272pixel以上のY幅をオブジェクト部分が要求しています。
 yとcellsizeの初期設定次第ですが、両者の積が472を上回る場合、OKボタンが画面上から消えてしまいます。
 52行目のscreen命令を
screen 0, x*cellsize+300, y*cellsize+300, 0, 15, 15

のように自由にxやyの値を取れる形式に変えるか、オブジェクト部分を別のウィンドウに移籍させた方が良い気がします。  このままではyとcellsizeの積が少ない場合は当然、xとcellsizeの積が600を超えないとオブジェクト同士が干渉してしまう可能性もあります。



backdrop

リンク

2011/7/17(Sun) 00:12:55|NO.40015

回答ありがとうございます
>if ( txt != "" ) or ( txt != "<---SPACE--->" ){
多分andの間違いです。ごめんなさい

>250行目はstnameが""だったならchnameに1を、それ以外なら0を返すと言う意味合いでしょうが、251行目で双方split命令で上書きされてしまいます。
>実はsplit命令が発令された段階でstnameもchnameもNullに初期化されます
単に一時的に必要な文字列を代入するだけですが該当部分を無くすとエラーが出てしまいました
HSPシステムが処理する際、スクリプトの単純代入と違う方法で代入しているようです
そのため変数の内容はNullにならずエラーを吐くようです



とおりすがり

リンク

2011/7/17(Sun) 05:50:15|NO.40016

コマンドライン文字列について誰も回答していない件について。

問題がコマンドラインまわりか、それ以外の部分なのか確認する簡単な方法は、
ロードをコマンドラインでなくダイアログでやってみる事です。
c = dir_cmdline
この部分を
dialog "def",16,""
if stat ! 0 : c = refstr
などと書き変えて実行して見てください。

正常にロードできるようならコマンドライン文字列の扱いに問題があります。
そうでなければ、ファイルの解析の仕方に問題があるという事かもしれません。



backdrop

リンク

2011/7/17(Sun) 16:10:52|NO.40018

>とおりすがりさん
ありがとうございます
解決しました

>木村さん
いろいろとご指摘いただきありがとうございます



とおりすがり

リンク

2011/7/18(Mon) 16:10:49|NO.40023

無事解決して何よりです。まだ見ておられるか分かりませんが
もしよければ、トラブルの原因が何で、どうしたら解決したのか
書いておいてくださると他の方の役に立ちます。



ONION software Copyright 1997-2023(c) All rights reserved.