Reflex# Posted December 9, 2012 Share Posted December 9, 2012 I have a question.. How to add date of toptime to toptimes(F5) script? Link to comment
TwiX! Posted December 9, 2012 Share Posted December 9, 2012 search in toptimes_client.lua function CToptimes:doOnServerSentToptimes( data, serverRevision, playerPosition ) and use local yourLines = 10 for i=1,yourLines do outputChatBox ( data[i].dateRecorded ); end Change outputChatBox on dxDrawText or guiSetText Link to comment
Reflex# Posted December 9, 2012 Author Share Posted December 9, 2012 I must to change code 1 on code 2? Or just put code 2 after code 1? Link to comment
TwiX! Posted December 10, 2012 Share Posted December 10, 2012 function CToptimes:doOnServerSentToptimes( data, serverRevision, playerPosition ) outputDebug( 'TOPTIMES', 'CToptimes:doOnServerSentToptimes ' .. tostring(#data) ) -- Calc number lines to use and height of window local numLines = math.clamp( 0, #data, 50 ) self.size.y = 46 + 15 * numLines -- Set height of window local sizeX = self.size.x local sizeY = self.size.y guiSetSize( self.gui['windowbg'], sizeX, sizeY, false ) -- Make listTimes contains the correct number of labels self:updateLabelCount(numLines) -- Update the list items for i=1,numLines do local d = data[i].dateRecorded local timeText = data[i].timeText if timeText:sub(1,1) == '0' then timeText = ' ' .. timeText:sub(2) end local line = string.format( '%d. %s %s %s', i, timeText, data[i].playerName, d ) guiSetText ( self.gui['listTimes'][i], line ) if i == playerPosition then guiLabelSetColor ( self.gui['listTimes'][i], 0, 255, 255 ) else guiLabelSetColor ( self.gui['listTimes'][i], 255, 255, 255 ) end end -- Debug if _DEBUG_CHECK then outputDebug( 'TOPTIMES', 'toptimes', string.format('crev:%s srev:%s', tostring(self.clientRevision), tostring(serverRevision) ) ) if self.clientRevision == serverRevision then outputDebug( 'TOPTIMES', 'Already have this revision' ) end end -- Update status self.clientRevision = serverRevision self.listStatus = 'Full' self:updateShow() end Link to comment
Reflex# Posted December 10, 2012 Author Share Posted December 10, 2012 function CToptimes:doOnServerSentToptimes( data, serverRevision, playerPosition ) outputDebug( 'TOPTIMES', 'CToptimes:doOnServerSentToptimes ' .. tostring(#data) ) -- Calc number lines to use and height of window local numLines = math.clamp( 0, #data, 50 ) self.size.y = 46 + 15 * numLines -- Set height of window local sizeX = self.size.x local sizeY = self.size.y guiSetSize( self.gui['windowbg'], sizeX, sizeY, false ) -- Make listTimes contains the correct number of labels self:updateLabelCount(numLines) -- Update the list items for i=1,numLines do local d = data[i].dateRecorded local timeText = data[i].timeText if timeText:sub(1,1) == '0' then timeText = ' ' .. timeText:sub(2) end local line = string.format( '%d. %s %s %s', i, timeText, data[i].playerName, d ) guiSetText ( self.gui['listTimes'][i], line ) if i == playerPosition then guiLabelSetColor ( self.gui['listTimes'][i], 0, 255, 255 ) else guiLabelSetColor ( self.gui['listTimes'][i], 255, 255, 255 ) end end -- Debug if _DEBUG_CHECK then outputDebug( 'TOPTIMES', 'toptimes', string.format('crev:%s srev:%s', tostring(self.clientRevision), tostring(serverRevision) ) ) if self.clientRevision == serverRevision then outputDebug( 'TOPTIMES', 'Already have this revision' ) end end -- Update status self.clientRevision = serverRevision self.listStatus = 'Full' self:updateShow() end I put it in the end of toptimes_client.lua and debugscript 3 showed me : @ 784 : bad argument #5 to 'format' (string expected,got nil) Link to comment
TwiX! Posted December 14, 2012 Share Posted December 14, 2012 change %s on number, not string, like %d Link to comment
Reflex# Posted December 14, 2012 Author Share Posted December 14, 2012 change %s on number, not string, like %d you mean change on %1,%2 and etc? Link to comment
TwiX! Posted December 14, 2012 Share Posted December 14, 2012 http://www.lua.org/manual/5.1/manual.ht ... ing.format The options c, d, E, e, f, g, G, i, o, u, X, and x all expect a number as argument, whereas q and s expect a string. Solved, close the topic Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now