找回密码
 点一下
查看: 2246|回复: 21

我的这个J错误在哪了?

[复制链接]
发表于 2008-8-11 23:18:52 | 显示全部楼层 |阅读模式
[codes=jass]function H2I takes handle h returns integer
return h
return 0
endfunction

function I2U takes integer i returns unit
return i
return null
endfunction

function I2TD takes integer i returns timerdialog
return i
return null
endfunction

function GameCache takes nothing returns gamecache
if udg_GC == null then
call FlushGameCache(InitGameCache("map.w3v"))
set udg_GC = InitGameCache("map.w3v")
endif
return udg_GC
endfunction

function tiaojian takes nothing returns nothing
if (not(IsUnitType(GetTriggerUnit(),UNIT_TYPE_HERO) == true )) then
return false
endif
return true
endfunction

function jishiqi takes nothing returns nothing
local unit u =I2U(GetStoredInteger(GC(),I2S(H2I(GetExpiredTimer())),"TriggerUnit"))
local timerdialog td = I2TD(GetStoredInteger(GC),I2S(H2I(GetExpiredTimer())),"TimerDialog"))
call ReviveHeroLoc(u,GetRectCenter(GetPlayableMapRect()), false )
call DestroyTimerDialog(td)
call FlushStoredMission(GC(), I2S(H2I(GetExpiredTimer())))
set u = null
set td = null
endfunction

function fh takes nothing returns nothing
local unit u = GetTriggerUnit()
local timer t = CreateTimer()
local timerdialog td = CreateTimerDialog(t)
call TimerDialogSetTitle(td, GetPlayerName(GetOwningPlayer(GetTriggerUnit())) + "复活时间:" )
call StoreInteger(GC(),I2S(H2I(t)),"TriggerUnit",H2I(GetTriggerUnit()))
call StoreInteger(GC(),I2S(H2I(t)),"TimerDialog",H2I(td))
call TimerStart(t,180,false,function jishiqi)
call TimerDialogDisplay(td,display)
set u = null
set t = null
set td = null
endfunction

//===========================================================================
function InitTrig_rh takes nothing returns nothing
local trigger tri = Createtrigger()
call TriggerRegisterAnyUnitEventBJ(tri,EVENT_PLAYER_UNIT_DEATH)
call TriggerAddCondition(Condition(tri,function tiaojian))
call TriggerAddAction(tri,function fh)
set tri = null
endfunction[/codes]


//①我不懂,希望指出我的错误,更希望能说明.
//②我把return bug 那段东西放进 '自定义代码'    里,这样就不用每个触发都打上return bug ,不知这样对不对.
发表于 2008-8-11 23:25:39 | 显示全部楼层
[jass]function jishiqi takes nothing returns nothing
local unit u =I2U(GetStoredInteger(GC(),I2S(H2I(GetExpiredTimer())),"TriggerUnit"))
local timerdialog td = I2TD(GetStoredInteger(GC),I2S(H2I(GetExpiredTimer())),"TimerDialog"))
call ReviveHeroLoc(u,GetRectCenter(GetPlayableMapRect()), false )
call DestroyTimerDialog(td)
call FlushStoredMission(GC(), I2S(H2I(GetExpiredTimer())))
set u = null
set td = null
endfunction[/jass]

这里的话 得到到期计时器 写一个变量...你每次都调用函数 效率很低
还有CG后面干嘛要()
又不是函数 是变量

[jass]call TimerDialogDisplay(td,display)[/jass]
display没有看到
回复

使用道具 举报

发表于 2008-8-11 23:26:44 | 显示全部楼层
初始化并返回游戏缓存的函数,声明时是GameCache,调用时便成了GC了
回复

使用道具 举报

发表于 2008-8-11 23:30:46 | 显示全部楼层
话说需要调用那个函数来获取缓存么
本来就是全局的
这样效率很低啊
回复

使用道具 举报

发表于 2008-8-11 23:32:01 | 显示全部楼层
习惯而已,话说缓存的调用我也是这么来的
回复

使用道具 举报

 楼主| 发表于 2008-8-11 23:33:57 | 显示全部楼层
实在不理解,这是我第2次编写.先前有事做没空去写,你们上面说的,能不能指出哪断写得有问题啊.
回复

使用道具 举报

 楼主| 发表于 2008-8-11 23:44:54 | 显示全部楼层
引用第1楼冰块于2008-08-11 23:25发表的  :
[jass]function jishiqi takes nothing returns nothing
local unit u =I2U(GetStoredInteger(GC(),I2S(H2I(GetExpiredTimer())),"TriggerUnit"))
local timerdialog td = I2TD(GetStoredInteger(GC),I2S(H2I(GetExpiredTimer())),"TimerDialog"))
call ReviveHeroLoc(u,GetRectCenter(GetPlayableMapRect()), false )
call DestroyTimerDialog(td)
.......




call TimerDialogDisplay(td, display)没有看到??什么意思?
回复

使用道具 举报

发表于 2008-8-12 00:08:55 | 显示全部楼层
先看看这个
[codes=jass]function GameCache takes nothing returns gamecache
if udg_GC == null then
call FlushGameCache(InitGameCache("map.w3v"))
set udg_GC = InitGameCache("map.w3v")
endif
return udg_GC
endfunction[/codes]
然后看看这些
[codes=jass]local unit u =I2U(GetStoredInteger(GC(),I2S(H2I(GetExpiredTimer())),"TriggerUnit"))
local timerdialog td = I2TD(GetStoredInteger(GC),I2S(H2I(GetExpiredTimer())),"TimerDialog"))
call FlushStoredMission(GC(), I2S(H2I(GetExpiredTimer())))

call StoreInteger(GC(),I2S(H2I(t)),"TriggerUnit",H2I(GetTriggerUnit()))
call StoreInteger(GC(),I2S(H2I(t)),"TimerDialog",H2I(td))[/codes]
明白了吗?函数名错掉了

你上面说的那句把display改成true吧
回复

使用道具 举报

 楼主| 发表于 2008-8-12 00:14:07 | 显示全部楼层
猪头大人是说把↓
call StoreInteger(GC(),I2S(H2I(t)),"TimerDialog",H2I(td))这句里面的GC改为↓
call StoreInteger(GameChe(),I2S(H2I(t)),"TimerDialog",H2I(td))吗?


把call TimerDialogDisplay(td,display)这句里面的display改为真?
回复

使用道具 举报

发表于 2008-8-12 00:15:53 | 显示全部楼层
是的,不排除有其他问题哦
回复

使用道具 举报

 楼主| 发表于 2008-8-12 00:23:10 | 显示全部楼层
可是我保存地图时,WE说  '缺少endif '  .我自己又不清楚错哪了.


function jishiqi takes nothing returns nothing
从这里开始就有问题了.
回复

使用道具 举报

发表于 2008-8-12 00:30:08 | 显示全部楼层
说缺少endif的一半都不是缺少endif额………………

仔细检查了下,错误如下
1、GameCache函数名错误,前面已指出,有一处还少了左括号
2、TimerDialogDisplay参数问题,前面也已经指出了
3、CreateTrigger,T没有打写
4、tiaojian函数返回值错误,应该是布尔类型boolean
5、添加条件的写法错误,call TriggerAddCondition(trg, Condition(function Cond))(具体变量名自己代入)
回复

使用道具 举报

发表于 2008-8-12 00:31:08 | 显示全部楼层
下个jassshop,语法错误自己解决就行了



另GameCache 这个函数非常不好,懒人的写法
回复

使用道具 举报

发表于 2008-8-12 00:33:05 | 显示全部楼层
貌似记得以前everguo大人说不建议在地图初始化时初始化,推荐这么写………………
回复

使用道具 举报

发表于 2008-8-12 00:38:41 | 显示全部楼层
不知道这个说法是基于什么理由?

封装udg_GC
可以把GameCache操作的函数都封装起来,顺便也可以把returnbug函数省了

防止未初始化就使用
这个只能靠自己注意,不可能因为这个原因把每个变量都改函数吧?
回复

使用道具 举报

 楼主| 发表于 2008-8-12 00:50:41 | 显示全部楼层
//①关于语法,我用JassCraft这个工具能不能呢?
//②call TimerStart(t,888,false,function XXXX)这里的false为什么写(假)又不写true(真)?
//③GameCache这样写效率很低?干嘛我在别人的演示里发现这类东西的有很多.
回复

使用道具 举报

发表于 2008-8-12 00:52:30 | 显示全部楼层
1、jasscraft可以检测语法
2、此参数表示是否循环,false表示一次性计时器,到期即停止,true则是循环计时器
3、此处貌似出现意见分歧,暂时不必在意
回复

使用道具 举报

 楼主| 发表于 2008-8-12 02:13:38 | 显示全部楼层
4、tiaojian函数返回值错误,应该是布尔类型

就剩下这里了,什么意思喽?boolean,我该怎么做呢?我用JassCraft工具查看,就发现向缓存里存东西的句子有问题,但我又不会改,不知是不是这些错误了.


call StoreInteger(GameCache(),I2S(H2I(t)),"TriggerUnit",H2I(GetTriggerUnit()))

local unit u =I2U(GetStoredInteger(GameCache(),I2S(H2I(GetExpiredTimer())),"TriggerUnit"))

call FlushStoredMission(GameCache(), I2S(H2I(GetExpiredTimer())))

local timerdialog td = I2TD(GetStoredInteger(GameCache(),I2S("TimerDialog"),H2I(td)))

call StoreInteger(GameCache(),I2S(H2I(t)),"TimerDialog",H2I(td))
回复

使用道具 举报

发表于 2008-8-12 02:14:39 | 显示全部楼层
function tiaojian takes nothing returns boolean
回复

使用道具 举报

 楼主| 发表于 2008-8-12 02:33:22 | 显示全部楼层
貌似不行的,WE说,返回1个无用的值.

不知是不是这些错误了.


call StoreInteger(GameCache(),I2S(H2I(t)),"TriggerUnit",H2I(GetTriggerUnit()))

local unit u =I2U(GetStoredInteger(GameCache(),I2S(H2I(GetExpiredTimer())),"TriggerUnit"))

call FlushStoredMission(GameCache(), I2S(H2I(GetExpiredTimer())))

local timerdialog td = I2TD(GetStoredInteger(GameCache(),I2S("TimerDialog"),H2I(td)))

call StoreInteger(GameCache(),I2S(H2I(t)),"TimerDialog",H2I(td))
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-7-21 04:21 , Processed in 0.054121 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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