View Single Post
Mathias
Senior Member
Lone Wolf Staff
 
Join Date: May 2005
Posts: 13,207

Old April 1st, 2013, 11:50 AM
Using gizmos along with the purchasing mechanisms (if the gizmo represents a piece of gear that you can purchase modifications for, using cash).

If you want the things you add to your gizmo to cost money, you'll need to add the thingbuytemplate="" option to your entity:
Code:
<!-- The Customizable gear entity -->
<entity
  id="grCustom"
  form="gcCustom"
  thingbuytemplate="BuyCustom">
  <bootstrap thing="GearCustom"/>
  <bootstrap thing="mdRFID"/>
  <bootstrap thing="mdWireless"/>
  <bootstrap thing="mdGearSize"/>
  <bootstrap thing="mdCybGrade"/>
  <bootstrap thing="mdBioGrade"/>
  <bootstrap thing="mdAdapsin"/>
  <movetest><![CDATA[
    call MoveTest
    ]]></movetest>
  </entity>
(The movetest script is an advanced topic for gizmos - not something you need to worry about until your game system is finished, and you start polishing it).

Then, in visual.dat, add a new template - this will automatically be placed along the bottom of your form, so that users can say OK when they're done purchasing all the stuff, and they won't actually be charged cash until they're done:

Code:
 
 
<template
id="BuyCustom"
name="Buy - Customize Form"
compset="Transact"
istransaction="yes"
marginvert="3">
 
<portal
id="lblpaid"
style="lblNormal">
<label
text="Amount to Pay: ¥">
</label>
</portal>
 
<portal
id="edtpaid"
style="editCenter">
<edit
field="xactCash"
maxlength="6"
format="integer">
</edit>
</portal>
 
<portal
id="zero"
style="lblNormal">
<label>
<labeltext><![CDATA[
~get the cost of the items - if we're in the middle of a buy
~transaction, the total value is held in the 'accumulated cost' field
~instead.
var moneyvalue as number
moneyvalue = gearpick.field[grCost].value * field[xactQty].value
if (state.iscreate = 0) then
if (gearpick.isbuying + gearpick.isbuychild <> 0) then
moneyvalue = gearpick.field[grPaidTran].value
endif
endif
 
~now get the total cost string
var money as string
call Money
@text = "(" & money & " if zero)"
]]></labeltext>
</label>
</portal>
 
<portal
id="free"
style="chkFree"
tiptext="Check this box to obtain the item for free (e.g. looted, stolen, found, etc.)">
<checkbox
field="xactIsFree"
message="Obtain for Free">
</checkbox>
</portal>
 
<portal
id="funds"
style="lblDisable">
<label>
<labeltext><![CDATA[
var moneyvalue as number
var money as string
 
~during creation, we're using the starting resources
if (state.iscreate <> 0) then
moneyvalue = #resleft[resResourc]
~during advancement, we'll show the character's current cash
else
moneyvalue = herofield[acCashNet].value
endif
 
call Money
@text = "{text clrgrey}(Funds: " & money & ")"
]]></labeltext>
</label>
</portal>
 
<position><![CDATA[
~setup appropriate widths for our edit portals
portal[edtpaid].width = 40
 
~our width is the rightmost extent of the portals
width = portal[lblpaid].width + 3 + portal[edtpaid].width + 10 + portal[zero].width
 
var nexttop as number
~position the amount paid portals at the top
portal[edtpaid].top = 0
perform portal[lblpaid].centeron[vert,edtpaid]
perform portal[zero].centeron[vert,edtpaid]
 
~position the free checkbox and funds portal beneath the payment portals
perform portal[free].alignrel[ttob,edtpaid,10]
perform portal[funds].centeron[vert,free]
 
~position the paid portals horizontally, centered within the span
portal[lblpaid].left = 0
perform portal[edtpaid].alignrel[ltor,lblpaid,3]
perform portal[zero].alignrel[ltor,edtpaid,10]
 
~left- and right-align the free and funds portals within the span
portal[free].left = 0
perform portal[funds].alignedge[right,0]
 
~if we're in creation mode, we don't need to show the amount to pay and free checkboxes
if (state.iscreate <> 0) then
portal[lblpaid].visible = 0
portal[edtpaid].visible = 0
portal[zero].visible = 0
portal[free].visible = 0
 
~move the fund left up a line
portal[funds].top = 0
perform portal[funds].centerhorz
endif
 
~if we don't purchase gear, we only find or are given it, our free checkox
~if locked ON
if (hero.tagis[Hero.Transitory] <> 0) then
portal[free].enable = 0
endif
 
 
~our height is the bottommost extent of the portals
height = portal[funds].bottom
]]></position>
 
</template>
Be careful using that template - some of it is Shadowrun specific, so it includes handling for the fact that in Shadowrun, the way you obtain gear differs between character creation mode and during play.

Last edited by Mathias; April 1st, 2013 at 12:37 PM.
Mathias is online now   #4 Reply With Quote