Lumina Posted August 15, 2017 Share Posted August 15, 2017 Hi, I have a treasure map creating a treasure spot when i read it. I would like the treasure spot to be revealed on the map when created : i tried to use the function of the different moonlens, but it's not working as i wish (you need to discover the spot of the map before). Any clue about how to do this ? Thanks a lot. Link to comment Share on other sites More sharing options...
ZupaleX Posted August 16, 2017 Share Posted August 16, 2017 When you share a map with somebody else, it discovers what you have explored for the other person even if that person did not go there at the first place no? I guess that's from where I would start. Link to comment Share on other sites More sharing options...
Lumina Posted August 16, 2017 Author Share Posted August 16, 2017 It seems to use the maprecorder component. But i'm not sure i can use it to record only a small part of the map (around the spawned item) and make the user of the treasure map learn it, because i'm not sure the item could "have" a map. Not sure also this code could help to learn small part of the map, but i must admit it's not a code i understand well. Link to comment Share on other sites More sharing options...
JohnWatson Posted August 16, 2017 Share Posted August 16, 2017 (edited) local pt = Vector3(inst.Transform:GetWorldPosition()) for k,v in ipairs(AllPlayers) do if v.player_classified~=nil and v.player_classified.MapExplorer~=nil then v.player_classified.MapExplorer:RevealArea(pt.x,0,pt.z) end end Haven't tested if it works, but you'll get the idea Edited August 16, 2017 by JohnWatson Link to comment Share on other sites More sharing options...
Cunning fox Posted August 17, 2017 Share Posted August 17, 2017 7 hours ago, JohnWatson said: local pt = Vector3(inst.Transform:GetWorldPosition()) for k,v in ipairs(AllPlayers) do if v.player_classified~=nil and v.player_classified.MapExplorer~=nil then v.player_classified.MapExplorer:RevealArea(pt.x,0,pt.z) end end Haven't tested if it works, but you'll get the idea Can someone explain me what "Vector3" is for? I see it like in lots of scripts, but I can't understand what it's for. I usually use local x,y,z = inst.Trasnform:GetWorldPosition() 1 Link to comment Share on other sites More sharing options...
Cunning fox Posted August 17, 2017 Share Posted August 17, 2017 I've made my own treasure mod, and I used maprevaelable components. But It shows icon to every player. local function SpawnChest(inst) local chest = SpawnPrefab("treasurechest") local fx = SpawnPrefab("maxwell_smoke") if chest ~= nil then chest:AddComponent("scenariorunner") chest.components.scenariorunner:SetScript("chest_treasures") chest.components.scenariorunner:Run() chest:AddComponent("timer") chest.components.timer:StartTimer("RemoveChest", TUNING.WHEN_REMOVE_CHEST*.5) chest:ListenForEvent("timerdone",function(inst) local oldonfinish = inst.components.workable.onfinish oldonfinish(inst) end) chest.Transform:SetPosition(inst.Transform:GetWorldPosition()) end if fx ~= nil then fx.Transform:SetPosition(inst.Transform:GetWorldPosition()) end inst:PushEvent("RemoveSpot") end local function OnDig(inst) local fx = SpawnPrefab("groundpound_fx") if fx ~= nil then fx.Transform:SetPosition(inst.Transform:GetWorldPosition()) fx.Transform:SetScale(.65, .65, .65) end end local function init(inst) if inst.icon == nil then inst.icon = SpawnPrefab("globalmapicon") --inst.icon.MiniMapEntity:SetIsFogRevealer(true) inst.icon:TrackEntity(inst) end end local function treaure_spot() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddSoundEmitter() inst.entity:AddMiniMapEntity() inst.entity:AddNetwork() inst.MiniMapEntity:SetIcon("treasure_cross.tex") inst.MiniMapEntity:SetCanUseCache(false) inst.MiniMapEntity:SetDrawOverFogOfWar(true) inst:AddTag("structure") inst:AddTag("maprevealer") inst.AnimState:SetBank("x_marks_spot") inst.AnimState:SetBuild("x_marks_spot") inst.AnimState:PlayAnimation("anim") inst.AnimState:SetLayer(LAYER_BACKGROUND) inst.AnimState:SetSortOrder(3) inst.entity:SetPristine() if not TheWorld.ismastersim then return inst end inst:AddComponent("inspectable") inst:AddComponent("workable") inst.components.workable:SetWorkAction(ACTIONS.DIG) inst.components.workable:SetWorkLeft(5) inst.components.workable:SetOnFinishCallback(SpawnChest) inst.components.workable:SetOnWorkCallback(OnDig) inst:DoTaskInTime(0, init) inst:ListenForEvent("RemoveSpot", function(inst) inst:Remove() if inst.icon ~= nil then inst.icon:Remove() inst.icon = nil end end) inst:ListenForEvent("timerdone", function(inst, data) if data and data.name == "RemoveSpot" then inst:Remove() if inst.icon ~= nil then inst.icon:Remove() inst.icon = nil end end end) return inst end 1 Link to comment Share on other sites More sharing options...
Lumina Posted August 17, 2017 Author Share Posted August 17, 2017 4 hours ago, makar5000 said: I've made my own treasure mod, and I used maprevaelable components. But It shows icon to every player. Ah thanks, it's an option, too. Especially if i don't understand how to make JohnWatson code work. Thanks JohnWatson too, i'll try it. Link to comment Share on other sites More sharing options...
ZupaleX Posted August 18, 2017 Share Posted August 18, 2017 Vector3 is a mathematical vector. It has coordinates (x, y, z) and some other methods (like getting the magnitude) which makes it easier to use than raw x, y and z values 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