1
0

_single_stock_item 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. !$location = $ARGS[4]
  14. !! This will check to see if the item is already owned
  15. dynamic 'in_inventory = <<$ARGS[3]>>'
  16. $in_inventory = iif(in_inventory > 0, '<<in_inventory>>', 'none')
  17. !dynamic "$in_inventory = iif(<<$ARGS[3]>> > 0, <<$ARGS[3]>>, '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 colspan=2 align=center>'+$ARGS[7]+'</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 ---------------------------------