stalker脚本LUA错误,试图索引本地“outfit_now”的值为“nil”

脚本:

   function update()

     local outfit_now = db.actor:get_current_outfit()

         if
                outfit_now:section() == "military"

        or outfit_now:section() == "outfit_solder_m1"
        or outfit_now:section() == "militaryspec_outfit"
        or outfit_now:section() == "specops_outfit"
    then
        set_actor_community("military")
    elseif
        outfit_now:section() == "bandit_outfit"

        or outfit_now:section() == "bandit_master_outfit"
                or outfit_now:section() == "bandit_veteran_outfit"
    then
        set_actor_community("bandit")
elseif
                outfit_now:section() == "dolg_outfit"

        or outfit_now:section() == "dolg_black_exoskeleton"
                or outfit_now:section() == "outfit_dolg_m1"
                or outfit_now:section() == "dolg_heavy_outfit"
                or outfit_now:section() == "dolg_scientific_outfit"
              then
        set_actor_community("dolg")
elseif
                outfit_now:section() == "killer_outfit"

        or outfit_now:section() == "killer_blue_exoskeleton"
                or outfit_now:section() == "killer_green_exoskeleton"
                or outfit_now:section() == "outfit_killer_m1"
              then
        set_actor_community("killer")
elseif changed then
        set_actor_community("actor")
elseif
                outfit_now:section() == "svoboda_light_outfit"

        or outfit_now:section() == "svoboda_heavy_outfit"
                or outfit_now:section() == "outfit_svoboda_m1"
                or outfit_now:section() == "svoboda_exoskeleton"
              then
        set_actor_community("svoboda")
elseif

outfit_now:section() == "nebo_light_outfit"

        or outfit_now:section() == "nebo_heavy_outfit"
                or outfit_now:section() == "nebo_scientific_outfit"
                or outfit_now:section() == "nebo_exo_outfit"
              then
        set_actor_community("nebo")
elseif
                outfit_now:section() == "lastday_outfit"

        or outfit_now:section() == "scientific_lastday_outfit"
                or outfit_now:section() == "exo_lastday_outfit"
                or outfit_now:section() == "nebo_exo_outfit"
              then
        set_actor_community("lastday")
elseif
                outfit_now:section() == "outfit_base"
              then
        set_actor_community("actor")

   end
end
function set_actor_community(actor)
    db.actor:set_character_community(actor)
end

原文链接 https://stackoverflow.com/questions/70817144

点赞
stackoverflow用户2858170
stackoverflow用户2858170

你试图索引一个本地的nil值 "outfit_now"。

local outfit_now = db.actor:get_current_outfit()

db.actor:get_current_outfit() 返回值为nil。找出原因并修复它。 如果不能修复,不要索引outfit_now,如 outfit_now:section(),如果它是nil。

2022-01-22 23:04:24