• Please note: In an effort to ensure that all of our users feel welcome on our forums, we’ve updated our forum rules. You can review the updated rules here: http://forums.wolflair.com/showthread.php?t=5528.

    If a fellow Community member is not following the forum rules, please report the post by clicking the Report button (the red yield sign on the left) located on every post. This will notify the moderators directly. If you have any questions about these new rules, please contact support@wolflair.com.

    - The Lone Wolf Development Team

Creating Gadgets

AndrewD2

Well-known member
In this system I think Gadgets may be the most complex thing to create. So far I've got a component with fields for: Total Story Point Cost, Good Trait Max Points, Bad Trait Max Points, Good Trait Total Points, Bad Trait Total Points, Gadget Type.

Gadgets come in 3 types, like Traits, Major/Minor/Special.

Minor can contain a positive value of 1 point, by taking bad traits you can effectively get 2 points (with a -1 from the bad trait)

Major are double, they're valued at 2 points and you can take 2 points in bad traits to gain 2 more good points to use.

Special are in reality anything greater than Major, with the base value as being 4, where you can take up to 4 points in bad traits to gain 4 more points of good traits.

There are 2 kinds of Gadgets to build, ones that will be created in the editor and ones that will be created via a custom gadget gizmo.

The editor tab will need to be able to select traits much like Magic Weapons in Pathfinder select powers. The logic in it will be that if the items are added to the gadget it doesn't have to balance out with Good Points and Bad Points.

The custom one be much like creating a custom magic weapon in Pathfinder is done. It'll have a line for it's name, the option to select good/bad traits and will have the interior logic that everything balances out to whether it's a minor/major/special gadget. There will also be a selector to whether its minor/major/special (but I figure that's a given).
 
Don't think of them as different projects - if I had Pathfinder to do over, weapons would work more like Shadowrun, where everything is customizable, and the mods that can be purchased are the same items you bootstrap into the gizmo of a pre-selected custom item that you build in the editor.
 
I don't really see them as different projects, I see them as 2 parts of the same project, just with parts that need to be handled differently.
 
That's what I meant - don't think of them as needing to be handled differently - when you create the thing entry for your custom item, you'll do so on the same editor tab as you're creating your specific items - it'll just be empty, with nothing pre-bootstrapped.

Then, there's already a Helper.CustomItem tag used for the custom gear item, so re-use that here, along with the username portal that's already set up on the gear tab to go along with that tag.
 
Ok, so I'm getting pretty far along in the form, I really only have one more thing to get working.

I'm guessing I need another table to show the item information on the form. But tables see to only show the things of the specific component in the container.

What I'm needing to add is the Info like Name/Custom Name, Rank/Custom Rank, how many points spent and how much you have left.

I created a fixed table, but as mentioned above that seems to only show items of a specific component on the table.

What I'm trying to get is something like the attached image, which will only need labels, menus, and a box to enter text.

I'm not sure if I actually need to use a table for this (which doesn't seem right) or some other element that I'm just not seeing to position the relative information.
 

Attachments

  • Gadget Form2.jpg
    Gadget Form2.jpg
    69.9 KB · Views: 4
And this is the portal/template I have so far (just working to get the name to show up).

Code:
    <portal
      id="gaNameInfo"
      style="tblInvis">
      <table_fixed
        component="Gadget"
        showtemplate="gaGadName"
        headerpick="GadgetHelp">
        <headertitle><![CDATA[
          @text="Gadget Info"
          ]]></headertitle>
        </table_fixed>
      </portal>
      
   <template
     id="gaGadName"
     name="Gadget Info"
     compset="Gadget"
     marginhorz="3"
     marginvert="2">
     
     <portal
       id="name"
       style="lblNormal">
       <label>
         <labeltext><![CDATA[
           if (tagis[Helper.CustomItem] <> 0) then
             @text = "Item Name: "
           else
             @text=field[name].text
             endif
           ]]></labeltext>
         </label>
       </portal>
       
       <position><![CDATA[
       
       height = portal[name].height
       width = 265
       portal[name].left = 0
       ]]></position>
     </template>
 
So I've discovered that I can do a template without it being attached to a portal. So I got rid of the portal above and placed the template in the layout for the form, but it's not showing up. The template is currently just 1 label: name

Code:
   <template
     id="gaGadName"
     name="Gadget Info"
     compset="Gadget"
     marginhorz="3"
     marginvert="2">
     
     <portal
       id="name"
       style="lblNormal">
       <label>
         <labeltext><![CDATA[
           if (parent.tagis[Helper.CustomItem] <> 0) then
             @text = "Item Name: "
           else
             @text=parent.field[name].text
             endif
           ]]></labeltext>
         </label>
       </portal>
       
       <position><![CDATA[
       
       portal[name].left = 0
       ]]></position>
     </template>

The only thing I currently have in the layout is this template.

Code:
  <layout
    id="gaGadTrt"
    marginvert="4">
    <!--<portalref portal="gaGadFrm" taborder="20"/>-->
    <templateref template="gaGadName" taborder="10"/>


    <position><![CDATA[

           
      ~position and size the table to span the full layout; it will only use the
      ~vertical space that it actually needs
        perform template[gaGadName].autoplace
      ~perform portal[gaGadFrm].autoplace

      ]]></position>
    </layout>

As far as I can tell this should be appearing, but it just shows a blank form with an Add button at the bottom.

EDIT: I notice that something is showing up when add the Trait Table back in, the blank space above is increased the amount of the size of the template, but still shows up bank.

EDIT 2: forcing it to be visible seems to have fixed my problem.
 
Last edited:
Ok, moving on from that blunder about, I'm trying to get the username field to only show up when the parent item has the "Helper.CustomItem" tag. It works for the name label script that is

Code:
     <portal
       id="name"
       style="lblNormal">
       <label>
         <labeltext><![CDATA[
           if (tagis[Helper.CustomItem] <> 0) then
             @text = "Item Name: "
           else
             @text=field[name].text
             endif
           ]]></labeltext>
         </label>
       </portal>

But if I use the parent.tag[Helper.CustomItem] in the position script I get a compilation error. I'm just trying to do if it's not a custom item, hide the portals that are only seen for custom items (names, point costs, etc)
 
Here's the layout for Shadowrun 5's skill specialties. I believe the key items that aren't described in the wiki are dynamic="yes" ispick="yes" on the templateref, which tells it that its pick is the parent pick, and that in visual scripts, unlike most anywhere else, you need to use container.parent to reach the parent. Almost everywhere else you can skip container and go to the parent directly.

(Of course if you look at Pathfinder/d20's code, there's quite a lot of legacy code written back when you needed container.parent everywhere).

Code:
  <layout
    id="skSpecial">
    <portalref portal="skSpecial" taborder="10"/>
    <portalref portal="skKnowSpec" taborder="20"/>
    <templateref template="skFixedSp" dynamic="yes" ispick="yes"/>
    <position><![CDATA[
      width = 350
      autoright = width

      if (container.parent.tagis[component.SkillKnow] = 0) then
        perform portal[skSpecial].autoplace
        portal[skKnowSpec].visible = 0
      else
        perform portal[skKnowSpec].autoplace
        portal[skSpecial].visible = 0
        endif

      if (container.parent.field[sklFixedSp].isempty = 0) then
        template[skFixedSp].width = width
        perform template[skFixedSp].render
        template[skFixedSp].top = autotop + 10
        height = template[skFixedSp].bottom
      else
        template[skFixedSp].visible = 0
        height = autotop
        endif
      ]]></position>
    </layout>
 
so using dynamic and ispick means that checking tagis[Helper.CustomItem] is the same as checking container.parent.tagis[Helper.CustomItem] without? Is that what I'm reading (and that's what th effect seems to be) but I just want to make sure I'm understanding this correctly.
 
The initial pick of a template script (and therefore any script inside it) is the pick it's assigned to.

By setting it as dynamic, the pick it's assigned to becomes the parent of the gizmo.

The layout script, on the other hand, is running as a child inside the gizmo. So in order to get to the same place, it instead needs to transition to its container (which is the gizmo), and then to the parent pick of that container.
 
Oh I see, now I'm trying to figure out the best way to track spent resources on each gadget, can I use a resource pick bootstrapped to it? Or should I just do the math in the component and have it read the fields?
 
Ok, almost got everything finished up. Is there a way freeze selection? Like when you're in advancement mode?

Also is there a way to set a prereq that is valid if it's on the gizmo? Some traits are specifically for gadgets or characters with a couple specific other traits, the traits are easily covered with checking the #hastrait[] macro that I made, but I'm not sure how to test if it's on a gadget itself
 
Last edited:
There should be examples of freezing tables in several of the tabs in the skeleton files.

ishero is the test for whether a container is the hero. The initial context of a prereq is the container you're adding something to (or the container it's in if it's a pick), so if you're adding it to a gizmo, ishero = 0, and if you're adding it to the character, ishero <> 0.
 
Also while working on the prereq I setup a prereq on the Traits that is

Code:
      ~check if we're cyborg, robot, or a gadget.
      if (tagis[Trait.Gadget] <> 0) then
        validif (#hastrait[trRobot] + #hastrait[trCyborg] <> 0)
        validif (container.ishero = 0)
      else
        @valid=1
        endif

But even items that have the Trait.Gadget tag are appearing as valid, I'm not sure if something special is needed for checking prereqs like that?
 
Figured it out I remember that just doing tagis is looking at the hero so what I did was add a <match> element for the tag Trait.Gadget and it works.
 
Last edited:
Back
Top