Closed Trojaner closed 6 years ago
Yes, many people dream about this, we had such a problem, either the animation of the effect, or many effects (same type), or chat.
This would allow for so much haha
How do you propose the game find strings to format with your bindings? Or just looking through every string field on the object?
loop string fields as soon as assets load and cache them maybe?
@SDGNelson Hm?
effects are unity prefabs so its a bit hard to have data on them
but it should not be impossible
Sorry - this is still on my radar, but not super high priority between balancing 4 and 3 development. I'm thinking the next update will be Christmas related, and then I'll be back to Calgary for the holiday. I promise I'll get at least formatting custom effect strings into Text.text sometime January!
This Friday's update has two new features available in EffectManager.sendUIEffect which should allow some neat stuff:
You can optionally provide a 16-bit "key" (or -1 to disable) which will remove an effect with the same key before spawning the new one. My thinking is that this will allow you to update effects rather than repeatedly sending them.
You can format up to 4 strings into your effect similar to the original post e.g. {2} will be replaced with arg2.
Closing the issue, but interested to see what you can make with it and further requests.
Thanks for adding it 👍 , But arent 4 strings a bit limited? What about having dynamic size array instead? (E.g. sending size of string array, then for each string first sending size of string then the characters themselves)
I dont know if the SteamCall serialization supports string arrays as arguments but worst case is sending it as packet stream, like this:
(pseudo code)
//sending
string[] array = ...
send(array.Length)
foreach(string s in array)
{
send(s.Length);
foreach(var c in s)
send(c);
}
//receiving
int length = read<int>();
string[] array = new string[length];
for(int i = 0; i < length; i++)
{
int strLength = read<int>();
StringBuilder sb = new StringBuilder();
for(int j = 0; j < strLength; j++) {
sb.Append(read<char>());
}
array[i] = sb.ToString();
}
Just use chunk buffer packet type with dynamic array of args :)
Tell me if code needed 💃
It would be fairly straightforward to add read/write string array to the Block class, but in what cases would you need that many strings?
EffectManager.sendUIEffect(3, 11234455, player.CSteamID, true, String.Format("Hello"), String.Format("Man"), String.Format("Man"), String.Format("Man"));
is dont work
@Trankvil https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/short Special for you
@SDGNelson ... sendUIEffect
without steamID parameter methods are booed. You need to call not tellUIEffect
but overloads with arguments like tellUIEffect4Args
since you're sending those
Otherwise works fine. Something like https://youtu.be/ZQbvzb13vFE is doable without pain in the ass
@aviadmini
EffectManager.manager.channel.send("tellUIEffect4Args", steamID, (!reliable) ? ESteamPacket.UPDATE_UNRELIABLE_BUFFER : ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[] { id, key, arg0, arg1, arg2, arg3 });
this code?
@Trankvil You don't need this
Btw @SDGNelson there's no way to remove effect from indexed on client, is there? (key = -1 simply destroys effect)
@aviadmini stop. i dont understand... me need upload mod in workshop?
If you want it to work - yes 💃
@SDGNelson Could you also add an option to update indexed effect with same ID, not just spawn a new one with new string? I can provide the code
@aviadmini i have code:
EffectManager.createAndFormatUIEffect(3, sdd, String.Format("Hello"), String.Format("Man"), String.Format("Man"), String.Format("Man"));
I understand, I need to have a mod with a canvas, where I want to output, right?
Currently effects can not display any data sent by the server.
My idea is to trigger effects like this:
(bindings is optional)
bindings would replace {0} in texts with bindings[0], {1} with bindings[1] etc... (e.g.
Hello {0}
would becomeHello Trojaner
if bindings is set to {"Trojaner"})This could use string.Format to implement it.
The reason why I ask for this is to have more dynamic effects possible (e.g. an effect displaying "You killed xxxxx!" on the screen)
Of course these effects with data binding should not be able to get triggered by triggerEffect without bindings or wrong bindings.
Actually I would prefer
object[] bindings
but that seems not possible with the current serialization.