Craftopia

Craftopia

ChatItem
Psychloor 4 Jul, 2023 @ 1:43pm
itemname as input
hi, i decompiled your code to use privately with commandhandler and also added in so you can type in itemname with spaces instead of itemid.

can write "@item gigantes' arrow 20"
to get 20 of them

the modification i did is this if you'd like to use it:

private static void CreateItemCommand(string[] args)
{
try
{
if (args.IsNullOrEmpty())
{
Debug.Log("The number of arguments is invalid.");
CommandHandler.DisplayBubbleToPlayer("The number of arguments is invalid.");
return;
}

string[] itemParams = { "", "", "", "", "", "", "" };

// Item name as string
if (!char.IsDigit(args[0][0]))
{
int stringEndPos = 0;
for (int i = 0; i < args.Length; i++)
{
if (char.IsDigit(args[i][0]))
{
stringEndPos = i;
break;
}
}

string itemName = string.Join(" ", args.Take(stringEndPos));
var itemRes = SingletonMonoBehaviour<OcItemDataMng>.Inst.appearIngameItemDataList.FirstOrDefault(i =>
i.DisplayName.IndexOf(itemName, StringComparison.OrdinalIgnoreCase) >= 0);

if (itemRes != null)
{
itemParams[0] = itemRes.Id.ToString();
Array.Copy(args, stringEndPos, itemParams, 1, Math.Min(args.Count() - stringEndPos, 6));
}
else
{
CommandHandler.DisplayBubbleToPlayer("Item not found : " + itemName);
return;
}
}
else
{
Array.Copy(args, 0, itemParams, 0, Math.Min(args.Count(), 7));
}
// and the rest of the code continues here
Last edited by Psychloor; 4 Jul, 2023 @ 1:53pm
< >
Showing 1-6 of 6 comments
mokos311  [developer] 4 Jul, 2023 @ 8:52pm 
We did not implement the item name generation because it seemed to increase the number of cases of generation failure due to typing errors.

And even in those cases, I get comments saying "this mod doesn't work". It is very annoying.
mokos311  [developer] 4 Jul, 2023 @ 8:53pm 
:rbrbu3:
Psychloor 5 Jul, 2023 @ 1:53am 
alright, well it's your mod so you're freely able to do what you want and i can get that some people think misspelling is an error
This extension looks very cool, just like using the command [/give] in Minecraft:steamthumbsup:
JingShing 11 Jul, 2023 @ 9:52am 
How do you decompiled code? I using dnspy and I failed to recompile the code I changed.
Psychloor 12 Jul, 2023 @ 3:33am 
Originally posted by JingShing:
How do you decompiled code? I using dnspy and I failed to recompile the code I changed.
you need all references the code used if you want to recompile with dnspy.
i made a new mod all together and used the decompiled code to change how it works and use with commandhandler instead
< >
Showing 1-6 of 6 comments
Per page: 1530 50