_single_stock_item.qsrc 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # $single_stock_item
  2. !! generic function to be used to stock single purchase items in stores
  3. !! see [shop], specifically the household appliances section for an example of use
  4. !! ARGS 0 is the value identifying when the item is owned
  5. !! it is assumed that anything >= the value is acceptable, this allows for upgrades like regular tv to plasma
  6. !! ARGS 1 is the item description
  7. !! ARGS 2 is the price
  8. !! ARGS 3 is the variable name for the item
  9. !! ARGS 4 is the location to go back to
  10. !! ARGS 5 is $metka
  11. !! ARGS 6 > 0 to force-disable buy link
  12. !! ARGS 7 is replacement text for 6
  13. !! ARGS 8 is custom buy link when ARGS 6 > 0
  14. !$location = $ARGS[4]
  15. !! This will check to see if the item is already owned
  16. dynamic 'in_inventory = <<$ARGS[3]>>'
  17. $in_inventory = iif(in_inventory > 0, '<<in_inventory>>', 'none')
  18. $RESULT = '<tr>' + _
  19. '<td align="center"><<FUNC(''$stock_item_info'', $ARGS[3])>></td>' + _
  20. '<td align="center"><<$ARGS[1]>></td>'
  21. if ARGS[6] > 0:
  22. $RESULT += '<td align=left>'+$ARGS[7]+'</td><td align=left>'+$ARGS[8]+'</td>'
  23. elseif ARGS[0] > in_inventory:
  24. $RESULT += '<td align="left">(you have <<$in_inventory>>)</td>'
  25. if money >= ARGS[2]:
  26. $RESULT += '<td align="left"><a href="exec: gs ''$buy_single_item'', <<ARGS[0]>>, ''<<$ARGS[1]>>'', <<ARGS[2]>>, ''<<$ARGS[3]>>'', ''<<$ARGS[4]>>''">buy</a>'
  27. else
  28. $RESULT += '<td></td>'
  29. end
  30. else
  31. $RESULT += '<td colspan=2 align=center>You already own this</td>'
  32. end
  33. $RESULT += '</td><td align="left">for <<ARGS[2]>> <b>₽</b></td></tr>'
  34. --- $single_stock_item ---------------------------------