作者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/cn.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