XenoBot Forums - Powered by vBulletin

User Tag List

Results 1 to 6 of 6

Thread: [Other] String concat. crash

  1. #1
    Senior Member XtrmJosh's Avatar
    Join Date
    Apr 2012
    Location
    Cambridge, England
    Posts
    1,324
    Mentioned
    39 Post(s)
    Tagged
    0 Thread(s)

    [Other] String concat. crash

    Bug Report
    Operating System:
    Other
    Short Description:
    String concat. crash
    Behaviors:
    • Client Freeze/Crash

    Indepth Description:
    It seems that this code:

    Code:
    local currentTime = os.date("*t", 906000490)
    local stamp = currentTime.hour .. " " .. currentTime.min
    
    print(stamp)
    Causes the client to crash. Meanwhile, this code:

    Code:
    local currentTime = os.date("*t", 906000490)
    local stamp = currentTime.hour .. " : " .. currentTime.min
    
    print(stamp)
    Does not. As you can see, the only difference is an extra space and : in the latter.

  2. #2
    Queen Fatality Fatality's Avatar
    Join Date
    Mar 2014
    Location
    Canada
    Posts
    754
    Mentioned
    83 Post(s)
    Tagged
    1 Thread(s)
    They both work for me o.0

  3. #3
    Senior Member maroxy's Avatar
    Join Date
    Apr 2014
    Location
    EUW
    Posts
    897
    Mentioned
    137 Post(s)
    Tagged
    0 Thread(s)
    lua code:
    local time = os.date("%X")
    print(time)


    You can use this one.


    Remember that the official XenoBot page is www.xenobot.net not xeno-bot.net or similar

  4. #4
    Queen Fatality Fatality's Avatar
    Join Date
    Mar 2014
    Location
    Canada
    Posts
    754
    Mentioned
    83 Post(s)
    Tagged
    1 Thread(s)
    If you want it to return the same as the snippet of code, you could use this
    lua code:

    local time = os.date("*t", 906000490)
    print('%s %d', time.hour, time.min)


    And if you want it as a variable, not just printing it, you can do this.

    lua code:

    local time = os.date("*t", 906000490)
    local tmp = "%s %s"
    local stamp = time1:format(time.hour, time.min)
    print(time)
    Last edited by Fatality; 01-26-2016 at 05:27 PM.

  5. #5
    Senior Member XtrmJosh's Avatar
    Join Date
    Apr 2012
    Location
    Cambridge, England
    Posts
    1,324
    Mentioned
    39 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Fatality View Post
    They both work for me o.0
    Quote Originally Posted by Fatality View Post
    If you want it to return the same as the snippet of code, you could use this
    lua code:

    local time = os.date("*t", 906000490)
    print('%s %d', time.hour, time.min)


    And if you want it as a variable, not just printing it, you can do this.

    lua code:

    local time = os.date("*t", 906000490)
    local tmp = "%s %s"
    local stamp = time1:format(time.hour, time.min)
    print(time)
    Thanks - working on finding an exact repro. I tried to simplify too much, might be a Lua implementation issue (e.g one of the XB functions). Investigating, will update shortly.

    The exact code, if anyone wants to investigate in tandem:

    Code:
    --[[
    	This is a XenoBot example script, intended to
    	teach new users about the scripting API and 
    	act as script that is usable in actual play.
    	
    	recentPrivateMessageHUD.lua - displays a HUD
    	showing your most recent private messages.
    
    	** DO NOT EDIT THIS FILE. INSTEAD, COPY IT TO
    	"Documents\XenoBot\Scripts" AND EDIT THE COPY. **
    ]]--
    
    --set the title of the HUD
    local title = "Recent Private Messages:"
    local showTitle = true
    
    --set the number of messages to show
    local messageCount = 4
    
    --set the maximum message length (including sender name)
    local messageLength = 60
    
    --set the top left x and y coordinates of the HUD
    local location =
    {
    	x = 25,
    	y = 5
    }
    
    --set the colors for the HUD
    local colors = 
    {
    	message = {95, 247, 247},
    	title = {225, 225, 225},
    }
    
    -------------------------------------------------------------------------------------------------
    -------------------------------------------------------------------------------------------------
    -------------------------------------------------------------------------------------------------
    
    --this creates the title HUD
    if (showTitle == true) then
    	local HUDTitle = HUD.CreateTextDisplay(location.x, location.y, title, unpack(colors.title))
    	location.y = location.y + 20 -- just offsets the y axis to below the header
    end
    
    --loop from 1 until messageCount, creating HUD objects for each
    local HUDData = {}
    for index = 1, messageCount do
    	local data = {}
    	
    	-- no message yet
    	data.message = ""
    	
    	--create the label HUD
    	data.label = HUD.CreateTextDisplay(
    							location.x,
    							-- +12 pixels to the y axis for every item
    							location.y + ((index - 1) * 12),
    							data.message,
    							-- text color
    							unpack(colors.message)
    						)
    						
    	--store the data to use later
    	HUDData[index] = data
    end
    
    --this is a proxy event which gets invoked when a private message is received
    PrivateMessageProxy.OnReceive("pmProxy", function (proxy, speaker, level, text)
    	--create the message from the data
            local currentTime = os.date("*t")
            local message = currentTime.hour .. ":" .. currentTime.min .. " | " .. speaker .. " [" .. level .. "]: " .. text
    	
    	--if the message is too long, this will shorten it
    	if (string.len(message) > messageLength) then
    		message = string.sub(message, 0, messageLength - 3) .. "..."
    	end
    	
    	--this will move each message "up" (from index 4 to 3, 3 to 2, 2 to 1, etc)
    	for index = 1, messageCount-1 do
    		HUDData[index].message = HUDData[index+1].message
    		HUDData[index].label:SetText(HUDData[index].message)
    	end
    	
    	--this will put the new message in the last index
    	HUDData[messageCount].message = message
    	HUDData[messageCount].label:SetText(message)
    end)
    The line

    Code:
            local message = currentTime.hour .. ":" .. currentTime.min .. " | " .. speaker .. " [" .. level .. "]: " .. text
    Remove the | and one of the spaces next to it, send yourself a PM, and observe crash.

    Edit: Not crashing for me. Did for @Luls. Not crashing for him now. What the very fuck is happening?!
    Last edited by XtrmJosh; 01-26-2016 at 06:50 PM.
    You cannot fail, so I'm lowering the standard.

  6. #6
    Super Moderator Luls's Avatar
    Join Date
    Dec 2010
    Location
    Canadaaaa.
    Posts
    1,976
    Mentioned
    186 Post(s)
    Tagged
    0 Thread(s)
    We were unable to reproduce the crash :S

    Closed.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •