Starfinder Playlist
  1. #1

    How to call function of Windowclass a from windowclass b

    Hi,

    I'm currently working on new character sheet for the Forbidden Lands extension.

    The game uses a lot of different combat actions, not all of which are available to you depending on your equipment. It's also (not yet sure if unnecessarily) nuanced in differentiating between different attack forms, with stabbing someone being different from slashing someone and other stuff. And some weapons allow you to choose different attack modes. Anyway, it's quite difficult for beginner to keep up with your available combat options and their advantages/disadvantes depending on your loadout.

    So I'm working on making a combat sheet for the character sheet in which you can configure your weapons, and the sheet then displays only the combat actions available to you:

    WeaponsArmor.png

    The Sheet is divided into two frames with different windowclasses, windowclass "weapons" for the upper frame in which you configure your weapons and armor, and windowclass "actions" for the lower frame in which your available actions are displayed. The windowclasses are connected to different scripts, let's call them "weaponsScript" and "actionsScript". The scripts are only called by the windowclasses.

    "actionsScript" has a function to read the content of the "weapons"-frame and generate content the "actions" frame from this data. The function is triggered onInit() of the "actions"-frame, and can be triggered manually by the radial menu of the "actions"-frame.

    However, I'd like to trigger the function whenever values change in the "weapons"-frame.
    Is it possible to call the function of the "actionsScript" by onValueChanged()-functions of the "weapons"-frame, in a way that calling node if the "actions"-frame?

    Or do I have to write a new script that is independent of the windowclasses, which operates from the charsheet base node?
    Attached Images Attached Images

  2. #2
    I've made some progress, but have not resolved the issue yet.

    I've copied my scripts into functions of a script that is independent of the windowclass calling it.

    My problem now is getting the correct value for the "window" variable.
    I've got the windowclass for the charsheet page called "charsheet_combat". Then there's the two windowclasses "weapon" and "combatweaponactions".

    What I think I need is to implement an onValueChanged()-function for the controls of the "weapon"-class that can somehow get the window-value of the "charsheet_combat"-class to feed it as an input into my original script.

    I've tried Interface.findWindow, but that doesn't work or my syntax isn't right. charsheet.id-00005 is my test-charactersheet, and .weaponactionlist is the datasource

    Other path I think I can take is looking into subwindows, and making the frame contents subwindows of charsheet_combat?
    Last edited by Tatzelbelm; May 18th, 2020 at 16:27.

  3. #3
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Isle of Wight, UK (for a bit)
    Posts
    27,503
    This doesn't specifically answer your question. But it gives advice on how to approach what you're trying to do.

    Usually when people start developing in FG they concentrate on the GUI - because that's what we mostly modify and concentrate on. However, most of the GUI controls (actually, controls that are called "fields" - e.g. stringfield, numberfield, etc.) the data they hold is stored in the database. You're much better doing any onUpdate or data manipulation code in the database. FG GUI fields automatically updates to show what is stored in the underlying database, so you can work against the data and the relevant GUI sections will be updated.

    The advantages are many:

    • It's easier to look at the database structure in the campaign db.xml file than it is to try to work out something like window.parent.window.<control name> within the GUI.
    • If you change around GUI fields within a window, the impact to DB code is usually much less than the impact to GUI based code.
    • Code will run and update data that is used by fields that haven't even been viewed yet. For GUI code (and GUI control access) they have to be already initiated to be used. Database access can run without the related window being open.
    • It's a lot easy to code for updates to DB fields - just do it in one place.


    The main disadvantage to all this is if you're not currently familiar with the FG database structure, the DB events and how to access in code. If you're planning to do anything other than minor tinkering in FG code then learning about the database, and using it, is well worth the effort.

    What you're trying to do is a classic issues with accessing data via the GUI. It's so much easier to access the data in the database, that has a specific hierarchy that is clearly visible in the campaign db.xml file - for example, charsheet.id-00001.armor.name, might contain the name of the armor worn by the first entry in the PC charsheet section of the database.
    Last edited by Trenloe; May 18th, 2020 at 16:29.
    FG Con 16 Fantasy Grounds Online RPG Convention - Postponed New date To Be Confirmed.
    Register at www.fg-con.com for all the latest info.

    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  4. #4
    Huh, you are right. This would be much simpler by just writing into the database.

    I've actually worked with the db quite a bit in the last few days, looked up lots of things in it etc.
    In this case, I just didn't think of it because I had been repurposing a script I had copied from some other ruleset, and was totally focused on getting this running by changing the existing script.

    Thanks!

  5. #5
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Isle of Wight, UK (for a bit)
    Posts
    27,503
    Quote Originally Posted by Tatzelbelm View Post
    and was totally focused on getting this running by changing the existing script.
    I know that feeling!
    FG Con 16 Fantasy Grounds Online RPG Convention - Postponed New date To Be Confirmed.
    Register at www.fg-con.com for all the latest info.

    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  6. #6
    And I've got it working now.

    Many, many thanks!

  7. #7
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Isle of Wight, UK (for a bit)
    Posts
    27,503
    Quote Originally Posted by Tatzelbelm View Post
    And I've got it working now.

    Many, many thanks!
    Woo hoo! Great news.

    Happy to help. Sorry it took a while to get to you - I saw your first post late yesterday evening my time and couldn't reply then.
    FG Con 16 Fantasy Grounds Online RPG Convention - Postponed New date To Be Confirmed.
    Register at www.fg-con.com for all the latest info.

    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
PF2E Playlist

Log in

Log in