. . . Posted May 18, 2018 Share Posted May 18, 2018 (edited) Hello, if someone can help me out with this that'd be nice! So, is there a way to check if the player is using the map? In my function I want to change my character's minimap icon but only when the player's map is open Spoiler local function MapIconAnimate(inst) --if inst.HUD and inst.HUD:IsMapScreenOpen() then return end if inst.components.playercontroller == nil then return end inst.MiniMapEntity:SetIcon("vyu5.tex") inst:DoTaskInTime(.06, function() inst.MiniMapEntity:SetIcon("vyu4.tex") end) inst:DoTaskInTime(.12, function() inst.MiniMapEntity:SetIcon("vyu3.tex") end) inst:DoTaskInTime(.18, function() inst.MiniMapEntity:SetIcon("vyu2.tex") end) inst:DoTaskInTime(.24, function() inst.MiniMapEntity:SetIcon("vyu1.tex") end) inst:DoTaskInTime(.3, function() inst.MiniMapEntity:SetIcon("vyu2.tex") end) inst:DoTaskInTime(.36, function() inst.MiniMapEntity:SetIcon("vyu3.tex") end) inst:DoTaskInTime(.42, function() inst.MiniMapEntity:SetIcon("vyu4.tex") end) inst:DoTaskInTime(.48, function() inst.MiniMapEntity:SetIcon("vyu5.tex") end) inst:DoTaskInTime(.54, function() inst.MiniMapEntity:SetIcon("vyu6.tex") end) end I tried using code like this Spoiler if inst.HUD and inst.HUD:IsMapScreenOpen() then return end but for some reason it doesn't work? As if I remove the " if inst.components.playercontroller == nil then return end " then spawned in of my player prefab will activate this function even though they're obviously not using the map, thanks for your time ! Edited May 23, 2018 by SuperDavid Link to comment Share on other sites More sharing options...
. . . Posted May 19, 2018 Author Share Posted May 19, 2018 bump Link to comment Share on other sites More sharing options...
RedHairedHero Posted May 22, 2018 Share Posted May 22, 2018 inst.HUD:IsMapScreenOpen() Link to comment Share on other sites More sharing options...
. . . Posted May 22, 2018 Author Share Posted May 22, 2018 I'm using that atm but it does not seem to work, thank you though ! Link to comment Share on other sites More sharing options...
RedHairedHero Posted May 22, 2018 Share Posted May 22, 2018 2 minutes ago, SuperDavid said: I'm using that atm but it does not seem to work, thank you though ! Weird, I just tested it and it seemed to be work. Link to comment Share on other sites More sharing options...
. . . Posted May 22, 2018 Author Share Posted May 22, 2018 (edited) That's strange, when I try using "inst.HUD:IsMapScreenOpen()" in my local function the game crashes saying attempt to index field 'HUD' (a nil value) Then I use this code as a test local function MapIconAnimate(inst) if inst.HUD and inst.HUD:IsMapScreenOpen() then inst.components.talker:Say(GetString(inst, "ANNOUNCE_WINTER")) end end --inside masterpostinit inst:DoPeriodicTask(1.3, MapIconAnimate) & I'm pretty sure when you're in the map your character can still talk, but my character said nothing while I was in the map.. this is so weird, thanks though ! Edited May 22, 2018 by SuperDavid Link to comment Share on other sites More sharing options...
RedHairedHero Posted May 22, 2018 Share Posted May 22, 2018 I know inst for that represents ThePlayer so I think you can do Local inst = ThePlayer inst.HUD:IsMapScreenOpen() Link to comment Share on other sites More sharing options...
. . . Posted May 22, 2018 Author Share Posted May 22, 2018 well a new crash has emerged " attempt to index local 'inst' (a nil value) " Spoiler local function MapIconAnimate(inst) local inst = ThePlayer if inst.HUD:IsMapScreenOpen() then return end if inst.sneaking == true or inst.components.playercontroller == nil or not inst.components.sanity:IsSane() then return end inst.MiniMapEntity:SetIcon("vyu5.tex") inst:DoTaskInTime(.06, function() inst.MiniMapEntity:SetIcon("vyu4.tex") end) inst:DoTaskInTime(.12, function() inst.MiniMapEntity:SetIcon("vyu3.tex") end) inst:DoTaskInTime(.18, function() inst.MiniMapEntity:SetIcon("vyu2.tex") end) inst:DoTaskInTime(.24, function() inst.MiniMapEntity:SetIcon("vyu1.tex") end) inst:DoTaskInTime(.3, function() inst.MiniMapEntity:SetIcon("vyu2.tex") end) inst:DoTaskInTime(.36, function() inst.MiniMapEntity:SetIcon("vyu3.tex") end) inst:DoTaskInTime(.42, function() inst.MiniMapEntity:SetIcon("vyu4.tex") end) inst:DoTaskInTime(.48, function() inst.MiniMapEntity:SetIcon("vyu5.tex") end) inst:DoTaskInTime(.54, function() inst.MiniMapEntity:SetIcon("vyu6.tex") end) end --masterpostinit inst:DoPeriodicTask(1.3, MapIconAnimate) still thanks for the help mate !! Link to comment Share on other sites More sharing options...
RedHairedHero Posted May 22, 2018 Share Posted May 22, 2018 When do you get the error message? I'm guessing the function is running before ThePlayer is established and it's making it nil and may be what's causing the error. Normally if I need to troubleshoot these I'll add a print under the variable to see what it is. I would temporarily comment out the MapScreenOpen section and do... local inst = ThePlayer print (inst) I can try to troubleshoot this when I get home tonight if you want to share your file. Link to comment Share on other sites More sharing options...
. . . Posted May 23, 2018 Author Share Posted May 23, 2018 Hey I found out why it worked for you it's because the code "MapScreenOpen" seems to only work when in a non-caves world as it worked for me like that, but in a caves world it doesn't do anything.. also I did local inst = ThePlayer print (inst) and it said my character's name in console Link to comment Share on other sites More sharing options...
CarlZalph Posted May 24, 2018 Share Posted May 24, 2018 That information is client-sided in a caverns setup, and you'll need to look into RPCs to let the server know when the client opens/closes their minimap. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now