烂泥兽吧 关注:6贴子:189
  • 4回复贴,共1

一个无用的struct函数,及其调用

只看楼主收藏回复

struct enc
public real a=1.0
public real c=3.0
public method reset takes nothing returns nothing
set this.a=GetRandomReal(.0,45.0)
set this.c=6.0
endmethod
endstruct
function test takes nothing returns nothing
local enc e=enc.create()
call e.reset()
call BJDebugMsg(R2S(e.a))
call BJDebugMsg(R2S(e.c))
call e.destroy()
endfunction
function InitTrig_aa takes nothing returns nothing
local trigger b=CreateTrigger()
call TriggerRegisterPlayerChatEvent(b,GetLocalPlayer(),"2",true)
call TriggerAddAction(b,function test)
endfunction


IP属地:山西1楼2016-02-16 20:54回复
    这个struct函数的调用坑了我N个小时,无论怎么测试显示的e.a和e.c的值都是其初始值,最后经大神点拨,才明白原来是少了call e.reset()。


    IP属地:山西2楼2016-02-16 20:56
    回复
      不懂


      IP属地:湖北来自Android客户端3楼2016-02-17 12:19
      收起回复
        2333


        IP属地:湖北来自Android客户端4楼2016-02-17 12:19
        回复