How do I translate this C# command to Python?
Code:AutoTurret[] turrets = GameObject.FindObjectsOfType<AutoTurret>();
Solved Getting all turrets with GameObject.FindObjectsOfType in Python?
Discussion in 'Rust Development' started by BlackMOTH, Sep 28, 2016.
-
GameObject.FindObjectsOfType[AutoTurret]() might work.
Make sure to import GameObject, though. -
Yea I tried that but I get ironPython error that I can't import GameObject.
Don't have the exact error with me now but I will post it later when I get on my other PC. -
How are you trying to import GameObject?
-
import GameObject
is there any other way
this is the error that I get when loading python plugin
ImportError: Import of module GameObject not allowed -
In this case it's "Not found".
GameObject is in the UnityEngine namespace.
TryCode:import UnityEngine.GameObject
Code:import UnityEngine.GameObject as GameObject
-
Thanks!
Got that working now
would you also happen to know how to modify bulletDamage on the AutoTurret.
Looked at JustDecompile it's private variable so it';s not present on the turret.
TurretsConfig.cs uses this:
FieldInfo bulletDamageField = typeof(AutoTurret).GetField("bulletDamage", (BindingFlags.Instance | BindingFlags.NonPublic));
bulletDamageField.SetValue(turret, GetBulletDamage(userID));
have no idea how to get that field out from AutoTurret in python -
I just tried a bunch of things, but none of them worked, so not sure if it's possible.