- Joined
- Oct 2, 2011
- Messages
- 89
I am working on code to have multiboard display various text messages to user. I have decided to try JASS for this and managed to set up everything. Basically the text is set to wrap around the limits of the multiboard. I got the numbers off of taking screenshots of in game and measuring the character width.
that is the code to have everything work, and I made some triggers to test/debug the system.
JASS:
function multiboardinit takes nothing returns nothing
set udg_dia = CreateMultiboard()
call MultiboardSetRowCount(udg_dia,1)
call MultiboardSetColumnCount(udg_dia,1)
call MultiboardSetItemsStyle(udg_dia,true,false)
call MultiboardSetItemsWidth(udg_dia,20)
call MultiboardSetTitleText(udg_dia,"Output")
call MultiboardDisplay(udg_dia,true)
endfunction
function calclen takes string input, integer startchar returns integer
local integer max = 327
local integer len = StringLength(input)
local integer lencount = 0
local integer endchar = startchar
local boolean done = false
loop
set endchar = startchar + 1
if lencount <= max or endchar == len then
//Part I parse string
if SubString(input,endchar,endchar) == "a" or SubString(input,endchar,endchar) == "b" or SubString(input,endchar,endchar) == "c" or SubString(input,endchar,endchar) == "d" or SubString(input,endchar,endchar) == "e" or SubString(input,endchar,endchar) == "h" or SubString(input,endchar,endchar) == "n" or SubString(input,endchar,endchar) == "u" or SubString(input,endchar,endchar) == "k" or SubString(input,endchar,endchar) == "z" then
set lencount = lencount + 8
elseif SubString(input,endchar,endchar) == "2" or SubString(input,endchar,endchar) == "4" or SubString(input,endchar,endchar) == "6" or SubString(input,endchar,endchar) == "8" or SubString(input,endchar,endchar) == "9" or SubString(input,endchar,endchar) == "0" or SubString(input,endchar,endchar) == "g" or SubString(input,endchar,endchar) == "o" or SubString(input,endchar,endchar) == "p" or SubString(input,endchar,endchar) == "q" or SubString(input,endchar,endchar) == "v" or SubString(input,endchar,endchar) == "x" or SubString(input,endchar,endchar) == "y" then
set lencount = lencount + 9
elseif SubString(input,endchar,endchar) == "1" or SubString(input,endchar,endchar) == "f" or SubString(input,endchar,endchar) == "r" then
set lencount = lencount + 5
elseif SubString(input,endchar,endchar) == "i" or SubString(input,endchar,endchar) == " " or SubString(input,endchar,endchar) == "j" or SubString(input,endchar,endchar) == "l" or SubString(input,endchar,endchar) == "(" or SubString(input,endchar,endchar) == ")" then
set lencount = lencount + 4
elseif SubString(input,endchar,endchar) == "3" or SubString(input,endchar,endchar) == "5" or SubString(input,endchar,endchar) == "7" or SubString(input,endchar,endchar) == ">" or SubString(input,endchar,endchar) == "<" then
set lencount = lencount + 7
elseif SubString(input,endchar,endchar) == "m" or SubString(input,endchar,endchar) == "w" then
set lencount = lencount + 13
elseif SubString(input,endchar,endchar) == "." or SubString(input,endchar,endchar) == "," then
set lencount = lencount + 3
elseif SubString(input,endchar,endchar) == "*" then
set lencount = lencount + 6
endif
else
set done = true
endif
exitwhen done == true
endloop
return endchar
endfunction
function writetoboard takes string input returns nothing
local integer startchar = 0
local integer endchar = 0
local integer a = 1
local integer len = StringLength(input)
call MultiboardClear(udg_dia)
call MultiboardSetRowCount(a)
loop
set endchar = calclen(input,startchar)
call MultiboardSetRowCount(udg_dia,a)
call MultiboardSetItemValue(MultiboardGetItem(udg_dia,a,1),SubString(input,startchar,endchar))
set a = a + 1
exitwhen endchar == len
endloop
endfunction
that is the code to have everything work, and I made some triggers to test/debug the system.
-
Untitled Trigger 004
-
Events
- Time - Elapsed game time is 5.00 seconds
- Conditions
-
Actions
- Custom script: call multiboardinit()
-
Events
-
MultiTest
-
Events
- Player - Player 1 (Red) types a chat message containing - as A substring
- Conditions
-
Actions
- Custom script: call writetoboard(GetEventPlayerChatString())
-
Events
Last edited: