PDA

View Full Version : Add search to the referenceindex window class



sloejack
September 13th, 2007, 19:58
The need to do this arose out of some valid comments about the CSRD modules that were recently released. Two notes before continuing, first is that you will have to create a custom ruleset using the d20unpak that comes with FG. There are instructions for this out there so I'm not going to go into that. Also, you're going to have to modify a couple of the xml files in your new ruleset. If you're not comfortable doing this, then don't do it.

Big thanks to Joshuha for easing the dull throbbing in my head from having bashed it against the wall so many times while trying to figure out why it wasn't working. Now on with the show.

In your new ruleset's folder, you need to modify the base.xml file and add the following bit after the <root version="2.0"> line:


<importinfo>
<acceptfrom ruleset="d20" />
</importinfo>

This will allow you to open the modules created for the d20 ruleset in your new ruleset's library.

Next you will need to modify reference_basicclasses.xml to add the following lines at line 626. This is in the <windowlist name="index"> node.


<script>
function onFilter(w)
local top = w.windowlist.window;
while top.windowlist do
top = top.windowlist.window;
end

local f = string.lower(top.filter.getValue());

if f == "" then
return true;
end

if string.find(string.lower(w.name.getValue()), f, 0, true) then
return true;
end

return false;
end
</script>


After that is added, slightly further down at what should now be line 647 after the </windowlist> for the aformentioned "index", add the following:


<filter name="filter">
<bounds>55,50,-50,20</bounds>
<target>index</target>
<trigger>filtertrigger</trigger>
</filter>
<filtertrigger name="filtertrigger">
<bounds>0,0,16,31</bounds>
<target>filter</target>
</filtertrigger>

Save your work and you're done. Create a campaign using your new ruleset and you will now notice the filter magnifying glass in the upper left corner of any windows that use the referenceindex class that will allow you to search through long indexes like those found in the monster module from the CSRD.

Just as a general warning, if and when any changes come out for the d20 ruleset from smiteworks, those changes will not be replicated to your ruleset. You will have to maintain it yourself. It is my hope that smiteworks will incoroporate this function into their ruleset and thus relegate this hack to the circular file.