STAR TREK 2d20
Page 92 of 109 First ... 42829091929394102 ... Last
  1. #911

    Join Date
    Nov 2017
    Location
    North Carolina, USA
    Posts
    266
    Ok, I am looking/trying that.

    onFilter(w) -- is (w) a standard name or do I need to put the name of my windowlist or filter in place of w? And then replace "w" throughout the script?

  2. #912
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,685
    Blog Entries
    1
    Off the top of my head:

    you have hidden field for: inventory_filter_weapon which is set to weapon
    This is the text that we are using to match against the control: item_type which has 3 possible values called weapon, armor, equipment (may vary in yours)

    so if on your weapon_list windowclass (mine would nrmally be called something like weapon_detail) you create hidden controls: new_filter, carried (0,1,2) and item_type (weapon, armor, equipment), #2 and #3 will fill automatically from the source record. make them not invisible until you know they are working. on each of those controls add something like:

    Code:
    function onInit()
      onValueChanged()
    end
    
    function onValueChanged()
      local nodeItem = window.getDatabaseNode();
      local sCarried = DB.getValue(nodeItem, "carried", '0');
      local sType = DB.getValue(nodeItem, "item_type", '');
      window.new_filter.setValue(sType .. sCarried);
    end
    now change my earlier instruction of

    Set the source of the weapons list to .inventorylist which is the same source as your inventory
    Create a hidden string control called: inventory_filter_weapon with a default value of: weapon
    Filter field type: Control
    Filter on field name: item_type (at least this is where I record weapon/armor/equipment in my rulesets)
    Filter on field type: Control
    to something like:

    Set the source of the weapons list to .inventorylist which is the same source as your inventory
    Create a hidden string control called: inventory_filter_weapon2 with a default value of: weapon2
    Filter field type: Control
    Filter on field name: new_filter
    Filter on field type: Control

    Note: I renamed inventory_filter_weapon to inventory_filter_weapon2 because setting a value with default only works on brand new records.

    I hope that this makes sense and I hope my code works... Im at work and not near my computer.... this is from memory and that is risky business...

  3. #913

  4. #914
    That is just a script you place on the windowlist control. Your control name goes in place of type and carried. Carried should not change. Do you know what controls you are trying to filter? (Other than carried)

  5. #915

    Join Date
    Nov 2017
    Location
    North Carolina, USA
    Posts
    266
    This is what I have so far (see images).
    windowlist:
    Capture.PNG

    weapon2 string:
    Capture2.PNG

    new_filter control:
    Capture3.PNG

    This is the error I get:
    [5/19/2023 9:27:07 AM] [ERROR] Script execution error: [string "C:charsheet_notes:new_filter"]:9: attempt to call field 'setValue' (a nil value)
    [5/19/2023 9:27:07 AM] [ERROR] Script execution error: [string "C:charsheet_notes:carried"]:9: attempt to call field 'setValue' (a nil value)
    [5/19/2023 9:27:07 AM] [ERROR] Script execution error: [string "C:charsheet_notes:item_type"]:9: attempt to call field 'setValue' (a nil value)

    Do I place the name of the control in Custom Class Name as well?
    What is the "setValue" that the control should refer to? I am wanting to filter weapons that are "Equipped" I tried sEquipped and sCarried, same error.
    Attached Images Attached Images

  6. #916

  7. #917
    Gunnar

    I shall leave you guys to it but if you want to just try the below. If your already scripting on the windowlist not sure why not just use onFilter directly?

    Use this on the windowlist make sure you have the controls present in the windowclass for the windowlist.

    function onFilter(w)
    if w.item_type.getValue() == "#insert the word your filtering from item_type here#" and w.carried.getValue() == 2 then
    return true;
    end
    return false;
    end

  8. #918

    Join Date
    Nov 2017
    Location
    North Carolina, USA
    Posts
    266
    OK, made those changes.
    weapon_filter2.PNG

    5 controls top to bottom:
    1. "weapon" is the type filter for the windowlist
    2. "weapon2" is the string filter for the new script. (I am not sure I set the filter up correctly. No filter option on a string so I created one in custom properties.)
    3. "new filter"
    4. "weapon" is the item_type string with "weapon" as the default text.
    5. "carried"

    The last 3 have the following script:
    function onInit()
    onValueChanged()
    end

    function onValueChanged()
    local nodeItem = window.getDatabaseNode();
    local sCarried = DB.getValue(nodeItem, "carried", '0');
    local sType = DB.getValue(nodeItem, "item_type", '');
    window.new_filter.setValue(sType .. sCarried);
    end

    My understanding of the process:
    This windowlist grabs items labeled "weapon" from .inventorylist
    The script should run when a weapon (item_type) item's value for "carried" (carried) changes.

  9. #919

    Join Date
    Nov 2017
    Location
    North Carolina, USA
    Posts
    266
    disregard this post, answered the question I had added here.
    Last edited by greybeardgunner70; May 19th, 2023 at 17:50. Reason: Deleted, unneccessary

  10. #920
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,685
    Blog Entries
    1
    OK Gunnar some of my instruction was a little off

    Attached is an extension and a RSW project.
    It creates a CoreRPG extension called GunnarsChallenge

    load it up in CoreRPG
    create a character called Bob
    create two items called Axe and Bow
    add them to Bobs inventory

    For the sake of this experiment we dont have item types in CoreRPG so I have used the Notes field
    If you write Weapon (case sensitive - and I used Title Case because 5E does) in there and you equip the item it will show up in the Weapons list
    If you unequip or change Weapon to something else it will disappear from the Weapons list
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
DICE PACKS BUNDLE

Log in

Log in