Ravenfield

Ravenfield

Loadout Changer (Mutator Mod)
 This topic has been pinned, so it's probably important
Chai  [developer] 9 Jul, 2020 @ 12:23am
If you're a mutator author
How to make a instantiate supply crate available to Loadout Changer

In the start method, check if the Loadout Changer Script is running.

function YourScript:Start() self.lc = GameObject.Find("LoadoutChangeScript(Clone)") self.playingWithlc = false self.behaviourLc = nil if(self.lc) then print("Got LoadoutChangerScript") self.playingWithlc = true self.behaviourLc = ScriptedBehaviour.GetScript(self.lc) end end

There are two functions that you can use in the LoadoutChangeScript:
  1. self.behaviourLc:AddResupplyCrate(InstantiatedResupplyCrate)
  2. self.behaviourLc:RemoveResupplyCrate(InstantiatedResupplyCrate)

Use it like in this example:

behaviour("Tester") function Tester:Start() self.lc = GameObject.Find("LoadoutChangeScript(Clone)") self.playingWithlc = false self.behaviourLc = nil if(self.lc) then print("Got LoadoutChangerScript") self.playingWithlc = true self.behaviourLc = ScriptedBehaviour.GetScript(self.lc) end end function Tester:RemoveFromList(resupplyCr) return function() coroutine.yield(WaitForSeconds(4)) self.behaviourLc:RemoveResupplyCrate(resupplyCr) print("Removed it") end end function Tester:Update() if Input.GetKeyBindButtonDown(KeyBinds.Use) then local ray = Ray(PlayerCamera.activeCamera.main.transform.position + PlayerCamera.activeCamera.main.transform.forward , PlayerCamera.activeCamera.main.transform.forward) local raycast = Physics.Raycast(ray,7, RaycastTarget.Default) if(raycast ~= nil ) then local objec = GameObject.Instantiate(self.targets.resupplyC) self.behaviourLc:AddResupplyCrate(objec) objec.transform.position = raycast.point self.script.StartCoroutine(self:RemoveFromList(objec)) end end end
Last edited by Chai; 9 Jul, 2020 @ 12:24am