The most useless script ever! Nobody uses binary! This trigger makes it so when Player 1 enters a number in chat, it sends a text message containing that number in BINARY!
JASS:
function Trig_Binary_Conversion_Actions takes nothing returns nothing
local string s = GetEventPlayerChatString()
local integer n = S2I(s)
local real init = 1
local string binaryconv = "1"
loop
exitwhen n/init >=1 and n/init < 2
set init = 2 * init
endloop
set n = ModuloInteger(n,R2I(init))
set init = init /2
loop
exitwhen init == .5
if n/init >= 1 then
set binaryconv = binaryconv + I2S(1)
set n = ModuloInteger(n,R2I(init))
else
set binaryconv = binaryconv + I2S(0)
endif
set init = init /2
endloop
call DisplayTextToPlayer(Player(0), 0.,0., binaryconv)
endfunction
//===========================================================================
function InitTrig_Binary_Conversion takes nothing returns nothing
set gg_trg_Binary_Conversion = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_Binary_Conversion, Player(0), "", false )
call TriggerAddAction( gg_trg_Binary_Conversion, function Trig_Binary_Conversion_Actions )
endfunction