找回密码
 点一下
查看: 2401|回复: 16

菜菜的问题关于 (局部变量)

[复制链接]
发表于 2008-1-19 11:28:41 | 显示全部楼层 |阅读模式
先用触发做了一个技能,然后把所有udg_全删了, 并在Actions 里申明了对应的局部变量,就出错了。
应该有多种可能,请问这是什么原因?(是不是因为,循环太多?If then else 太多?数组太多?)
发表于 2008-1-19 11:31:38 | 显示全部楼层
能把code发上来吗?这样说不时很明白,不过后面列的问题应该是不存在的
还有,局部变量要在函数顶部申明的哦~~
回复

使用道具 举报

 楼主| 发表于 2008-1-19 12:26:36 | 显示全部楼层
好的等等~`我好像知道哪里错了。。
物品类型数组 是不是这样申? local itemtype array xxxx
单位类型数组 是不是这样申? local unittype array xxxxx
回复

使用道具 举报

发表于 2008-1-19 12:27:45 | 显示全部楼层
应该都是………………
local integer array
物品类型和单位类型变量其实都是整数变量
回复

使用道具 举报

 楼主| 发表于 2008-1-19 12:38:59 | 显示全部楼层
啊。。原来是这样啊。。。
有没关于这种归类于REAL 还是integer等等的文章?
回复

使用道具 举报

发表于 2008-1-19 12:42:08 | 显示全部楼层
um...不是很清楚………………
lz可以去下JassShopPro或者JassCraft,里面可以查看函数调用参数的类型和返回值的类型的
回复

使用道具 举报

 楼主| 发表于 2008-1-19 13:02:05 | 显示全部楼层
OK,我还是没成功。。
帮我看看code 吧。。这是没改过的
[codes=jass]function Trig_test_3_Func002Func001Func001C takes nothing returns boolean
    if ( not ( UnitItemInSlotBJ(udg_sfUnit, udg_x3[2]) == null ) ) then
        return false
    endif
    return true
endfunction[/codes]

[codes=jass]function Trig_test_3_Func002C takes nothing returns boolean
    if ( not ( udg_x3[1] >= 5 ) ) then
        return false
    endif
    return true
endfunction[/codes]

[codes=jass]function Trig_test_3_Actions takes nothing returns nothing
    set udg_sfUnit = GetSpellAbilityUnit()
    if ( Trig_test_3_Func002C() ) then
        set udg_x3[2] = 1
        loop
            exitwhen udg_x3[2] > 6
            if ( Trig_test_3_Func002Func001Func001C() ) then
                call UnitAddItemByIdSwapped( 'modt', udg_sfUnit )
            else
            endif
            set udg_x3[2] = udg_x3[2] + 1
        endloop
        set udg_x3[1] = 0
    else
    endif
    set udg_x3[1] = ( udg_x3[1] + 1 )
endfunction[/codes]

//===========================================================================
[codes=jass]function InitTrig_test_3 takes nothing returns nothing
    set gg_trg_test_3 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_test_3, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddAction( gg_trg_test_3, function Trig_test_3_Actions )
endfunction[/codes]
回复

使用道具 举报

发表于 2008-1-19 13:03:54 | 显示全部楼层
//这个是没改过之前的吗??
不好意思看到了………………
回复

使用道具 举报

 楼主| 发表于 2008-1-19 13:05:17 | 显示全部楼层
这是去掉udg的..会出错的。。也是这个
[codes=jass]function Trig_test_2_Func002Func001Func001C takes nothing returns boolean
    if ( not ( UnitItemInSlotBJ(sfUnit, x3[2]) == null ) ) then
        return false
    endif
    return true
endfunction[/codes]

[codes=jass]function Trig_test_2_Func002C takes nothing returns boolean
    if ( not ( x3[1] >= 5 ) ) then
        return false
    endif
    return true
endfunction[/codes]

[codes=jass]function Trig_test_2_Actions takes nothing returns nothing
    local unit sfUnit = GetSpellAbilityUnit()
    local integer array x3
    if ( Trig_test_2_Func002C() ) then
        set x3[2] = 1
        loop
            exitwhen x3[2] > 6
            if ( Trig_test_2_Func002Func001Func001C() ) then
                call UnitAddItemByIdSwapped( 'modt', sfUnit )
            else
            endif
            set x3[2] = x3[2] + 1
        endloop
        set x3[1] = 0
    else
    endif
    set x3[1] = ( x3[1] + 1 )
endfunction[/codes]

//===========================================================================
[codes=jass]function InitTrig_test_2 takes nothing returns nothing
    set gg_trg_test_2 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_test_2, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddAction( gg_trg_test_2, function Trig_test_2_Actions )
endfunction[/codes]
回复

使用道具 举报

发表于 2008-1-19 13:16:38 | 显示全部楼层
这样可能会出问题的,我觉得………………
udg_x3[1]这个是做全局控制的吧,如果这样改,每次出现的x3[1]都是0,而且上面这些方法中的x3和sfUnit都没有传递啊
回复

使用道具 举报

发表于 2008-1-19 13:21:07 | 显示全部楼层
是我的话,我会把全局变量udg_x3改成非数组,存储原先udg_x3[1]的内容,顺便把bj函数砍了,做了下排泄………………
[codes=jass]function Trig_test_3_Actions takes nothing returns nothing
    local integer x3
    local unit sfUnit = GetSpellAbilityUnit()
    if udg_x3 >= 5 then
        set x3 = 0
        loop
            exitwhen x3 > 5
            if UnitItemInSlot(sfUnit, x3) == null then
                call UnitAddItemById(sfUnit, 'modt')
            endif
            set x3 = x3 + 1
        endloop
        set udg_x3 = 0
    endif
    set udg_x3 = udg_x3 + 1
    set sfUnit = null
endfunction[/codes]
回复

使用道具 举报

 楼主| 发表于 2008-1-19 13:23:58 | 显示全部楼层
我是拿触发直接改的,因为能力实在有限。。。再问个弱智的问题。。x3  sfUnit 怎么传递?用StoreInteger?
回复

使用道具 举报

发表于 2008-1-19 13:27:31 | 显示全部楼层
不用啊,直接在函数的takes里改额………………
一开始都是拿触发直接改的,后来看的多改的多了就熟悉了
你把全局变量x3改成不是数组,然后把
Trig_test_2_Func002Func001Func001C和Trig_test_2_Func002C删掉,把Trig_test_3_Actions改成10楼那样试试看,我不知道有没有写错………………
不要忘记备份下,因为我老是会犯低级错误的,说不定we就崩掉了………………
回复

使用道具 举报

 楼主| 发表于 2008-1-19 13:30:55 | 显示全部楼层
好的我试试
回复

使用道具 举报

 楼主| 发表于 2008-1-19 13:59:49 | 显示全部楼层
O yeah!!!!成功了!!!
太谢谢你了!无法用"语言"表达!!
[codes=jass]function Thanks _For_zhuzeitou  takes nothing returns nothing
      local integer x
              set x = 0
            loop
                  exitwhen x3> Die//把Die 转成整数怎么写来着?S2I?
    call DisplayTextToPlayer( GetLocalPlayer(), 0, 0, "Thanks" )
                   endloop
endfunction[/codes]
回复

使用道具 举报

发表于 2008-1-19 14:04:26 | 显示全部楼层
引用cupidtns的签名  :
极度感谢“zhuzeitou ”前辈

呵呵,不用谢的呀~~互帮互助嘛~~
另外………………至少………………可不可以把"前辈"去掉呢………………
回复

使用道具 举报

 楼主| 发表于 2008-1-19 14:10:26 | 显示全部楼层
引用第15楼zhuzeitou于2008-01-19 14:04发表的  :


呵呵,不用谢的呀~~互帮互助嘛~~
另外………………至少………………可不可以把"前辈"去掉呢………………
好吧。。下次加上去。。。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-5-22 15:17 , Processed in 0.039305 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表