Logging messages (SOLVED)

Started by stuh505, Mon 07/03/2005 00:52:43

Previous topic - Next topic

stuh505

I would like a plugin that allows me to handle text in a chat-log type system.

Aka,  everything that is said in conversation is added to the log...and they can scroll up to read past comments.

IF you still don't know what I'm talking about, think NWN, Baldur's Gate, etc.

scotch

I don't think a plugin for that exists.  You could actually do this quite easily in script, by making a custom speech displaying function that writes the lines into a global array, as well as displays the speech.  If you don't know how to do that then perhaps someone will write it (or come up with a better way).

stuh505

I know how to write the code, but I'm not sure how it could be done in AGS.

It would certainly use up too many overlays to do it graphically.

I suppose maybe a GUI with a listbox could be used (duh)...well I'll look into it more.

scotch

Well, you'd make an array, of 200 strings, or however long you wanted it to be, along with an int, keeping track of your position in the array.  Make a function called displaySpeechRecorded(int charid, string line);  Give it a body with something like "positionint++; if(positionint==200) positionint=0; speechArray[positionint] = line; DisplaySpeech(charid, line);" in it

In your game you'd use that function instead of the usual DisplaySpeech, unless you didn't want it to be recorded.
speechArray would contain the last 200 lines spoken then, going backwards from speechArray[positionint], wrapping around to the array size-1 at 0.  You could, with that, make a GUI that has code to display the last X lines, with scroll buttons.

If you wanted you could add something in that function to write out the text into a file, as well.  For long term recording of speech.

stuh505

Yep.  Sounds pretty easy now.  I just had forgotten that we had list boxes already to work with heh

Pumaman

I was thinking about some sort of on_event_always function, which could be called for events like StartDialog, ENdDialog, StartDisplaySpeech, EndDisplaySpeech, etc and let you handle these things better in the script. That might be the cleanest long-term solution to this sort of thing.

stuh505

I'm not exactly sure what you mean...but this does seem like a feature that could be used in a lot of games and be worthwhile to have built in, if that's what you're suggesting.

stuh505

So what will happen in my game if I just let this message list grow?  I didn't run into any problems in testing but I didn't play a long game either :P  I can easily put a cap on it but I'm curious if there is a built in cap, or if eventually the game will just crash, or if it will keep running fine forever.


SMF spam blocked by CleanTalk