找回密码
 点一下
查看: 1874|回复: 6

问一个郁闷点的问题....[半解决]

[复制链接]
发表于 2006-4-23 11:39:45 | 显示全部楼层 |阅读模式
我用localvars写一个技能, 需要在缓存中储存一个玩家类型的变量(player)
可是原先的函数里没有关于玩家变量的函数, 于是自己仿造着加了一条...可是程序执行到这就跳出了.所以想问一下各位大大...


1.player 变量是什么类型派生的, 是handle吗?
2.有没有什么解决的办法5555或者通过其他形式,比如转换==

我用sethandlehandle储存值
gethandleplayer取值


附修改过的localvars源码:

// =======================Local Vars By KaTTaNa
function H2I takes handle h returns integer
    return h
    return 0
endfunction

// ===========================
function LocalVars takes nothing returns gamecache
    if udg_handlevars == null then
        call FlushGameCache(InitGameCache("jasslocalvars.w3v"))
        set udg_handlevars = InitGameCache("jasslocalvars.w3v")
    endif
    return udg_handlevars
endfunction

function SetHandleHandle takes handle subject, string name, handle value returns nothing
    if value==null then
        call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name)
    else
        call StoreInteger(LocalVars(), I2S(H2I(subject)), name, H2I(value))
    endif
endfunction

function SetHandleInt takes handle subject, string name, integer value returns nothing
    if value==0 then
        call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name)
    else
        call StoreInteger(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

function SetHandleBoolean takes handle subject, string name, boolean value returns nothing
    if value==false then
        call FlushStoredBoolean(LocalVars(),I2S(H2I(subject)),name)
    else
        call StoreBoolean(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

function SetHandleReal takes handle subject, string name, real value returns nothing
    if value==0 then
        call FlushStoredReal(LocalVars(), I2S(H2I(subject)), name)
    else
        call StoreReal(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

function SetHandleString takes handle subject, string name, string value returns nothing
    if value==null then
        call FlushStoredString(LocalVars(), I2S(H2I(subject)), name)
    else
        call StoreString(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

function GetHandleHandle takes handle subject, string name returns handle
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleInt takes handle subject, string name returns integer
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleBoolean takes handle subject, string name returns boolean
    return GetStoredBoolean(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleReal takes handle subject, string name returns real
    return GetStoredReal(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleString takes handle subject, string name returns string
    return GetStoredString(LocalVars(), I2S(H2I(subject)), name)
endfunction

function GetHandleUnit takes handle subject, string name returns unit
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleTimer takes handle subject, string name returns timer
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleTrigger takes handle subject, string name returns trigger
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleEffect takes handle subject, string name returns effect
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleGroup takes handle subject, string name returns group
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleLightning takes handle subject, string name returns lightning
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleWidget takes handle subject, string name returns widget
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandlePlayer takes handle subject, string name returns player
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction


function FlushHandleLocals takes handle subject returns nothing
    call FlushStoredMission(LocalVars(), I2S(H2I(subject)) )
endfunction

[ 本帖最后由 helanmouse 于 2006-4-23 12:23 编辑 ]
发表于 2006-4-23 12:00:04 | 显示全部楼层
不懂~~~不知所云,看我1年后能不能懂50%
回复

使用道具 举报

 楼主| 发表于 2006-4-23 12:22:56 | 显示全部楼层
....郁闷了...忽然在jass手册中发现了GetPlayerID这个函数...这就是说配合Player函数就可以把player变量转化成integer储存...不过还是希望问一下直接储存不可以吗?
回复

使用道具 举报

发表于 2006-4-23 12:26:13 | 显示全部楼层
玩家类型
是个什么东西???
如果你只是想保存玩家的话.
用integer就可以了.
调用的时候.就是Player(0),Player(1),.....,Player(15)
魔兽一共有16个玩家.后面四个是特殊的.嗯嗯.
你没看到T里.有一个.把什么玩家索引转换为玩家么..

补充.小写的player是变量类型.
大写的P
Player(0)是玩家1.


[ 本帖最后由 amp34 于 2006-4-23 12:53 编辑 ]
回复

使用道具 举报

发表于 2006-4-23 12:41:52 | 显示全部楼层
player没有研究过
但playercolor是integer

总共才16个玩家
直接用integer不行吗
回复

使用道具 举报

发表于 2006-4-23 12:43:12 | 显示全部楼层
原帖由 helanmouse 于 2006-4-23 12:22 发表
....郁闷了...忽然在jass手册中发现了GetPlayerID这个函数...这就是说配合Player函数就可以把player变量转化成integer储存...不过还是希望问一下直接储存不可以吗?


最好不要利用“return bug”直接存储对象,会存在许多问题的

能转成integer的尽量转
回复

使用道具 举报

发表于 2006-5-18 14:07:46 | 显示全部楼层
继续学习中,后来跟来。。。
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-21 23:01 , Processed in 0.035228 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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