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

User avatar
Diegtiarov
Trespasser
Posts: 52
Joined: 12 Nov 2015, 08:34
Contact:

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

Postby Diegtiarov » 03 Dec 2016, 09:14

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:

User avatar
Alundaio
S.T.A.L.K.E.R.
Posts: 1368
Joined: 26 May 2012, 22:26

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

Postby Alundaio » 03 Dec 2016, 21:58

well there is no 'npc' variable. Use the 'stalker' variable in that function's scope.

ranks.get_obj_rank_name(stalker)
"I have a dream that one day this community will rise up and live out the true meaning of its creed: "We hold these truths to be self-evident; that all mods are created equal."

User avatar
Diegtiarov
Trespasser
Posts: 52
Joined: 12 Nov 2015, 08:34
Contact:

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

Postby Diegtiarov » 04 Dec 2016, 05:57

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?

User avatar
Alundaio
S.T.A.L.K.E.R.
Posts: 1368
Joined: 26 May 2012, 22:26

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

Postby Alundaio » 04 Dec 2016, 06:09

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)
"I have a dream that one day this community will rise up and live out the true meaning of its creed: "We hold these truths to be self-evident; that all mods are created equal."

User avatar
Diegtiarov
Trespasser
Posts: 52
Joined: 12 Nov 2015, 08:34
Contact:

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

Postby Diegtiarov » 11 Dec 2016, 10:07

So, finally checked that today...

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

User avatar
Alundaio
S.T.A.L.K.E.R.
Posts: 1368
Joined: 26 May 2012, 22:26

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

Postby Alundaio » 11 Dec 2016, 16:09

You should re-merge your mod's scripts. They are still outdated, specifically xr_motivator.script
"I have a dream that one day this community will rise up and live out the true meaning of its creed: "We hold these truths to be self-evident; that all mods are created equal."

User avatar
Diegtiarov
Trespasser
Posts: 52
Joined: 12 Nov 2015, 08:34
Contact:

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

Postby Diegtiarov » 13 Dec 2016, 14:35

Done. Will be included in next addon update.

User avatar
Alundaio
S.T.A.L.K.E.R.
Posts: 1368
Joined: 26 May 2012, 22:26

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

Postby Alundaio » 13 Dec 2016, 17:22

Cool thanks :gizmo:
"I have a dream that one day this community will rise up and live out the true meaning of its creed: "We hold these truths to be self-evident; that all mods are created equal."


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest

cron