Warcraft III resources & community, 2003–2006 · archived

text.print [UPDATE!]

not rated
Submitted by bugmakerFunctions0 downloads
This small function who print the text on screen like sci-fi.
I hope you see that =)
Enjoy...

Source

// autor - bugmaker
// 
// globals:
// udg_cache - game cache
//  
// to call func enter (call text_print (PLAYER_NUM, "TEXT", X, Y, PERIOD, TIMER{its depend from period}, SOUND_ID)
// 
// to register sounds don't forget call to func:
// call TxtRegisterSound ("SND_text_print", "war3mapimported\\sound name.wav") 
//
// just don't forget to add this func to init trigger (set udg_cache = InitGameCacheBJ( "MapName.w3v" )) to decleare cache variable
//
//example: call text_print (1, "TextTextTextTextText", 0.45, 0.75, 0.08, 50, 1)
//
// CUSTOM MAP SCRIPT:

function H2I takes handle h returns integer
    return h
    return 0
endfunction
 
function set_object_iparam takes handle h, string key, integer val returns nothing
    call StoreInteger(udg_cache, I2S(H2I(h)), key, val )
endfunction
 
function get_object_iparam takes handle h, string key returns integer
    return GetStoredInteger(udg_cache, I2S(H2I(h)), key)
endfunction
 
function set_object_rparam takes handle h, string key, real val returns nothing
    call StoreReal(udg_cache, I2S(H2I(h)), key, val )
endfunction
 
function get_object_rparam takes handle h, string key returns real
    return GetStoredReal(udg_cache, I2S(H2I(h)), key)
endfunction
 
function set_object_sparam takes handle h, string key, string val returns nothing
    call StoreString(udg_cache, I2S(H2I(h)), key, val )
endfunction
 
function get_object_sparam takes handle h, string key returns string
    return GetStoredString(udg_cache, I2S(H2I(h)), key)
endfunction
 
function flush_object takes handle h returns nothing
    call FlushStoredMission(udg_cache, I2S(H2I(h)))
endfunction

function set_cfg takes string key, string val returns nothing
   call StoreString(udg_cache, "Sconfig", key, val)
endfunction

function get_cfg takes string key returns string
   return GetStoredString(udg_cache, "Sconfig", key)
endfunction
function TxtRegisterSound takes string key, string val returns nothing
   local string count = I2S(S2I(get_cfg("TxtSoundCount")) + 1)
   call StoreString(udg_cache, "SndList", key + "[" + count + "]", val)
   call set_cfg("TxtSoundCount", count)
endfunction

function TxtGetRegisteredSound takes string key, integer num returns string
   return GetStoredString(udg_cache, "SndList", key + "[" + I2S(num) + "]")
endfunction



//	|=======================================\|
//	|print text function			 |
//	|v					 |

function show_prt_text takes nothing returns nothing

local timer tm 			= GetExpiredTimer()
local integer l 		= get_object_iparam (tm, "text_print_l")
local integer i 		= get_object_iparam (tm, "text_print_i")
local integer CurDelay 		= get_object_iparam (tm, "text_print_del")
local integer play 		= get_object_iparam (tm, "text_print_snd")
local integer maxSnd 		= S2I(get_cfg("TxtSoundCount"))
local integer md 		= get_object_iparam (tm, "text_print_tx")
local integer PNum 		= get_object_iparam (tm, "text_print_player")
local integer k 		= 0
local string text 		= get_object_sparam (tm, "text_print_t")
local string txt 		= get_object_sparam (tm, "text_print_tx")
local string snd 		= TxtGetRegisteredSound("SND_text_print", play)
local string Char 		= SubStringBJ(text, i, i)
local string TmpStr 		= ""
local real per 			= get_object_rparam (tm, "text_print_per")
local real x 			= get_object_rparam (tm, "text_print_x")
local real y 			= get_object_rparam (tm, "text_print_y")

if (i > l + CurDelay) then
	call DestroyTimer(tm)
	call flush_object(tm)
else

if (md == 0) then
	set md = 1
	if (i != l + CurDelay) then
		set k = 1
			set TmpStr = " |c0000A596"
		loop
			exitwhen k > 10
				set TmpStr = TmpStr + "|"
			set k = k + 1
		endloop
	else
		set TmpStr = ""
	endif
else
	set md = 0
	set TmpStr = ""
endif

if (play != 0) then
	if (Char != " ") and (i <= l) then
		if (play <= maxSnd) then
			call PlaySound(snd)
		else
			call PlaySound(TxtGetRegisteredSound("SND_text_print", play))
		endif
		
	endif
endif

set text = Char
set txt = txt + text
call ClearTextMessagesBJ( GetPlayersAll() )
call DisplayTimedTextToPlayer (Player(0), x, y, per, txt + TmpStr )

set i = i + 1
call set_object_iparam (tm, "text_print_i", i)
call set_object_iparam (tm, "text_print_tx", md)
call set_object_sparam (tm, "text_print_tx", txt)
endif

endfunction

//==================================

function text_print takes integer PNum, string txt, real x, real y, real period, integer CurDelay, integer Snd returns nothing

local timer tm = CreateTimer()
local integer i
local integer l = StringLength(txt)
local integer t
local string text = ""

set i = 1
call TimerStart(tm, period, true, function show_prt_text)

call set_object_iparam(tm, "text_print_l", l)
call set_object_iparam(tm, "text_print_i", i)
call set_object_iparam(tm, "text_print_snd", Snd)
call set_object_iparam(tm, "text_print_del", CurDelay)
call set_object_sparam(tm, "text_print_t", txt)
call set_object_rparam(tm, "text_print_per", period)
call set_object_rparam(tm, "text_print_player", PNum)
call set_object_rparam(tm, "text_print_x", x)
call set_object_rparam(tm, "text_print_y", y)

endfunction
//	|=======================================/|

Comments

10
How do you get JASS scripts into maps?
I assume you havn't fixed the colors yet?
You know when you see in movies how each letter is printed one by one, this is very cool.
Could you link an example picture into a comment so everyone knows what you mean with "science-fiction-text"

http://i36.photobucket.com/albums/e48/OgeRfaCes/MyLogo.jpg
One bug i noticed was that it processed colour tags as individual letters, so it printed the |ccfff code then the coloured tags followed. Maybe you could try correcting this by printing the colour code as one block when it encounters one.
Wow this is actually quite good. Well since he has trouble explaing it, basically it prints the text you provide as text on screen letter by letter, like in the sci-fi films where you see on the computer monitors the text comes on one letter at a time with a little cursor in front of it.
what do you mean when you say 'sci-fi' text?
Anyways this function wont compile because it is missing the Get_cfg function and Set_cfg function.

Oww i forget about this

Ok ready

Now you may cope all code to custom script code, add following to init trigger:

set udg_cache = InitGameCacheBJ( "MapName.w3v" )
call TxtRegisterSound ("SND_text_print", "war3mapimported\\sound name.wav")
call TxtRegisterSound ("SND_text_print", "war3mapimported\\sound name.wav")
what the hell does it do?

Anyways this function wont compile because it is missing the Get_cfg function and Set_cfg function.
please, describe your opinion about my script.