作者laechan (小太保)
看板mud_sanc
標題[副本] map2data
時間Sat Apr 19 17:44:57 2014
justin 我看你已經寫好了,那因為你在斷線狀態,我補了一行
return map,用 running code 測試的結果如下:
tmp=@LONG
001-002 005-006
| | |
003-004 007
|
009-008
LONG
;
data="/std/new_ob/instance/instance_ob"->map2data(tmp);
write(identify(data)+"\n");
========== 程式執行區 ==========
([
"009" : ([ "east" : "008" ]),
"008" : ([ "west" : "009" ]), // 少了 north
"007" : ([ ]), // 少了 south north
"006" : ([ "west" : "005" ]), // 少了 south
"005" : ([ "east" : "006" ]), // 少了 south
"004" : ([ "west" : "003" ]), // 少了 north
"003" : ([ "east" : "004" ]), // 少了 north
"002" : ([ "west" : "001" ]), // 少了 south
"001" : ([ "east" : "002" ])
])
========== 程式執行區 ==========
這樣可以看出大概的問題,你可以再檢查一下,大抵上就是
map[t2]["north"] 跟 map[t2]["south"] 的判斷完全沒有執
行到,有執行到就會有資料,我加了 debug 行你可以參考
south 的判斷字串: [ | | |][ ]
south 的判斷字串: [ | | |][ | ]
south 的判斷字串: [ | | |][ | ]
south 的判斷字串: [ | | |][ |]
north 的判斷字串: [ | | |][ | ]
south 的判斷字串: [ |][ ]
north 的判斷字串: [ | | |][ | ]
south 的判斷字串: [ |][ ]
north 的判斷字串: [ | | |][ |]
south 的判斷字串: [ |][ |]
north 的判斷字串: [ |][ ]
north 的判斷字串: [ |][ |]
^^^^^^^^^^^^^^ ^^
t3 t3[a..b]
Laechan
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 111.253.160.16
※ 文章網址: http://webptt.com/m.aspx?n=bbs/mud_sanc/M.1397900701.A.CA1.html
補充一下,這函數寫在 map2data 的用意,就是你可以直接在
函數內使用 instance_data 這個變數「而無需宣告」,然後你
的設定目標就是放在
instance_data["房間號碼"]["exits"]["出口方向"]
那問題在於,先前我說你可以使用
instance_rooms=({
"001","001",.....
});
實際上應該是不行的,因為每一個 room_file 都代表一個 key
name,相同的 room_file 其 key name 會相同。
那我有想到一個解決方案,就是我們再加一個參數,用來判斷
我們的副本使用的是「實際的基底區域」還是「虛擬的基底區
域」,例如 instance_virtual 這個參數
instance_virture = "/std/new_ob/instance/virtual/xxx"
有這個參數時,它就以 xxx.c 這個檔案當做大家統一使用的房
間檔。
然後我再把 instance_ob.c 翻一翻,它就可以支援虛擬基底區
域的做法,基本上也很簡單,就是不要讓它讀 oroom 的資料就
行了。
(你可以想像所有的資料都在 instance_data 內)
Laechan
※ 編輯: laechan (111.253.160.16), 04/19/2014 17:59:41
1F:推 justinj :那是轉換的時候出了問題....修好了.. 04/20 09:59
2F:→ laechan :今天會完成 map2data 參數及 instance_virtual 參數 04/21 07:51
3F:→ laechan :相關的修改, 我後來發現這兩個要分開才行 04/21 07:51
4F:推 justinj :其實可以以創房間的順當編號..之後就以這個編號來設 04/21 08:25
5F:→ justinj :定...例如instance_data["r000"]["exits"]["east"]= 04/21 08:26
6F:→ justinj :"r001" 04/21 08:26
7F:→ justinj : 順序 04/21 08:27
8F:推 justinj :對了...目前副本寫法想要再多連一條線設定是error 04/21 08:31
嗯?
另外我的意思是,依目前的寫法,會固定做底下的東西
iroom = clone_object(INSTANCE_ROOM);
oroom = find_object_or_load(指向的舊有房間);
那因為目前是採用 instance_paths + instance_files[i]
的做法,如果每個 instance_files[i] 都是 "001.c",就
會變成每個 oroom 都是讀 instance_paths+"001.c"(這部
份 ok),連帶的每個 instance_data 的 key_name 也會是
"001"(這就不行)。
修改的話分兩部份
一、map2data(或不包含) + ({"001","001",...}) <= 要用到 instance_virtual 參數
(不使用基底區域,出口透過 map2data 自動設或 instance_data 手動設)
二、map2data + ({"001","002",...}) <= 要用到 instance_map2data 參數
(使用基底區域但是出口透過 map2data 更動)
※ 編輯: laechan (210.61.157.53), 04/21/2014 09:18:36
9F:→ laechan :然後 instance_virtual 我打算讓 wiz 自設定 04/21 09:31