Hi all,
I was wondering if you have any better solution other than the one I'm currently using for comparing IDs to names.
I used to code in C# long time ago, and coming back to it from JS is rather strange for me, i have following code for comparing names with it's actual ID
Code:
List<dynamic> list = new List<dynamic>();
foreach (System.Reflection.FieldInfo prop in typeof(NPCID).GetFields()) {
if (prop.Name.Contains(parameter)) {
dynamic expando = new System.Dynamic.ExpandoObject();
expando.name = prop.Name;
expando.id = prop.GetValue(prop);
list.Add(expando);
}
}
if(lis*****unt() > 1) {
Main.NewText("Found many monsters under that name, could not spawn.");
foreach (var i in list) {
Main.NewText(string.Format("{0}: {1}", i.id, i.name));
}
} else if ( lis*****unt() == 1){
NPC.NewNPC((int)player.position.X, (int)player.position.Y, list[0].id);
Main.NewText(string.Format("Successfully spawned npc"));
}
Second question I have - If i remember correctly, there was an option in old terraria versions to spawn NPCs client side on the server, so everybody could see & attack them, but now if i spawn anything it dissappears. Same goes for item editing, when i drop my custom edited item, eg. i set sword's damage to 1000, the item goes back to it's original state. I assume it's because these items have a function SetDefaults set when it's picked up, but not sure.
Third question - Didn't actually test that, but when i want to edit my items, to get the actual item held, the function is
Main.player[Main.myPlayer].HeldItem. Is it possible to set
Main.myPlayer to other player ID so i can view/edit their items as well? Is it possible from the client side or do I need to edit the server and add custom commands?