PSOBB Addon Plugin (Lua UI addons)

Discussion in 'Tools' started by Eidolon, Dec 11, 2016.

  1. DesertWolf93

    DesertWolf93 Member

    Guildcard:
    42053158
    After searching for why Alt+Tab would cause me to crash while waiting for a reply, I found out that classic fullscreen was my problem and switched to HD HD Hud. That was the magic fix I was wondering about. I never would've thought that to be the issue. Now to conquer Linux!
     
  2. NeonLuna

    NeonLuna amazing

    Guildcard:
    42014519
  3. DesertWolf93

    DesertWolf93 Member

    Guildcard:
    42053158
    Dude, you're a legend. That is probably the one and only post about it on the internet. It fixed my problem immediately. Thank you so much!
     
    NeonLuna likes this.
  4. CageyRabbit

    CageyRabbit Member

    Guildcard:
    42052497
    That's the same post I used to get it running in WINE as well. Between that and the changes that Soly made recently it runs great in Linux now.
     
  5. e_bolavirus

    e_bolavirus Member

    Guildcard:
    42052755
    I'm trying to determine how to color code a tech drop in the floor window to stand out if its a higher level than what i currently have learned, without going into the .lua after each playthrough and updating the table manually. Is there a way to reference what level the tech is with the maximum level i have learned any apply a color variant if true?
     
  6. Soly

    Soly Member

    Location:
    CR
    Well... it is as "easy" as you described it... grab the player data and get the tech levels from it...
    You can see how some player stats are read here https://github.com/Solybum/PSOBBMod-Addons/blob/master/solylib/characters.lua#L81

    You'd have to add a new function (hopefully taking the tech id as parameter) and then returning the level...
    Ofc you'd need the address of the tech level data...

    I'll look into this in the next few days.
     
  7. brionac

    brionac Legendary Partisan

    For anybody that's using the Monster Reader addon, I like to offer a slightly different color of text for Zalure, which is currently a dark blue color that is hard to see in some areas like Gal Gryphon's Lair.

    I haven't tested this new color, Lime Green, in every case yet, but I like to show you what it looks like in this attached image.

    pso132266401454445817.png

    Great, so how do you insert this modification for yourself? Well, with Ctrl + F and some help with the below code, you'll have it too. I have the file's location listed within the Ephinea folder's path, so find that folder first to reach for the init.lua file. There's two places where the modification needs to occur, so I listed them in the code below.

    As you can see in the image, I'm targeting a Booma that has Lv 5 Zalure on it. The top window has one instance of that new color of text being shown, and the list of monsters on the left is the other location where you see the same thing. So this will be easy to view once you read the code where the modifications need to be made to see what I see here. After you edited and saved the file, press Reload in the Main Menu for your addons to see the new color load correctly.

    Code:
    EphineaPSO\addons\Monster Reader\init.lua
    
    local function PresentMonsters()
    -- Get how many columns we'll need
    lib_helpers.TextC(false, 0xFF00FF00, defTech.name .. defTech.level .. string.rep(" ", 2 - #tostring(defTech.level)) .. " ")
    
    local function PresentTargetMonster(monster)
    -- Show J/Z status and Frozen, Confuse, or Paralyzed status
    lib_helpers.TextC(false, 0xFF00FF00, defTech.name .. defTech.level .. string.rep(" ", 2 - #tostring(defTech.level)) .. " ")
    
    The Zalure color was taken from https://convertingcolors.com/android-color-4278255360.html?search=0xFF00FF00
     
    Last edited: Feb 19, 2020 at 9:29 PM
  8. Soly

    Soly Member

    Location:
    CR
    If you have github, feel free to make a PR with the change
    If the other color was hard to read, then I don't see a reason to not change it.
     
  9. e_bolavirus

    e_bolavirus Member

    Guildcard:
    42052755
    ui.png
    I edited my monster reader lua to calculate the optimal techs to use as a force based solely on the enemies resistance. Also added an inventory counter to be displayed on the AIO frame. I need to determine how to calculate better tech usage based on enemy resistance AND current player tech level. Maybe a damage calculation that i can use to compare? ATP is player + ?. DFP is player + 0x2D2. MST is player + 0xE2E. ATA is player + 0x2D4. EVP is player + 0x2D0. LCK is player + 0x2D6.

    An issue i noticed last night though, every encounter with De Rol Le would break my monster reader completely. I forgot to check to log to see what was causing it so i'll have to go back in. I'm not sure if its because of something I may have done or if its a known issue.

    Edit: Solution was found to the De Rol Le issue, i needed to add additional lines to the function CopyMonster. In my arguements to determine what resistance is lowest, it was breaking on De Rol Le because the head was being copied for HP purposes but no additional stats, so when i was checking if Efr <= Eic for example, it was returnin a nil value for both.
     
    Last edited: Feb 21, 2020 at 11:31 AM
  10. Dude

    Dude Member

    Guildcard:
    42020401

    any place I can download your monster reader thingy with the spell weaknesses? Looks super useful
     
  11. NeonLuna

    NeonLuna amazing

    Guildcard:
    42014519
    @Soly i'm trying to switch to your fork of bbmod. i didn't even realize until after i started that you added the ability to use custom fonts - that's something i've wanted for a while! also, the function to list folder contents is really helpful. i have a planned feature for my addon that needs to be able to do that, and the only way i found to do it in lua is a bit clunky.

    i made sure that my addon was in a state where it would at least start before i switched, but it caused the entire game to crash when i tried to run it under your bbmod fork. i was able to narrow it down to an imgui popup. the popup isn't displayed when the addon starts, it only appears when the user clicks a button, but when i commented out the popup code, it allowed my addon to start.

    2020-02-20 soly bbmod popup crash.png

    i have a copy of my pso folder, which still has Eidolon's version of bbmod, along with a barebones addon that i sometimes use to try things out before adding them to custom hud (my addon). i used this to double-check, and got the same results - a basic popup worked fine with Eidolon's bbmod, but it crashes the game when using your fork unless i comment out the popup code.



    also, i noticed that in the theme editor, color components are labeled A,B,G,B instead of A,R,G,B.
     
  12. Ender

    Ender of fun

    Guildcard:
    42017744
    Those asserts always indicate a bug in your addon. Make sure you have one and only one matching End*() call for each Begin*(), and a corresponding Pop*() for each Push*().

    Also they're only on in debug mode. Soly is doing his releases with debug builds which should probably be changed to be release because iirc there's some automatic stack balancing in the plugin from a commit by @staphen some years back. But I wouldn't want to rely on that to coverup an addon's bug (which could be detrimental if it's covering up the right mistake elsewhere).

    EDIT: I remember older releases of some addons copied the PushStyleColor() for transparent windows and were missing the PopStyleColor(), and I've seen those copied around by others (myself included :oops:).
     
    Last edited: Feb 20, 2020 at 4:49 PM
  13. NeonLuna

    NeonLuna amazing

    Guildcard:
    42014519
    i'm writing most of my code from scratch at this point, just referring to other things to remind myself of syntax. here's the simple addon i used to double check that the problem wasn't in my code:

    Code:
    --[[
    popup test
    Catherine S (IzumiDaye/NeonLuna)
    2020-02-20
    ]]
    
    local core_mainmenu = require('core_mainmenu')
    
    local showwindow
    local showtestpopup
    
    local function present()
       if not showwindow then return end
     
       if imgui.BeginPopup('testpopup') then
           imgui.Text'test popup'
           if imgui.Button'close' then imgui.CloseCurrentPopup() end
       imgui.EndPopup() end
     
       if showtestpopup then
           imgui.OpenPopup'testpopup'
           showtestpopup = false
       end
     
       imgui.SetNextWindowSize(600,300,'FirstUseEver')
       local success
       success, showwindow = imgui.Begin('popup test', true)
           if not success then
               imgui.End()
               return
           end
         
           if imgui.Button'show test popup' then showtestpopup = true end
         
       imgui.End()
    end -- local function present()
    
    local function init()
       core_mainmenu.add_button('popup test', function() showwindow = not showwindow end)
     
       return
           {
           name = 'popup test',
           version = '0.1',
           author = 'IzumiDaye',
           description = 'test popup with a barebones addon',
           present = present,
           }
    end
    
    return {__addon = {init = init}}
    
     
  14. Ender

    Ender of fun

    Guildcard:
    42017744
    I think you're suppose to call OpenPopup() before BeginPopup(), and also End before close (although imgui.cpp seems to indicate Close() should be called inside Begin() and End() but oh well).

    This works for me after some changes and error handling omitted. Although the popup behavior is a little odd because popups are meant to go away if you click outside of them, whereas it looks like you want to have them become the focus again.

    Code:
    local function present()
        if not showwindow then
            return
        end
    
        --imgui.SetNextWindowSize(600,300,'FirstUseEver')
        local success
        success = imgui.Begin('popup test', true)
        if not success then
            return
        end
       
        if imgui.Button('show test popup') then
            showtestpopup = true
        end
        imgui.End()
        if showtestpopup then
            imgui.OpenPopup('testpopup')
            imgui.BeginPopup('testpopup')
            imgui.Text('test popup')
            if imgui.Button('close') then
                showtestpopup = false
            end
            imgui.EndPopup()
            if not showtestpopup then
                imgui.CloseCurrentPopup()
            end
        end
    end -- local function present()
     
    Last edited: Feb 20, 2020 at 7:19 PM
  15. NeonLuna

    NeonLuna amazing

    Guildcard:
    42014519
    ok, this does make a popup without crashing - but my code works fine with the other version of bbmod, including closing the popup if the user clicks outside it, which is what i want.

    i tried putting OpenPopup before BeginPopup, and it didn't make a difference.

    i checked what version of imgui bbmod uses with imgui.GetVersion, and found out that it's 1.49, while the copy of imgui.h that i've been referring to is 1.67. i downloaded the 1.49 version of imgui.h and imgui.cpp, and the way popups are made doesn't seem to have changed. (the parts that i'm using seem the same, at least.) imgui.h version 1.49, line 374, pretty explicitly says to call CloseCurrentPopup between BeginPopup and EndPopup. also, in imgui.h 1.67, line 508, it says not to call OpenPopup every frame. it doesn't say anything about that in 1.49, but i'm only calling it once when i want to start showing the popup, and it works exactly as i intended in Eidolon's version of bbmod.

    when using Soly's bbmod fork, it looks like the game crashes if i call BeginPopup when the popup is not open, but i believe i'm supposed to be able to call it regardless. it returns a boolean to tell me if it's open or not, and i don't see why it would do that if i'm not allowed to call it when the popup isn't open. i see a function in imgui.h, IsPopupOpen, which would allow me to work around this, but bbmod doesn't seem to have that function.
     
  16. Soly

    Soly Member

    Location:
    CR
    Thanks, fixed.

    Afaik I have been grabbing the release build to put on github...

    So it seems the issue with the popups are the auto balancing stacks
    For some reason the popups don't actually appear (either in 1.49 or 1.75 WIP) unless I put the imgui.End after the whole begin popup.

    After commenting the autobalancing stack stuff this code works just fine

    Code:
    local function present()
        if imgui.Begin('popup test', true) then
            if imgui.Button('show test popup') then
                imgui.OpenPopup('testpopup')
            end
            
            if imgui.BeginPopup('testpopup') then
                imgui.Text('test popup')
                if imgui.Button('close') then
                    imgui.CloseCurrentPopup()
                end
                imgui.EndPopup()
            end
            
            imgui.End()
        end
    end -- local function present()
     
    NeonLuna likes this.
  17. Soly

    Soly Member

    Location:
    CR
    @NeonLuna since this is most likely how this will be solved?
    You can go into addons\psointernal\init.lua and comment the lines
    Code:
    153: balance_all_stacks = override_stack_functions()
    224: balance_all_stacks()
    I think this should work but mismatched Begin/Ends and all that stuff will crash addons.
     
    NeonLuna likes this.
  18. Soly

    Soly Member

    Location:
    CR
    NeonLuna likes this.
  19. e_bolavirus

    e_bolavirus Member

    Guildcard:
    42052755
    @Soly any idea how to determine what the player's highest level learned for each technique would be? I was able to find the player's MST address. I want to create a function to determine the most optimal tech to cast for each enemy using the tech damage formula on pso-world, and this is the one piece im missing. Otherwise i would have to manually edit the function every time a new tech is learned.
     
  20. Soly

    Soly Member

    Location:
    CR
    Just to let you know, I am adding this rq

    Seems to be good
    [​IMG]

    You can use it something like

    Code:
    local self = lib_characters.GetSelf()
    local foie = lib_characters.GetPlayerTechniqueLevel(self, lib_characters.Techniques.Foie)
     
    Last edited: Feb 21, 2020 at 10:02 PM

Share This Page