Tuesday, March 27, 2012

Guide - Text (Images and Variable Replace)

Text is independent of the event system and can be called directly from the game. Though in most cases that is not a good idea as running through the event system allows for custom events interrupting with special text. Most of the time though when modding an event will be calling the text. Just like events text uses a label to know it was called and has lots of customization.

Probably the most important part of text is actually the images. Text is simple images not so much. Images are broken down into 5 locations (bg, fg, fgleft, fgright, and fgcenter.)





Right now the width / height or scale is kept by the fg, fgleft, fgcenter, and fgright and then centered. While the bg is always forced to fit the full screen. I may at a later date make this user choice. If you need this feature please say so.


Next up is how to call the images. There is a nice file by the name of

libs/otherlib/xml/textstories/imagereplace.xml

You don't have to use image replace you can just put in the direct file path to the images folder but I really would appreciate if you did. That way if the image moves we only have to change it once. Also I screw up paths with the wrong .jpg or and an s or what ever so having to put it in once means that its easier to fix and you know where it is. ( I probably shouldn't mention it but you can use the image replace command in any of the text system files... but please don't.)

name = "#realestatebg" -- the label called
file = "shop/realestate/realestatebg.jpg" -- where the image is looking in the image director libs/otherlib/image

That's all there is for image replacement.

Now just as important text replacement... There are two types varreplace where you replace variables and replacer where you replace text.


A variable replacement the gold and a name replacement example.


First off replacer, its damn simple you put in a search and return a replacement. File is

libs/otherlib/xml/textstories/peoplereplace.xml

though it actually works in any of the loaded in text files. But still keep the standards, it saves us from problem like misspelling Setra multiple times and then having to find it over and over and over... not that happened...

xml is so simple no reason to really worry about it.

search = "#showchange" --- what we are searching for
rep = "makechange" --- what we are changing too

Now on to variable replace


So this work exactly the same and is covered in events since they use the same things. No reason to rebuild a wheel. Really modders should probably ask me before adding these as misspellings or even bad capitalization will CRASH THE GAME! That's why I have done dozens already for you guys. File is at...

libs/otherlib/xml/textstories/variablereplace.xml

search = "#gold" -- label we are looking for
rclass = "GameData" -- The class
rep = "charGold" -- The variable in the class
name = "Gold" -- Used by the after points changes more on that in a second.


And there is still another variable replacement. No really on the fly variables those pesky ones made by modders they might want to display those too. Okay now there is a very important rule about these as a matter of fact two.

1) You can't use "#". That's a key word that is a variable replace and if used here crash.... maybe or it won't work.
2) Make sure it's unique or the text editor may end up replacing your variable everywhere.

File is at

libs/otherlib/xml/event/setvariable.xml

Though of course that's a lie it can be added to any EVENT!!! xml file. That's right its not directly part of the text system because there variables created by the event system.

label = "fatiguework" --- the search label
vvar = "33" --- the starting value

Okay just one more type of replacement and that is stat changes. Which is all done internally for I hope are obvious reasons, all you have to do is add the key word, "#showchange".



That was a lot of options and explanations and we still haven't even made a single text fire in the game yet.

Daisy

2 comments:

  1. I'm more and more amazed by the system you have created here! When you're done, you'll have not only created Otherworld, but also a powerful and flexibel framework to build other games.

    I'm sure I don't understand everthing yet, so this suggestion probably doesn't take everything in consideration. However, based on what I currently understand, it seems to me that it's important if a certain XML file belongs to the text system, or to the event system. If that is the case and if(!) almost every XML file can be associated with a certain system, I think it would be a good idea to label the files accordingly.

    Example:
    setvariable.xml is part of the event system. One of the first lines of the file could read:
    {system}event{/system}

    Advantages:
    It would be transparent what can and what can not be done in the file, because this depends on the system used. Also, modders could declare the intended use of their files, which may make handling them easier for Otherworld.

    ReplyDelete
  2. They don't look in the same directory structure on purpous and i doesn't matter about naming though I will probably rename then all some day event or text right now there all named the same

    xml/event/roomjob/cleaingjob.xml

    xml/textstories/roomjob/cleaningjob.xml

    It's something I have though about doing a dozen times and been to lazy.

    Daisy

    ReplyDelete