PDA

View Full Version : Looking up API calls?



Varsuuk
March 26th, 2018, 01:25
I am just getting started and I went to add a pair of "rest" subitems to the character radial menu.

I see that it appears to be:
registerMenuItem(string-description, icon-to-use, Location?Index?[, SubLocation?Index?])

But I searched in the rulesets and did not find these. I looked in the Interface section of Wiki and I found the command "openRadialMenu" but nothing else. Further searching may find it but I need to do a few things before I can continue on this so figured I'd ask ahead of time should I not find this.

Is there some location on web page or in the Fantasy Grounds folder where I can search on function names to see description or if not, at least the interface/params? Or is it the Wiki plus a forum "updates" page? Or?


------

Lastly, as a bonus question that may become self-evident as I get more than 2 hours into coding ;) - if I made a similar method to that found in char.lua for 5e I can easily differentiate between a 1 day rest & full rest. However, if I wanted to add another entry to the radial for N-Days rest and have the handler popup some way to get a number from the user - what existing Core/3.5/5e/PF/SW/C&C/ADDCore etc ruleset file/method can I look at for inspiration?


Thanks all

Trenloe
March 26th, 2018, 01:42
But I searched in the rulesets and did not find these.
Which ruleset?

TIP: Extract your ruleset PAKs to a directory somewhere (ideally not in the FG rulesets directory, unless you call it something other than the ruleset name - perhaps 5e_temp or something so that FG doesn't think it is actually a ruleset). Then use a file editor that has "find in files" functionality. Searching for registerMenuItem in the 5E ruleset gives lots of hits.

For example in campaign\scripts\char.lua:


registerMenuItem(Interface.getString("menu_rest"), "lockvisibilityon", 8);
registerMenuItem(Interface.getString("menu_restshort"), "pointer_cone", 8, 8);
registerMenuItem(Interface.getString("menu_restlong"), "pointer_circle", 8, 6);

The API call is documented here:https://www.fantasygrounds.com/refdoc/windowinstance.xcp#registerMenuItem

In the above code: 8 is the top left at the first level. 8, 8 is the top left in the second level after first selecting top left. 8, 6 is the bottom left (6) in the second level after first selecting the top left (8).

Moon Wizard
March 26th, 2018, 01:42
Here's the link to the registerMenuItem API function:
https://www.fantasygrounds.com/refdoc/windowcontrol.xcp#registerMenuItem

You will also need the onMenuSelection API event:
https://www.fantasygrounds.com/refdoc/windowcontrol.xcp#onMenuSelection

There are several examples in the CoreRPG ruleset:
campaign/record_table.xml
campaign/scripts/charselect_client_entry.lua
campaign/scripts/charselect_host_entry.lua
campaign/scripts/char_invlist.lua
campaign/scripts/imagewindow.lua
campaign/scripts/masterindexitem_window.lua
campaign/scripts/masterindex_window.lua
campaign/scripts/table_add.lua
ct/ct_host.xml
ct/scripts/ct.lua
...and so on...

Make sure you use a text editor with the ability to search all files in a directory, like Notepad++.

Regards,
JPG

Varsuuk
March 26th, 2018, 03:38
Awesome help finding the API page. I’m sorry, I intended to go through them one by one - what I meant about an index is it would be great to search on a single web page for a function call to help me find it. I’m sure once I become more familiar with this type of programming, I will better be able to suss out which top level items like windowclass I should open to look for the call.


I already unpacked CoreRP, 3.5, 5e, and AD&D Core (ftw) into the Eclipse lua project I created to help me lear/edit. I searched and found he CALL in all the places you mentioned which I guess I didn’t make clear in my initial post (no big surprise, I tend to not collect thoughts on “paper” clearly) - that is how I inferred the API paramus. I was looking for either the web API page (you both found it for me) or the lua source file it was defined in (in case it was something we were supposed to find in some utility.lua file I missed)

I’ll start my searches going forward with Windoclass :) on hindsight, I feel quite foolish not continuing down the list, it knew was getting off the pc so figured ask. Now am back after son is asleep and going back into the breach ;). Fun stuff.

Thanks as always for excellent replies! You guys are amazingly helpful.

Moon Wizard
March 26th, 2018, 04:04
I just type “<function_name> fantasygrounds.com” into Google to find them. :)

JPG

Varsuuk
March 26th, 2018, 04:59
I just type “<function_name> fantasygrounds.com” into Google to find them. :)

JPG

AHA!

Wow, yeah... you’d think I haven’t been using personal computers since ‘83 (worked on networked VIC20s to do a Space Shuttle simulaunch 1982 in HS, but only “operated”, so not counting that.)

Somehow I am still pretty “general internet” slow... the upside is I only know of cat video meme concept through inference, so ... there’s that going for me...