Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with API Sample #1
#7
Don't mean to whip a dead horse but there seems to be a couple things more wrong with the sample Peep

Player.health.current seems to throw an error. Player.hp.current does report the correct number, however, I cannot get it to report it to the HP: field.

Below is a snippet I've taken out of the sample (with slight edit). d(Player.hp.current) reports to the console perfectly, however the hpvalue = tostring(Player.hp.current) line doesn't actually report it to the HP: field.

Code:
-- The Mainloop function, gets called all the time by FFXIVMinion:
function mymodule.OnUpdateHandler( Event, ticks )
    if ( mymodule.running and ticks - mymodule.lastticks > 500 ) then
        mymodule.lastticks = ticks
-- if the player is alive, set the current HP value into the new field of our created Window:
         if (Player.alive) then
            d(Player.hp.current)
            hpvalue = tostring(Player.hp.current)
         end
    end        
end

Also, I find that the GUI_NewWindow() function seems to have issues regarding window size and location, and that I need to use GUI_SizeWindow() to accurately display the window. Is this a known issue, or just me breaking stuff?

Normally when I want to pick up a new language quickly I take a working sample and break it to see what happens, but it seems I'm try to accomplish the opposite this time :P

Lastly, I appreciate the help so far in guiding me, it's appreciated!

Nevermind, figured it out. Seems that the window doesn't like displaying fields that are not part of a group. The code below is a 100% functioning "Sample #1". Please stick this up in place of the current one :)

Code:
-- Create a new table for our code:
mymodule= { }
-- Some local variables we use in our module:
mymodule.running = false
mymodule.lastticks = 0
mymodule.hpvalue = "0"

-- Initializing function, we create a new Window for our module that has 1 button and 1 field to display data:
function mymodule.ModuleInit()
    GUI_NewWindow("MyNewWindow",500,50,250,170);
    GUI_NewButton("MyNewWindow","Toggle","MYMODULE.TOGGLE");
    GUI_NewField("MyNewWindow","HP:","hpvalue","HitPoints"); -- In order to display the value of this field, it must be a part of a group ("HitPoints").
    GUI_SizeWindow("MyNewWindow",250,200) -- This line currently required in order to properly resize and display the window. GUI_NewWindow is a little broken right now.
end

-- The function that gets called when the button is pressed:
function mymodule.ToggleRun()
    mymodule.running = not mymodule.running
end

-- The Mainloop function, gets called all the time by FFXIVMinion:
function mymodule.OnUpdateHandler( Event, ticks )
    if ( mymodule.running and ticks - mymodule.lastticks > 500 ) then
        mymodule.lastticks = ticks
-- if the player is alive, set the current HP value into the new field of our created Window:
         if (Player.alive) then
            hpvalue = tonumber(Player.hp.current)
         end
    end        
end

-- Registering the Events
RegisterEventHandler("Gameloop.Update",mymodule.OnUpdateHandler) -- the normal pulse from the gameloop
RegisterEventHandler("MYMODULE.TOGGLE", mymodule.ToggleRun) -- the function that gets called when our button is pressed
RegisterEventHandler("Module.Initalize",mymodule.ModuleInit) -- the initialization function, gets called only once at startup of the game

Now, on to something more useful!
Reply
 


Messages In This Thread
Problem with API Sample #1 - by Sil - 10-14-2013, 03:50 AM
RE: Problem with API Sample #1 - by Gabi - 10-14-2013, 05:29 AM
RE: Problem with API Sample #1 - by Sil - 10-14-2013, 05:44 AM
RE: Problem with API Sample #1 - by z0mg - 10-14-2013, 06:11 AM
RE: Problem with API Sample #1 - by Sil - 10-14-2013, 07:48 AM
RE: Problem with API Sample #1 - by z0mg - 10-14-2013, 08:00 AM
RE: Problem with API Sample #1 - by Sil - 10-14-2013, 12:52 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)

We help you win the game.

FFXIV Bot and More.

 

Products