XenoBot Forums - Powered by vBulletin

User Tag List

Results 1 to 6 of 6

Thread: Calculator for manual dicers (Only cc's with the automatic calculator atm)

  1. #1

    Join Date
    Nov 2014
    Location
    Sundsvall, Sweden
    Posts
    174
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    Calculator for manual dicers (Only cc's with the automatic calculator atm)

    The script has been updated, look at the comment below.

    Hey, i made this calculator thingy and thought there might be other people who wanted it.

    The calculator channel will multiply anything with 1.8 or the chosen rate.
    When you pick up crystal coins it will automatically multiply it by 1.8 and print the result, also putting the most recent calc on the HUD, but sadly it does not count platinum coins.

    Here's a picture of it:
    bb3da7fe9049c2c12c89fa3554fe9d5c.png

    And here's the code:
    Code:
    Look at the comment below to get the updated script.
    Last edited by yompa93; 04-29-2016 at 12:33 PM.

  2. #2

    Join Date
    Nov 2014
    Location
    Sundsvall, Sweden
    Posts
    174
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Updated the script a bit. After you pickup cash or write in the amount to multiply you can now write "w" to multiply the result with the rate(default 1.8)

    The script does NOT count platinums when picked up, write the total amount in the channel instead.

    Fixed crash when writing letters without any function in the channel.

    Formatted the strings.

    Code:
    -- Calculation ----------------------------------------------------------------------------------------------------------
    rate = 1.8
    
    function multi(f)
    Result1 = f * rate															 						  -- value for 'Most recent calculation' in the HUD.
    win = Result1																 						  -- Storing the calc result to multiply further when the guy playing is winning.
    ProcessDebugMessage('Calculator', ''..f..' * '..rate..' = '.. string.format('%.2f', Result1) ..'k')   -- The calculation in the channel.
    HudUpdate() 																 						  -- Updating the HUD values.
    end
    	
    -- Channel
    CalculatorChannel = Channel.Open('Calculator', onSpeak, onClose)
    function ProcessDebugMessage(speaker, message)
    		CalculatorChannel:SendOrangeMessage(speaker, message)
    	end
    
    ProcessDebugMessage('Calculator', 'Type a figure to multiply with '..rate..' ')
    ProcessDebugMessage('Calculator', 'Type "w" to continue counting a winning streak')
    
    registerNativeEventListener(EVENT_SELF_CHANNELSPEECH, 'onChannelSpeak')
    onChannelSpeak = function(channel, message)
    	local message = message:lower()
    	if message == "w" then
    		if win ~= nil then
    			ProcessDebugMessage(''..c..' ['..level..']', ''..message..'')
    			winresult = win * rate
    			win = win * rate
    			print(''..winresult..'k')
    			HudUpdate()
    			
    			ProcessDebugMessage('Calculator', ''.. string.format('%.2f', winresult) ..'k')
    		else
    			ProcessDebugMessage(''..c..' ['..level..']', ''..message..'')
    			print('There is nothing to multiply with '..rate..'')
    			ProcessDebugMessage('Calculator', 'There is nothing to multiply with '..rate..'')
    		end
    	elseif message ~= string.match(message, '%a+') and message > "0" then
    		ProcessDebugMessage(''..c..' ['..level..']', ''..message..'')
    		f = message
    		multi(f)
    	elseif message == string.match(message, '%a+') then
    		ProcessDebugMessage(''..c..' ['..level..']', ''..message..'')
    	end
    end
    
    level = Self.Level()
    c = Self.Name()
    
    -- HUD -----------------------------------------------------------------------------------------------------------------
    local HUDTitle = HUD.CreateTextDisplay(66, 32, "Most recent calculation", 255, 255, 255)
    
    
    local HUDData = {}
    local data = {}
    data.update = ""
    data.label = HUD.CreateTextDisplay(66, 46 , data.update, 225, 225, 225)
    HUDData = data
    
    function HudUpdate()
    	local update = string.format('%.2f', win)
    	HUDData.label:SetText(update)
    end
    
    -- Auto-Calculation ----------------------------------------------------------------------------------------------------
    oldValue = 0
    start = 0
    Module.New('MoneyCounter', function(mod)
    if start == 0 then
    oldValue = Self.ItemCount(3043)
    start = 1
    end
    newValue = Self.ItemCount(3043)
    	if oldValue ~= newValue then
    		count = newValue - oldValue
    		if not (newValue < oldValue) then
    			Result2 = ''.. count * rate * 10 ..'k'
    			win = count * rate * 10
    			print(''..Result2..'')
    			ProcessDebugMessage('Calculator', ''..Result2..'')
    			HudUpdate()
    		end
    		oldValue = Self.ItemCount(3043)
    	end
    	mod:Delay(50)
    end)
    print("Successfully loaded the script.")
    2083ee2dceb4e4ba4866a78e5a48a8d7.png
    Last edited by yompa93; 04-29-2016 at 12:31 PM.

  3. #3
    Lifetime Subscriber Sheradial's Avatar
    Join Date
    Apr 2015
    Posts
    165
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Really nice idea!


  4. #4

    Join Date
    Nov 2014
    Location
    Sundsvall, Sweden
    Posts
    174
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Sheradial View Post
    Really nice idea!
    Thank you!

  5. #5

    Join Date
    Jan 2014
    Posts
    183
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Use string.format('%.2f', message), because Your code is like 5021521.5210521521521521521521521521K
    Didnt used/tested that just looked on code and saw that numbers XD
    Thats just my proposal.

  6. #6

    Join Date
    Nov 2014
    Location
    Sundsvall, Sweden
    Posts
    174
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kamilqq View Post
    Use string.format('%.2f', message), because Your code is like 5021521.5210521521521521521521521521K
    Didnt used/tested that just looked on code and saw that numbers XD
    Thats just my proposal.
    I totally agree, i'm not sure how to use that bit of code though. I'm just learning right now
    Will do some research, thanks

    EDIT:
    Done formatting the string
    Last edited by yompa93; 04-29-2016 at 12:32 PM.

Posting Permissions

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