LibUtils

This project has become inactive.

This project is inactive and its default file will likely not work with the most recent version of Warhammer Online: Age of Reckoning. The author may have abandoned it, or it may have outlived its usefulness.

Description

A simple library providing some commonly used utility functions. This library solves the problem of reading and writing to a file for communication with an external program!

Reporting Bugs

Post Bugs HERE

Requirements

LibCereal-1.0 must be installed.

Function Documentation

LibUtils.Chat( text ) / Chat( text )

Description

Sends a line of text to the primary chat window.

Parameters

text - A line of text in either string or wstring format.

Returns

Nothing

LibUtils.Dbg( text ) / dbg( text )

Description

Sends a line of text to debug window.

Parameters

text - A line of text in either string or wstring format.

Returns

Nothing

LibUtils.Dump( lua_object, label ) / Dump( lua_object, label )

Description

Prints out the lua_object in string format to the Chat window. It uses the chat window rather than the debug window because the debug window truncates the output.

Parameters

lua_object - Any lua object

Returns

Nothing

LibUtils.LoadFile( filename )

Description

Loads and de-serializes the contents of a file created by LibUtils.SaveFile()

Parameters

filename - The name of the file to load.

Returns

A single Lua object

LibUtils.PlayerName()

Description

Determines the name of the current character.

Parameters

none

Returns

A string containing the name of the current character.

LibUtils.SaveFile( filename, lua_object )

Description

Stores a single lua object (such as a table or a string) to the named file.

Parameters

filename - The filename to write to. lua_object - The object to be stored.

Returns

Nothing

LibUtils.SendCommand( cmd )

Description

Causes a single slash command to be executed. For example, "/target maudib"

Parameters

cmd - Either a string or widestring to be executed.

Returns

Nothing

LibUtils.StrJoin( ) / strjoin()

Description

Parameters

Returns

LibUtils.StrSplit() / strsplit()

Description

Parameters

Returns

You must login to post a comment. Don't have an account? Register to get one!

  • 3 comments
  • Avatar of Master_Jochen Master_Jochen Fri, 24 Apr 2009 22:49:54

    Ok i got for other coders a example for Delphi to convert in standart delphi can read If this post is not ok please erase it. Ps: i searched very long to find it.

    procedure TForm1.Timer2Timer(Sender: TObject);
    var
      F: TStream;
      UnicodeString: WideString;
      UnicodeSign: Word;
      FileName: string;
      FileSize: Cardinal;
    begin
      FileName :=edit1.text;
      F := TFileStream.Create(FileName, fmOpenRead);
      try
        FileSize := F.Size;
        if FileSize >= SizeOf(UnicodeSign) then
        begin
          F.ReadBuffer(UnicodeSign, SizeOf(UnicodeSign));
          if UnicodeSign = $FEFF then
          begin
            Dec(FileSize, SizeOf(UnicodeSign));
            SetLength(UnicodeString, FileSize div SizeOf(WideChar));
            F.ReadBuffer(UnicodeString[1], FileSize);
            // now UnicodeString contains Unicode string read from stream
            Memo2.Lines.Text := UnicodeString;
          end
          else
            // not a Unicode format;
            Memo2.Lines.LoadFromFile(FileName);
        end;
      finally
        F.Free;
      end;
     // REading memo2 here
    end;
    
  • Avatar of multox multox Sat, 20 Dec 2008 06:18:20

    Hi Fishmouth,

    UTF-16 LE means UTF-16 in the Little Endian format, which is the format that x86 processors use. UTF-16 is a unicode standard and you should be able to read/write this file using fixed-width wide character representations in most programming languages.

    Many applications support this format. Most likely, the application that you're using is trying to read the file in UTF-8. For an example, try reading the file with notepad.exe. Notepad is able to read and write the file correctly. (At least on my Vista 64 machine.)

    Please note that if you write data to the file from an external application, then it will need to be in the serialized format required by LibCereal-1.0. For an example, try hard-coding the data into your mod first, then saving it to see the format that it should be in.

    If I am misunderstanding or could use any more help, please let me know.

    Sincerely, Multox

  • Avatar of fishmouth fishmouth Tue, 16 Dec 2008 15:03:18

    (excuse my englisch) In your documentation of LibUtils you said: "-- - We can easily communicate with external applications."

    But i figured out, that this isnt that easy. If you look closely at the asdfasdf.txt created by the LibUtils.TestSaveLoad function in an Hex-Editor, you see that it is using the UTF-16 LE (LE!) character set, that means the first four hexadecimal chars of the file are FFFE and the hex-chars 3 and 4 of every following Letter in the txt are always 00 (so an "a" is 6100 in hex). The Problem is, that txts created by other applications use another character set and LibUtils.LoadFile/WAR cant read it. (because of the missing FFFE and xx00 hex). Any idea to force applications in general to save in UTF-16 LE? (maybe through an externat application?)

    So long LibUtils can only read txts created by itself.

    greetings fishmouth

  • 3 comments