Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: Need SIMPLE file format that includes plain text + embedded commands?

  1. #1

    Need SIMPLE file format that includes plain text + embedded commands?

    Hi all,
    for my game The Probe I am wanting to make some simple text files that include these features:

    1. plain text for messages
    2. some simple formatting like setting colour of some of the text, and end of line markers; "\n" perhaps?
    3. can embed names of images so I can display text with images in them, like if I refer to one of the objects in the game I can use text + image.

    The way I figure it, I could load the text file, parse it to break it down into it's component parts (or elements), and then when it comes to displaying it, 'execute' each element so it does it's thing - sets some formatting, draws text, etc.

    Any ideas?

    I could roll my own, maybe use something like XML, or some other system.

    Possible XML Example:

    Test File.txt

    This is some normal text and some <red>red text</red>.<crlf/>and this <blue> text is on a new line</blue>! and now here is an image example <img filename="test.png"/> too
    hmm...I'm not sure if that is going to work so well somehow though as XML usually needs to have open/close pairs of commands.

    Maybe some thing self-created like this?

    \n = new line
    \$RRGGBB = colour change (2 hex digits per colour part)
    \i = image name
    \fdd = font size change (2 digits)

    Line one\nline two and an image \i"probe.png". Also some \$FF0000red\$000000 text Here is some \f12size 12 text\f08
    cheers,
    Paul
    Games:
    Seafox


    Pages:
    Syntax Error Software itch.io page

    Online Chess
    http://gameknot.com/#paul_nicholls

  2. #2
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Re: Need SIMPLE file format that includes plain text + embedded commands?

    You could to all out and use XML or something similar, but if I were to make this text/script for something like how you would use it, I'd probably make my own standard and parser for it.

    You could take the tag concept of HTML and simply have it token-ize blocks and the parser will act as a state machine, kinda like so...

    Code:
    <text>Some text</text>
    <color>color name or RGB(A) value</color>
    Line1<br>Line2
    <img>texture_or_image_name</img>
    
    ...or for the more complex content generation...
    
    <text-x>x location of text drawing</text-x>
    <text-y>y location of text drawing</text-y>
    <draw-x>x location of image drawing</draw-x>
    <draw-y>y location of image drawing</draw-y>
    <draw-r>set red color offset for image drawing</draw-r>
    <draw-g>set green color offset for image drawing</draw-g>
    <draw-b>set blue color offset for image drawing</draw-b>
    <draw-a>set alpha offset for image drawing</draw-a>
    <reset>set attribute to default value</reset>
    I think you get the idea. You could make it as complicated or as simple as you need. If you want the parser to allow only 1 image and 1 text block, (sort of like a standard character dialog box) you could have it ignore extra text or img blocks to safeguard the parser from tripping up.

    If you have a few different display 'templates' or configurations you want to use on screen, you could send some values to the parser before you assign the text/script to display your next script.

    For example if you wanted to have these displays:

    - A character dialog box with 1 image and 1 text block you could put...

    Code:
    // set_dialog_display(num of images, num of text blocks)
    set_dialog_display(1,1);
    - A player stats display box with 2 images and 2 text displays you could instaed put...

    Code:
    set_dialog_display(2, 2);
    You then have to make your game draw each display based on which one you picked, and so on...
    Jason McMillen
    Pascal Game Development
    Co-Founder





  3. #3

    Re: Need SIMPLE file format that includes plain text + embedded commands?

    Thanks for the feed back WILL

    I am thinking to use the text format + parser to do some horizontally scrolling credits with text, and maybe some images.

    I also want to fill windows in-game with text and/or images too, so I don't think I will need any specific location stuff in the format.

    I am planning on just filling up the dialog with the image(s) and text, and wrapping the text around at the edges.

    cheers,
    Paul
    Games:
    Seafox


    Pages:
    Syntax Error Software itch.io page

    Online Chess
    http://gameknot.com/#paul_nicholls

  4. #4
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Re: Need SIMPLE file format that includes plain text + embedded commands?

    Ah, so you're likely to make sort of a 'simple' documentation format and display engine then? Such as an HTML or .DOC standard for example.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  5. #5

    Re: Need SIMPLE file format that includes plain text + embedded commands?

    I'd just take XML and use that. You can have a look at HTML to see how formatting is done. The benefit is that you can use an existing XML parser to save time.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  6. #6

    Re: Need SIMPLE file format that includes plain text + embedded commands?

    or you can write a high level layer to control what you need to:

    ScrollText(...)
    DisplayDialog(...)
    GetInput(...)
    etc.

    Then expose those high level routines to the scripting system and you have lots of control and flexibility. HGE allows for Pascal, Basic and JavaScript syntax. Compilation is fast and you have the added advantage of x86 execution. Not only that but you can use any of the language constructs offered by each language, even mix and match them.

    And if you choose to use XML, see the XML_XXX routines in HGE.

    Just offering one more option that maybe helpful.
    Jarrod Davis
    Technical Director
    Hadron Game
    http://hadrongames.com

  7. #7

    Re: Need SIMPLE file format that includes plain text + embedded commands?

    How about creating something similar to BBCode?

  8. #8

    Re: Need SIMPLE file format that includes plain text + embedded commands?

    Quote Originally Posted by Hadron Games
    or you can write a high level layer to control what you need to:

    ScrollText(...)
    DisplayDialog(...)
    GetInput(...)
    etc.

    Then expose those high level routines to the scripting system and you have lots of control and flexibility. HGE allows for Pascal, Basic and JavaScript syntax. Compilation is fast and you have the added advantage of x86 execution. Not only that but you can use any of the language constructs offered by each language, even mix and match them.

    And if you choose to use XML, see the XML_XXX routines in HGE.

    Just offering one more option that maybe helpful.
    Thanks for the info Jarrod, I will look into those options

    cheers,
    Paul
    Games:
    Seafox


    Pages:
    Syntax Error Software itch.io page

    Online Chess
    http://gameknot.com/#paul_nicholls

  9. #9

    Re: Need SIMPLE file format that includes plain text + embedded commands?

    Quote Originally Posted by Brainer
    How about creating something similar to BBCode?
    hmm...BBCode? I hadn't thought of that, that might just be the ticket

    Thanks Patrick!

    cheers,
    Paul
    Games:
    Seafox


    Pages:
    Syntax Error Software itch.io page

    Online Chess
    http://gameknot.com/#paul_nicholls

  10. #10

    Re: Need SIMPLE file format that includes plain text + embedded commands?

    You can base your code on this parser.

    Hope it helps.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •