问一句,setTag和getTag到底怎么用
太阳神三国杀lua吧
全部回复
仅看楼主
level 12
RT,游戏开始时的默认getTag值是???????????????????????, @Ailue
2012年11月21日 02点11分 1
level 12
那个一般不用,是当你需要存储一些全局变量的时候使用的。类似于寄存器。
tag寄存器有两种,一种是存在Player上的,另一种是存在room上的(比如智迟)
2012年11月21日 03点11分 2
level 12
默认Tag是什么?我写青龙的魂刃和三台的远虑是使用了Tag。
2012年11月21日 03点11分 3
tag的默认值?应该是 sgs.QVariant()
2012年11月21日 12点11分
toString是不是nll????????????????????????
2012年11月22日 01点11分
level 12
远虑的代码如下:
.
YuanlvCard=sgs.CreateSkillCard{
name = "yuanlv",
target_fixed = false,
filter=function(self,targets,to_select,player)
return #targets == 0 and not to_select:objectName()==player:objectName()
end,
on_effect = function(self, effect)
local room=effect.to:getRoom()
room:loseHp(effect.from)
local player=effect.to
for _, skill in sgs.qlist(player:getVisibleSkillList()) do
room:detachSkillFromPlayer(player, skill:objectName())
end
player:setTag("hided",sgs.QVariant(player:getGeneralName()))
local xxx
if player:getGeneral():isMale() then
xxx="sujiang"
else xxx="sujiangf"
end
room:setPlayerProperty(player, "general", sgs.QVariant(xxx))
if player:getGeneral2() then
player:setTag("hided2",sgs.QVariant(player:getGeneralName()))
room:setPlayerProperty(player, "general2", sgs.QVariant("sujiang"))
end
end
}
yuanlvvs=sgs.CreateViewAsSkill{
name = "yuanlv",
n = 0,
view_as = function(self, cards)
if #cards ~= 0 then return nil end
local VMWcard = YuanlvCard:clone()
VMWcard:setSkillName("yuanlv")
return VMWcard
end,
enabled_at_play=function(self, player)
return not player:hasUsed("#yuanlv")
end,
}
yuanlv = sgs.CreateTriggerSkill
{
name = "yuanlv",
view_as_skill = yuanlvvs,
events = {sgs.PhaseChange},
can_trigger=function()
return true end,
on_trigger = function(self, event, player, data)
local room = player:getRoom()
if player:getPhase() == sgs.Player_Finish and( player:getGeneralName()=="sujiang" or player:getGeneralName()=="sujiangf") and not player:getTag("hided"):toString()==0 then
room:transfigure(selfplayer,player:getTag("hided"):toString(),true,false)
player:setTag("hided"sgs.QVariant(0))
if not player:getTag("hided2"):toString()==0 then
local general2= player:getTag("hided2"):toString()
room:setPlayerProperty(player, "general2", sgs.QVariant(general2))
player:setTag("hided2",sgs.QVariant(0))
end
end
end,
}
@Ailue ,这对吗?
2012年11月21日 04点11分 4
tostring 返回的是字串...不会是int
2012年11月21日 14点11分
level 12
hunren = sgs.CreateTriggerSkill
{
name = "hunren",
frequency = sgs.Skill_Compulsory,
events = {sgs.GameStart,sgs.CardLost,sgs.FinishJudge,sgs.CardGot},
on_trigger = function(self, event, player, data)
local room = player:getRoom()
if event==sgs.GameStart then
player:setTag("HunrenSkill",sgs.QVariant("tiandu")
--elseif event == sgs.CardUsed then
elseif event==sgs.FinishJudge then
if player:getWeapon() then return false end
local judge = data:toJudge()
local card = judge.card
data_card = sgs.QVariant(0)
data_card:setValue(card)
if(room:askForSkillInvoke(player,"tiandu", data_card)) then
player:obtainCard(judge.card)
room:playSkillEffect("tiandu")
return true
end
return false
elseif event==sgs.CardLost or event==sgs.CardGot then
local move = data:toCardMove()
local y=sgs.Sanguosha:getCard(move.card_id)
if (move.from_place == sgs.Player_Equip) and y:inherits("Weapon") then
room:detachSkillFromPlayer(player:getTag("HunrenSkill"):toString()
player:setTag("HunrenSkill","tiandu")
elseif move.to=player and move.to_place==sgs.Player_Equip and y:inherits("Weapon") then
local x=sgs.Sanguosha:getCard(move.card_id)
local skill
if x:inherits("Crossbow") then
skill="jizhi"
elseif x:inherits("DoubleSword") then
skill="rende"
elseif x:inherits("QinggangSword") then
skill="juejing"
elseif x:inherits("GudingBlade") then
skill="yinghun"
elseif x:inherits("IceSword") then
skill="tianxiang"
elseif x:inherits("Blade") then
skill="wusheng"
elseif x:inherits("Axe") then
skill="duanliang"
elseif x:inherits("Spear") then
skill="paoxiao"
elseif x:inherits("Fan") then
skill="bazhen"
elseif x:inherits("Halberd") then
skill="wushuang"
elseif x:inherits("KylinBow") then
skill="liegong"
elseif x:inherits("MoonSpear") then
skill="longdan"
elseif x:inherits("YitianSword") then
skill="jianxiong"
elseif x:inherits("YxSword") then
skill="fangzhu"
elseif x:inherits("SpMoonspear") then
skill="qingguo"
else skill="jixi"
end
if player:hasSkill(skill) then return end
player:setTag("HunrenSkill",sgs.QVariant(skill)
room:acquireSkill(player,skill)
end
end
end
end,
}
cuihuo = sgs.CreateTriggerSkill
{
name = "cuihuo",
events = {sgs.CardLost},
on_trigger=function(self,event,player,data)
local room = player:getRoom()
if event == sgs.CardLost then
local move = data:toCardMove()
local y=sgs.Sanguosha:getCard(move.card_id)
if (move.from_place == sgs.Player_Equip) and y:inherits("Weapon") then
local recov = sgs.RecoverStruct()
recov.card = nil
recov.who = player
room:recover(player, recov)
if player:getPhase() == sgs.Player_NotActive then return false end
room:setPlayerFlag(player,"chused")
end
end
end,
can_trigger=function(self,player)
return player:hasSkill(self:objectName()) and player:isAlive() and not player:hasFlag("chused")
end,
}
魂刃和淬火, @Ailue ,你怎么看?
2012年11月21日 04点11分 5
其实你可以用一个table。。代码会短很对。。以后维护也更好一点。。
2012年11月22日 09点11分
回复 380463464 :很多。。。
2012年11月22日 09点11分
1