Hello guys, how to rewrite code below to C#? it's in Lua now
Code:local ParachuteField = global.SupplyDrop._type:GetField("parachute", rust.Private()) if (ParachuteField) then local Parachute = ParachuteField:GetValue(SupplyDrop) if (Parachute) then
Solved Rewriting code from Lua to C# GetField/GetValue
Discussion in 'Rust Development' started by Sanlerus, Jun 7, 2015.
-
At random, since the forum is probably dead.
-
And to answer @Sanlerus' question, You'd be using Reflection (https://msdn.microsoft.com/en-us/library/ms173183.aspx)
So in your case it will be something like this
Code:... private FieldInfo parachute = typeof(SupplyDrop).GetField("parachute", BindingFlags.NonPublic | BindingFlags.Instance); ... private void OnEntitySpawned(BaseEntity entity) { var airdrop = entity as SupplyDrop; if (airdrop == null) return; var supplydropParachute = parachute.GetValue(airdrop); } ...