Texts Library Beginner's Guide?

Language: JP EN DE FR
New Items
2018-08-14
users online
Forum » Windower » Support » Texts Library Beginner's Guide?
Texts Library Beginner's Guide?
Offline
By NiroAL 2018-12-03 01:34:57
Link | Quote | Reply
 
Hi everyone. I'm looking to try and start using the texts library to make some status displays in FFXI. I want to be able to track what ailments and buffs my character has in a seperate window. I know that there are addons or plugins that might have this functionality, but I'm interested in learning to do it myself.

However, my main problem is, as a total beginner to programming, I have no idea where to start. I've tried looking at other addons that utilize the texts library and reverse engineering their functionality, but most of the time I just end up confused. I also can't find very much documentation or any tutorials on how to use the library.

Are there any resources that anyone knows of that can help me out? Any help getting me started with the texts library would be greatly appreciated. Thank you so much!
 Bahamut.Shozokui
Offline
Server: Bahamut
Game: FFXI
user: Shozokui
Posts: 69
By Bahamut.Shozokui 2018-12-03 07:37:30
Link | Quote | Reply
 
The texts library is simple. The place where you're going to get hung up if you're a "total beginner" is going to be enumerating your buffs and determining which are buffs/debuffs. Spoiler alert, the game just considers everything a buff.

Creating a new text box and showing it
Code
settings = config.load('data\\settings.xml',default_settings)
box = texts.new('${current_string}', settings.text_box_settings, settings)
box.current_string = ''
box:show()


Setting text of a specific box
Code
box.current_string = txt



Storing your text box configuration in an xml file in data/settings.xml
Code
<?xml version="1.1" ?>
<settings>
    <global>
        <text_box_settings>
            <bg>
                <alpha>125</alpha>
                <blue>0</blue>
                <green>0</green>
                <red>0</red>
                <visible>true</visible>
            </bg>
            <flags>
                <bold>false</bold>
                <bottom>false</bottom>
                <draggable>true</draggable>
                <italic>false</italic>
                <right>false</right>
            </flags>
            <padding>10</padding>
            <pos>
                <x>1583</x>
                <y>349</y>
            </pos>
            <text>
                <alpha>255</alpha>
                <blue>255</blue>
                <font>Consolas</font>
                <fonts>

                </fonts>
                <green>255</green>
                <red>255</red>
                <size>12</size>
                <stroke>
                    <alpha>255</alpha>
                    <blue>0</blue>
                    <green>0</green>
                    <red>0</red>
                    <width>0</width>
                </stroke>
            </text>
        </text_box_settings>
    </global>
</settings>
[+]
Offline
By NiroAL 2018-12-04 00:49:57
Link | Quote | Reply
 
Thank you so much! This will be a great jumping off point for me. If it's not too much trouble, could you run me through your code and explain your syntax to me? Or is there some documentation for the texts library I can read somewhere?

Either way, thanks so much!
 Bismarck.Xurion
Offline
Server: Bismarck
Game: FFXI
user: Xurion
Posts: 140
By Bismarck.Xurion 2018-12-04 05:24:40
Link | Quote | Reply
 
I recommend looking into the Windower Github wiki: https://github.com/Windower/Lua/wiki. There's a lot of documentation available there.

Here's a brief line-by-line explanation of an addon example that creates a text box and displays your inventory space.
Code
--The name of your addon
_addon.name = 'Inventory Space'
--You (any format you want for this - this is just what I put)
_addon.author = 'Dean James (Xurion of Bismarck)'
--Current version of this addon. If you want to version "properly", look up semantic versioning
_addon.version = '1.0.0'

--This library generates text boxes
texts = require('texts')
--This library handles loading/saving configuration (the XML file in data/settings.xml)
config = require('config')

--These are the default settings we want
default_settings = {
  bg = {
    alpha = 75
  },
  padding = 3
}
--The first time we execute config.load, the data/settings.xml file is auto generated with the default_settings
settings = config.load(default_settings)
--Here we create a text box using the texts library. We tell it to use the settings that have been fetched or auto generated
--The texts library will now add additional configuration to the XML file
text_box = texts.new(settings)

--This is an event we tell Windower to execute at a certain point. In this case, it is when the addon loads
--There are a number of events that can be set. Check out: https://github.com/Windower/Lua/wiki/Events
windower.register_event('load', function()
  --Use windower.ffxi.get_items().inventory to get info about your inventory
  local inventory = windower.ffxi.get_items().inventory
  --Use the inventory info to generate text that will be soming like "64/80"
  local new_text = inventory.count .. '/' .. inventory.max
  --Use the :text function to set the text
  text_box:text(new_text)
  --Use the :visible function to set the text box to visible
  text_box:visible(true)
end)


I'll assume you know how to put this into your addons directory etc. and load it. When you do, it'll appear at the very top left of the UI because we haven't set it to be any different (most text-based addons do this).

You can now drag the text box around, and as you do, the texts library automatically saves the new position in the settings.xml file.
[+]
Offline
By NiroAL 2018-12-04 06:28:14
Link | Quote | Reply
 
Thank you so much! This is perfect. I'm going to mess with it later on.

I really appreciate the help!
 Bismarck.Xurion
Offline
Server: Bismarck
Game: FFXI
user: Xurion
Posts: 140
By Bismarck.Xurion 2018-12-04 07:08:51
Link | Quote | Reply
 
No worries. Another thing I forgot to mention is the texts library (as well as others) can be found in addons\libs\texts.lua.

You can browse all the functions available there. Good luck!
Log in to post.