标题: [已解决]f中对class变量的存取问题
sjmind
会员
Rank: 1



UID 1025
精华 0
积分 106
帖子 30
阅读权限 5
注册 2008-6-4
 
发表于 2008-7-18 00:26  资料  短消息  加为好友  添加 sjmind 为MSN好友 通过MSN和 sjmind 交谈
[已解决]f中对class变量的存取问题

里面的ItemL是一个自定义的class类型
load之后说“访问了null对象”
应该就是没有把f.IL读进来
IL的数据主体是一个数组,几个整型
能不能做到不管在那里save,总能正确的load

first.ks:

@call storage="initsys.ks"

*start
;@advl
欢迎来到Kirikiri/KAG的世界![l][r]
这次是对物品道具或任务列表等的ItemList进行测试.[l][r]
初始的测试数据为{0,0,1,1,2} [l][r]
[iscript]
f.IL=new ItemArray();
f.IL.Add(0);
f.IL.Add(0);
f.IL.Add(1);
f.IL.Add(1);
f.IL.Add(2);
//f.IL=global.ItemL;
[endscript]
变量初始完成[l][r]
ItemL中存在#1共
@emb exp="f.IL.GetItemCount(1);"
@emb exp="f.IL"

[r]
@outputItemL
[p]
*uc0
@save ask="true" place="1"
*uc1
存档点后增加#1*1[l][r]
[iscript]
f.IL.Add(1);
[endscript]
@outputItemL
[l][r]
@load ask="true" place="1"
@s


然后是存档data1.kdt的相关部分:


"user" => %[
  "IL" => null /* (object) "(object 0x01616B74:0x01616B74)" */
],

就是这里永远是null.

[ 本帖最后由 sjmind 于 2008-7-18 11:20 编辑 ]

顶部
sjmind
会员
Rank: 1



UID 1025
精华 0
积分 106
帖子 30
阅读权限 5
注册 2008-6-4
 
发表于 2008-7-18 11:19  资料  短消息  加为好友  添加 sjmind 为MSN好友 通过MSN和 sjmind 交谈
KAG中的save的确是将f中class对象进行了保存
但class的变量的实质是一个指针
而f的实质是个dictionary,其对class的变量的存储实际上是保存了一个指针
所以load之后原指针指向的地方一定为null
解决方案就是不要在f中使用class的变量

顶部
全局变量D
亲友
Rank: 2



UID 14
精华 1
积分 1262
帖子 719
阅读权限 50
注册 2006-12-20
 
发表于 2008-7-18 17:25  资料  短消息  加为好友 
嗯,这个问题也困扰了我很多年...用字典就好了...





顶部
 



清除 Cookies - 联系我们 - [Key Fans Club] the Council of Doujin-game Development and Promotion - Archiver - WAP
Powered by Discuz! 5.5.0 © 2001-2006 Comsenz Inc.
Processed in 0.021215 second(s), 9 queries , Gzip enabled
粤ICP备05060595号
[ 当前模板 - 天高云淡 v 设计制作 - 七星论坛 v 请使用1024*768或以上分辨率浏览本模板 ]
请勿删除或修改此处版权图示