加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 jeffice0325 于 2019-8-9 11:36 编辑
module PSCL module EVENT @whouse=[] def self.geteventname(evt) evt.instance_variable_get("@event").instance_variable_get("@name") end def self.seteventxyid(evt,x,y,id) evt.instance_variable_get("@event").instance_variable_set("@x",x) evt.instance_variable_get("@event").instance_variable_set("@y",y) evt.instance_variable_set("@id",id) end def self.search_events(amap,sid=0) @whouse[sid] = {} if @whouse[sid] == nil amap.events.each{|k,v| @whouse[sid][geteventname(v)] = v } end def self.put_event(amap,ename,x,y,sid=0) ael = amap.events.length().to_s.to_i + 1 amap.events.merge!({ael => Marshal.load(Marshal.dump(@whouse[sid][ename]))}) seteventxyid(amap.events[ael],x,y,ael) return ael end end end
module PSCL
module EVENT
@whouse=[]
def self.geteventname(evt)
evt.instance_variable_get("@event").instance_variable_get("@name")
end
def self.seteventxyid(evt,x,y,id)
evt.instance_variable_get("@event").instance_variable_set("@x",x)
evt.instance_variable_get("@event").instance_variable_set("@y",y)
evt.instance_variable_set("@id",id)
end
def self.search_events(amap,sid=0)
@whouse[sid] = {} if @whouse[sid] == nil
amap.events.each{|k,v|
@whouse[sid][geteventname(v)] = v
}
end
def self.put_event(amap,ename,x,y,sid=0)
ael = amap.events.length().to_s.to_i + 1
amap.events.merge!({ael => Marshal.load(Marshal.dump(@whouse[sid][ename]))})
seteventxyid(amap.events[ael],x,y,ael)
return ael
end
end
end
如上,我应当是在迭代外插入值的,但为什么总提示不能在迭代内插入值? |