搜索
查看: 276|回复: 2

[求助] LUA的一个范围问题

[复制链接]
发表于 2023-4-10 22:07:42 | 显示全部楼层 |阅读模式
function on_DoSpellSkill(Actor, TagActor, MagicID)


        local Actorname = Actor:getCharName()       
        local TagActorName = TagActor:getCharName()       
        local RaceId = TagActor:getRace()--种族ID
        local RaceId1 = Actor:getRace()


if RaceId1 == 0 then (1000%通过)
  local trjl1 = TagActor:getCustom9()  --左手
END

if trjl1 == "xx" then
end
end

trjl1 我在if RaceId1 == 0 then 申明过一次,且条件都通过

有时候我需要在if trjl1 == "xx" then  的上方在申明一次,造成这种原因在哪里!




发表于 2023-4-11 00:19:02 | 显示全部楼层
局部变量只能作用在if end之间,lua基础语法要学习下
发表于 2023-4-11 00:21:01 | 显示全部楼层
local trjl1 = ""
if RaceId1 == 0 then --(1000%通过)
  trjl1 = TagActor:getCustom9()  --左手
end

if trjl1 == "xx" then
end

这样下面的也可以用了。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|HGEM2论坛

GMT+8, 2024-9-23 11:28 , Processed in 0.472629 second(s), 13 queries .

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

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