Closed ETcodehome closed 7 years ago
angstroms?
Ah. that might be from the color-coding. I switched to a new message method some weeks ago because of changes in the chat plugin:
https://github.com/uncovery/uncovery_me/blob/master/websend_inc/mod.inc.php#L190
This might be related. We used to use this here:
https://github.com/uncovery/uncovery_me/blob/master/includes/websend.inc.php#L478
I am not 100% sure it's because of this, but likely related in some sense to the new chat plugin.
the Broadcast might need a different way to do colorcodes. The issue is that the colors ARE changing, so not sure if there is anything unneedd that is creating the Angstroms.
function umc_mod_broadcast($msg) { global $WS_INIT; $chat_command = $WS_INIT['mod']['broadcast']; // we can send several messages as an array. if (!is_array($msg)) { $msg = array($msg); } foreach ($msg as $line) { $str = preg_replace(color_regex() . "e", 'color_map(\'$1\')', $line); $full_command = "$chat_command $str;"; umc_exec_command($full_command, 'asConsole'); } }
should probably also be using echo instead of a specialised command that prefixes with broadcast.
umc_echo("{yellow}[!]{gray} Didn't specify {yellow}request{gray} or {yellow}offer{gray}, assuming {yellow}offer", true);
ah but echo doesn't psuh to all.... hrmm.
yes exactly.
/tellraw @a ["",{"text":"[!]"},{"text":" Psiber voted! Rolled ","color":"gold"},{"text":"936"},{"text":"! Recieved ","color":"gold"},{"text":"15 Potatoes!"}]
That's the right basic command to be using for this since it isnt wrapped by something else. Removes all the [Broadcast] and makes it far easier / cleaner to read. Will update to have same fields etc.
function color_map($color = null) { global $UMC_COLORS; $keys = array();
foreach ($UMC_COLORS as $code => $types) {
$keys = array_merge($keys, $types['names']);
if (isset($color) && in_array($color, $types['names'])) {
return "§". $code;
}
}
if (isset($color)) { // there is an error, we should not be here, color not found
return;
}
return $keys;
}
The unicode character added to the start of the color codes, was that specific to old chat system? return "§". $code;
http://minecraft.tools/en/color-code.php
does the new system not need the unicdoe preface?
So the tellraw is definetely the best thing we can do. We would need a function abstracting this The function above is for the way colors worked in the old code (when this whole {...} did not exist in chat. If we translate colors that are used in commands right now to the "color":"gold" stuff, we can forget about those.
It think it's easiest to go through the code and make sure that system messages use a good format. I am afraid that the $ and § color codes are quite difficult to translate into the "color":"gold" type of text.
Well, the tellraw is also the best long term solution too, since that is native functionality (best for efficiency and future proofing).
It also has some awesome options available for mouse over text, clickable buttons (like a buy now command that prefills in chat when you click a shop listing), description texts, all sorts.
While it's nice to have a 1:1 transition from the old color code formatting I'm not sure that a straight translation for the old messgaes is the best solution. We should be really looking at each usage that is a problem and seeing if the tellraw opens new ways to improve the user experience.
We should just migrate the problematic commands over for right now. Generate any feedback that we want to adapt to the new system as we need them.
Is an awesome generator for rapidly generating the JSON chat strings.
Will start with modifying this one to use as an example.
Is there a source code for this tool available? I wonder how much we want to have an abstraction layer for this or if we should use tellraw directly in the code.
I can't imagine that they have source available for it, since their whole website is basically supplying these tools (for various useful bits and pieces)
Shop listings have multiple angstroms in them.