Skip to content

Commit 8c0a266

Browse files
committed
Implement stripHexCode function and update output messages to remove hex codes from player names
1 parent b08ce6c commit 8c0a266

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

[editor]/editor_main/server/saveloadtest_server.lua

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ addEventHandler("newResource", root,
116116
triggerClientEvent ( source, "saveloadtest_return", source, "new", true )
117117
triggerEvent("onNewMap", resourceRoot)
118118
dumpSave()
119-
editor_gui.outputMessage(getPlayerName(client).." started a new map.", root, 255, 0, 0)
119+
editor_gui.outputMessage(stripHexCode(getPlayerName(client)).." started a new map.", root, 255, 0, 0)
120120

121121
actionList = {}
122122
currentActionIndex = 0
@@ -138,6 +138,7 @@ function handleOpenResource()
138138
if (isElement(openingSource)) then
139139
triggerClientEvent ( openingSource, "saveloadtest_return", openingSource, "open", true )
140140
playerName = getPlayerName ( openingSource )
141+
playerName = stripHexCode( playerName )
141142
end
142143
local outputStr = playerName.." opened map "..tostring(openingResourceName)..". (opening took "..math.floor(getTickCount() - openingStartTick).." ms)"
143144
editor_gui.outputMessage ( outputStr, root, 255, 0, 0 )
@@ -483,7 +484,7 @@ function saveResourceCoroutineFunction ( resourceName, test, theSaver, client, g
483484
if ( returnValue ) then
484485
loadedMap = resourceName
485486
if (theSaver) then
486-
editor_gui.outputMessage ( getPlayerName(theSaver).." saved to map resource \""..resourceName.."\".", root, 255, 0, 0 )
487+
editor_gui.outputMessage ( stripHexCode(getPlayerName(theSaver)).." saved to map resource \""..resourceName.."\".", root, 255, 0, 0 )
487488
end
488489
end
489490
if ( theSaver ) then
@@ -639,7 +640,7 @@ function doQuickSaveCoroutineFunction(saveAs, dump, client)
639640
triggerClientEvent ( client, "saveloadtest_return", client, "save", true )
640641
end
641642
if ( not dump ) then
642-
editor_gui.outputMessage (getPlayerName(client).." saved the map.", root,255,0,0)
643+
editor_gui.outputMessage (stripHexCode(getPlayerName(client)).." saved the map.", root,255,0,0)
643644
dumpSave()
644645
end
645646
else
@@ -685,6 +686,8 @@ function createElementAttributesForSaving(xmlNode, element)
685686
xmlNodeSetAttribute(elementNode, "rotX", toAttribute(round(dataValue[1], 3)))
686687
xmlNodeSetAttribute(elementNode, "rotY", toAttribute(round(dataValue[2], 3)))
687688
xmlNodeSetAttribute(elementNode, "rotZ", toAttribute(round(dataValue[3], 3)))
689+
elseif ( dataName == "scale" ) then
690+
xmlNodeSetAttribute(elementNode, "scale", toAttribute(round(dataValue, 3)))
688691
elseif ( dataName == "posX" or dataName == "posY" or dataName == "posZ") then
689692
xmlNodeSetAttribute(elementNode, dataName, toAttribute(round(dataValue, 5)))
690693
if (dataName == "posX") then

[editor]/editor_main/server/util.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ function isPlayerAllowedToDoEditorAction(player,action)
77
return false
88
end
99

10+
function stripHexCode(text)
11+
return text:gsub("#%x%x%x%x%x%x","")
12+
end
13+
1014
function table.subtract(t1, t2)
1115
local find, remove = table.find, table.remove
1216
for i=#t1,1,-1 do

0 commit comments

Comments
 (0)