HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Can you put a carriage return in a string?

10-01-2003, 10:04 PM#1
Ligature
Er.. the title says it all, really. I'm trying to get a unit's transmission to change dynamically, so I'm setting it to display a string. But I'd like to include a line break... so unless there's some kind of <br> tag to put in a string... Heh, that would be nice...

Anyone know how to do this?
10-01-2003, 10:07 PM#2
FyreDaug
Ofcourse there is! If you were to look at Blizzard's unit strings and what not, you would have seen the code, but not many people look for things like that.

But the code you are looking for is
Code:
|n

I don't know what the n stands for, but whatever, it works :p
10-01-2003, 10:14 PM#3
Ligature
Huh... when I was looking through the UI strings, I seem to remember there being just ordinary line breaks in the text file that seemed to work as such... Ah well.

Thanks muchly.

// Ligature
10-01-2003, 10:37 PM#4
Supra God CrK
hehe ok i'm noob and i don't really understand what you guys are talking bout. i think you guys mean how to stop the transmission and than pause a while than play the rest or something along those lines. could you please explain better because i would like to know how to do whatever it is ur doing. i am trying to learn everything i can even if i don't need it.
10-01-2003, 11:25 PM#5
weaaddar
Some strings won't accept the |n charachter if that doesn't work as of jass 1.03
you can just go
Code:
set str="My string needs a carraige return

So I'll do it haha!"
worthlessly cool wouldn't you agree?
10-01-2003, 11:45 PM#6
Ligature
Weaaddar - I dunno, when I'm entering data for a string variable in WorldEditor, when I press "enter" it hits the "OK" button. Maybe you could copy and paste from a text editor, but for now I'm sticking with the |n.

[edit] Oh whoops you meant using custom script... Heh. Haven't gotten there yet!

Supra God - I was just trying to find out how to put a line break in a string... so say I wanted to display this text in a transmission:

Hello
World

I could do it by setting a string to "Hello|nWorld" and displaying that string.

Make sense?
10-02-2003, 01:26 AM#7
Raptor--
Quote:
I don't know what the n stands for, but whatever, it works :p

'n' most likely stands for "new line" or "next line"
10-02-2003, 01:33 AM#8
Ekkruker
Or it might not mean anything and it could just be a symbol...

Hey I want to learn WC3 JaSS but I don't know where to start, anyone know a good beginners tutorial?
10-02-2003, 01:38 AM#9
weaaddar
Really its like any other programming language. If you know one you can easily pick up jass and get over its a bit odd syntax. (No ;, instead you have a call after each line).
I would suggest looking at common.j and blizzard.j they list all the functions i'm sure there are sites that comment what they do but eh...
10-02-2003, 01:38 AM#10
Ligature
From what I've heard, the best way to teach yourself Jass is to write a trigger that you understand, then convert it to custom script and follow along. Kind of a build-your-own-tutorial...
10-02-2003, 01:57 AM#11
Mr.Obliteration
Really if you know any programming language, or even a scripting language such as javascript, learning jass will take you no time at all. The main differences from javascript are that functions use endfunction and such as opposed to an }, you have to declare variable types, and you do not end lines (this is a hard habit to overcome :) ) .

And remember if you don't know how to do something, just make a trigger and convert it to text or look through the .j files as weaaadar said.

If you are new to programming, there are many good tutorials out there.

BTW, weaadar: your avatar makes me happy!!!
10-02-2003, 02:01 AM#12
Ekkruker
I know a wee bit of "C" from neverwinter nights(the worst game EVER) and I know perfect Morrowind(the best game EVER) Script ;)

So you don't end lines? Are you sure? Thats going to be annoying, but Ill try it, thx..
10-02-2003, 02:09 AM#13
Ekkruker
AGH

Someone disect this for me so I might understand it...

this used to be a

Event: A unit dies
Action: Replace <triggering unit> with (unit type of<triggering unit>) using the (new units max life and mana)

and turned it to custom text and it became this...

Code:
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
    call ReplaceUnitBJ( GetTriggerUnit(), GetUnitTypeId(GetTriggerUnit()), bj_UNIT_STATE_METHOD_MAXIMUM )
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_001 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Untitled_Trigger_001, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
endfunction
10-02-2003, 02:27 AM#14
Mr.Obliteration
Alright...



call TriggerRegisterAnyUnitEventBJ( gg_trg_Untitled_Trigger_001, EVENT_PLAYER_UNIT_DEATH )

^---- Basically, this is the event. An unit dies and runs the function below.


function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
call ReplaceUnitBJ( GetTriggerUnit(), GetUnitTypeId(GetTriggerUnit()), bj_UNIT_STATE_METHOD_MAXIMUM )
endfunction


This function is takes nothing returns nothing says it is a void function, no args and no return.
This calls the function ReplaceUnitBJ with arguments of the triggering unit for unit to replace, GetUnitTypeId(GetTriggerUnit()), to get the type of unit to replace with, bj_UNIT_STATE_METHOD_MAXIMUM makes it have maximum life. This is all your really need to know to write a bit of jass.