Page 1 of 1

[Script] sr.light - Excluding certain ranks from disabling flashlights.

Posted: 03 Dec 2016, 09:14
by Diegtiarov
Hey.

I want "Novice" and "Trainee" stalkers not to disable their flashlight during the fight at night/in underground levels.

Wrote this, but without any result.

Code: Select all

   -- Stalker in danger mode; release torch
   if (st.danger_flag) then
       local rank = ranks.get_obj_rank_name(npc)
      if rank ~= nil then
          if rank ~= ("novice" or "trainee") then
            if (torch) then
               if (torch:attachable_item_enabled()) then
                  torch:enable_attachable_item(false)
               end
               local sim = alife()
               sim:release(sim:object(torch:id()),true)
            end
            return
         end
      end
   end


Code: Select all

   -- Stalker has enemy and is not underground; release torch
   if (stalker:best_enemy() and not indoor_levels[level.name()]) then
       local rank = ranks.get_obj_rank_name(npc)
      if rank ~= nil then
          if rank ~= ("novice" or "trainee") then
            if (torch) then
               if (torch:attachable_item_enabled()) then
                  torch:enable_attachable_item(false)
               end
               local sim = alife()
               sim:release(sim:object(torch:id()),true)
            end
            return
         end
      end
   end


0 lua skills, please help. :suicide:

Re: [Script] sr.light - Excluding certain ranks from disabling flashlights.

Posted: 03 Dec 2016, 21:58
by Alundaio
well there is no 'npc' variable. Use the 'stalker' variable in that function's scope.

ranks.get_obj_rank_name(stalker)

Re: [Script] sr.light - Excluding certain ranks from disabling flashlights.

Posted: 04 Dec 2016, 05:57
by Diegtiarov
It turns out result received from get_obj_rank_name(stalker) function is a string but isn't any of:

Code: Select all

novice
trainee
experienced
professional
veteran
expert
master
legend

I've checked that by putting

Code: Select all

if rank ~= ("novice" or "trainee" or "experienced" or "professional" or "veteran" or "expert" or "master" or "legend") then


Any ideas how to check what is the output or eventually a table of what received strings can be?

Re: [Script] sr.light - Excluding certain ranks from disabling flashlights.

Posted: 04 Dec 2016, 06:09
by Alundaio
It's read directly from game_relations.ltx:

Code: Select all

stalker_max_rank_name = parse_ranks( ltx:r_string_ex( "game_relations", "rating" ),         stalker_rank_intervals )


If you enable debug hud you can see character rank in the stalker_info display. The debug hud uses ranks.get_obj_rank_name()


use a printf statement to log stuff

Code: Select all

printf("rank=%s",rank)

Re: [Script] sr.light - Excluding certain ranks from disabling flashlights.

Posted: 11 Dec 2016, 10:07
by Diegtiarov
So, finally checked that today...

... the breaking thing was a space put there, after "~=". :lol:

Re: [Script] sr.light - Excluding certain ranks from disabling flashlights.

Posted: 11 Dec 2016, 16:09
by Alundaio
You should re-merge your mod's scripts. They are still outdated, specifically xr_motivator.script

Re: [Script] sr.light - Excluding certain ranks from disabling flashlights.

Posted: 13 Dec 2016, 14:35
by Diegtiarov
Done. Will be included in next addon update.

Re: [Script] sr.light - Excluding certain ranks from disabling flashlights.

Posted: 13 Dec 2016, 17:22
by Alundaio
Cool thanks :gizmo: