-
May 19th, 2023, 02:54 #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?
-
May 19th, 2023, 04:25 #912
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
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
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...
-
May 19th, 2023, 04:25 #913
This means you stay more within the RSW environment than you might with Baynes code...
-
May 19th, 2023, 12:21 #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)
https://forge.fantasygrounds.com/shop/items/199/view
Old School Essentials Ruleset
https://www.dmsguild.com/product/352...eon-Builder-5E
5e Random Dungeon Generator!
-
May 19th, 2023, 15:28 #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.
-
May 19th, 2023, 15:38 #916
-
May 19th, 2023, 15:51 #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;
endhttps://forge.fantasygrounds.com/shop/items/199/view
Old School Essentials Ruleset
https://www.dmsguild.com/product/352...eon-Builder-5E
5e Random Dungeon Generator!
-
May 19th, 2023, 16:33 #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.
-
May 19th, 2023, 16:44 #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
-
May 20th, 2023, 03:47 #920
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
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks