PDA

View Full Version : Hello World



Taboen
11-22-2007, 04:53 AM
Right so all I have is UT2004 scripting tutorials and I thought lets start with the first one again for UT3. Hello World!

But its giving me an error and I really don't have enough experience to know what it could be.


class HelloWorld extends Commandlet;

function int Main(string Args)
{
log("=========");
log("Hello World");
log("=========");
return 0;
}

When I 'ut3 make' it, it says: Error, 'log': Bad command or expression.
Apparently the command log has changed.
Now with UT3, is there going to be a list of all changes?

Jrubzjeknf
11-22-2007, 05:07 AM
Try LogInternal().

Taboen
11-22-2007, 06:09 AM
Ok thanks.

Gugi
11-22-2007, 08:02 AM
yep, you need to use LogInternal instead of Log and WarnInternal instead of Warn.
You can find this out by looking at the Object-class.

Dunno why, but in this Object-class Epic suggest to use the (not existing) macro "log" instead of LogInternal xD

Kohan
11-22-2007, 10:35 AM
What may be a good idea is heading on over to the Unreal Wiki and converting some of the simpler scripting examples over to UScript 3 (preserving the original, of course). This would help to build a base of UT3 scripting tutorials.

Daishonin
12-07-2007, 10:31 PM
Hi,

Noob question here. When I call LogInternal...


LogInternal("Hello World!");

... where should I expect to see that? I created a Hello World mutator, started up UT3, enabled my mutator and loaded a level expecting to see it output "Hello World!" somewhere, but didn't see any text anywhere. Is there some other app this displays in? Do I have to have my Unreal editor open as well? (My comp crashes when I try loading UT3 while my editor is open, I guess I need more memory!)

If this is not the command to display lines of text to the player in UT3, what command is that?

Thanks!

Pfhoenix
12-07-2007, 10:48 PM
It's not non-existant.

All macros in UnrealScript start with `, so `log() is what you should be using. You can define your own macros as well.

Daishonin
12-08-2007, 12:10 AM
Where does it get logged to?

Xyx
12-08-2007, 05:36 AM
You can define your own macros as well.
How does that work?

This wasn't in Epic's "what's new in uscript" list. Would you happen to know of any other undocumented additions?

Pfhoenix
12-08-2007, 08:28 AM
I don't know why it wasn't; macros can be incredibly handy.

`define foo bar;

then call `foo for wherever you want bar to show up (like pre-processor defines from C/C++). You can combine/nest macros, as well.

bez
12-08-2007, 09:22 AM
Where does it get logged to?

it logs to your log
Right click on your ut3 shortcut and select properties then add
-windowed -log
to the end

when playing you should see your log in background

Daishonin
12-08-2007, 03:28 PM
Ohh there's a -log flag... Perfect, that's what I was looking for, thank you very much! I've since discovered it also writes the log here: My Documents\My Games\Unreal Tournament 3\UTGame\Logs\Launch.txt

I'm still struggling with my first mutator, "Hello World". I have more questions:

1. How can I specify the name & description of my mutator (to appear to the player in Unreal's Mutators menu) in my .uc script (when I tried adding them to my defaultproperties section, it gave me syntax errors on compile). Surely you don't HAVE to manually edit the .ini config?


FriendlyName=Hello World
Description=My "Hello World" mutator.

2. Why is my log complaining:


ScriptLog: Mutators MutHelloWorld.HelloWorld
Warning: Failed to load 'Class MutHelloWorld.HelloWorld': Failed to find object 'Class MutHelloWorld.HelloWorld'

Here is my very simple mutator (with a call to both `log and LogInternal in hopes of having either one of them work):

My Documents\My Games\Unreal Tournament 3\UTGame\Src\MutHelloWorld\Classes\HelloWorld.uc


class HelloWorld extends UTMutator;

function PostBeginPlay()
{
Super.PostBeginPlay(); // Run 'Mutator.PostBeginPlay'
LogInternal("Hello World 1");
`log("Hello World 2"); // `log is a macro that calls LogInternal.
}

defaultproperties
{
GroupNames(0)="Hello World from Daishonin!"
}

3. What does GroupNames do?

4. Is there a way of printing a line of text to the player in-game?

Thanks!

Daishonin
12-08-2007, 03:54 PM
#2 is resolved (I wasn't using the -useunpublished flag -- Unreal was adding my mutator to the menu because it found the config ini, but couldn't find my .u package because i hadn't published it). Thanks to this thread http://forums.epicgames.com/showthread.php?t=584867

I'd still love answers to the other questions. :)

SwaTz0rs
12-08-2007, 04:38 PM
3: i think you can give it a group name so no other mutator which has the same group name can be started.. for compatibility reasons..

bez
12-08-2007, 04:58 PM
4. Is there a way of printing a line of text to the player in-game?


add this
then when in the game type in the console mutate amIworking



function Mutate(string type, PlayerController say)
{
if(type~="amIworking")
{
say.ClientMessage("yes im working"); ////////// prints to screen .....
LogInternal("yes im working"); ////////// prints to log .......
}
}

Bonehed316
12-08-2007, 07:40 PM
And you can put macros one multuple lines, as in C++ using the \, but the output of the macro wont be on a new line, unless you add the newline manually, with \n.

This is another reason why epic should put out a code drop, because 'log is used unanimously, but probably exports as LogInternal, due to preprocessing.

There are tons of undocumented features. ;)

Xyx
12-08-2007, 08:28 PM
3: i think you can give it a group name so no other mutator which has the same group name can be started.. for compatibility reasons..
Quite. It'd be nice if there were some standardization in group names, though.