system.lua 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. FFVII.set_party = function( character1, character2, character3 )
  2. FFVII.Party[ 1 ] = character1
  3. FFVII.Party[ 2 ] = character2
  4. FFVII.Party[ 3 ] = character3
  5. end
  6. FFVII.is_character = function( character )
  7. if FFVII.Characters[ character ] == nil then
  8. return false
  9. end
  10. return true
  11. end
  12. FFVII.add_party_character = function( character )
  13. if FFVII.Characters[ character ] == nil then
  14. print( "Tried add to party invalid character \"" .. character .. "\"." );
  15. return
  16. end
  17. if FFVII.Characters[ character ].party_lock == true then
  18. print( "Tried add to party locked character \"" .. character .. "\"." );
  19. return
  20. end
  21. -- check if character already in party
  22. for x = 1, 3 do
  23. if FFVII.Party[ i ] == character then
  24. print( "Character \"" .. character .. "\" already in party." );
  25. return
  26. end
  27. end
  28. -- try to add in first free slot
  29. for x = 1, 3 do
  30. if FFVII.Party[ i ] == nil then
  31. FFVII.Party[ i ] = character
  32. return
  33. end
  34. end
  35. end
  36. FFVII.remove_party_character = function( character )
  37. if FFVII.Characters[ character ] == nil then
  38. print( "Tried remove from party invalid character \"" .. character .. "\"." );
  39. return
  40. end
  41. if FFVII.Characters[ character ].party_lock == true then
  42. print( "Tried remove from party locked character \"" .. character .. "\"." );
  43. return
  44. end
  45. for x = 1, 3 do
  46. if FFVII.Party[ i ] == character then
  47. FFVII.Party[ i ] = nil
  48. return
  49. end
  50. end
  51. end
  52. FFVII.set_party_lock = function( character, lock )
  53. if FFVII.Characters[ character ] == nil then
  54. print( "Tried set/unset party lock to invalid character \"" .. character .. "\"." );
  55. return
  56. end
  57. FFVII.Characters[ character ].party_lock = lock;
  58. end
  59. FFVII.get_party_lock = function( character )
  60. if FFVII.Characters[ character ] == nil then
  61. print( "Tried get party lock from invalid character \"" .. character .. "\"." );
  62. return false
  63. end
  64. return FFVII.Characters[ character ].party_lock
  65. end
  66. FFVII.set_character_enable = function( character, enable )
  67. if FFVII.Characters[ character ] == nil then
  68. print( "Tried enable/disable invalid character \"" .. character .. "\"." );
  69. return
  70. end
  71. FFVII.Characters[ character ].enable = enable;
  72. end
  73. FFVII.get_character_enable = function( character )
  74. if FFVII.Characters[ character ] == nil then
  75. print( "Tried get enabled from invalid character \"" .. character .. "\"." );
  76. return false
  77. end
  78. return FFVII.Characters[ character ].enable;
  79. end
  80. FFVII.add_item = function( item, quantity )
  81. if FFVII.Items[ item ] == nil then
  82. print( "Tried add invalid item \"" .. item .. "\"." );
  83. return
  84. end
  85. local old_quantity = 0
  86. if FFVII.ItemStorage[ item ] ~= nil then
  87. old_quantity = FFVII.ItemStorage[ item ]
  88. end
  89. FFVII.ItemStorage[ item ] = old_quantity + quantity
  90. if FFVII.ItemStorage[ item ] > 99 then
  91. FFVII.ItemStorage[ item ] = 99
  92. end
  93. end
  94. FFVII.get_item_quantity = function( item )
  95. if FFVII.Items[ item ] == nil then
  96. print( "Tried get quontity for invalid item \"" .. item .. "\"." );
  97. return
  98. end
  99. local quantity = 0
  100. if FFVII.ItemStorage[ item ] ~= nil then
  101. quantity = FFVII.ItemStorage[ item ]
  102. end
  103. return quantity
  104. end
  105. FFVII.remove_item = function( item, quantity )
  106. if FFVII.Items[ item ] == nil then
  107. print( "Tried remove invalid item \"" .. item .. "\"." );
  108. return
  109. end
  110. local old_quantity = 0
  111. if FFVII.ItemStorage[ item ] ~= nil then
  112. old_quantity = FFVII.ItemStorage[ item ]
  113. end
  114. FFVII.ItemStorage[ item ] = old_quantity - quantity
  115. if FFVII.ItemStorage[ item ] < 0 then
  116. FFVII.ItemStorage[ item ] = 0
  117. end
  118. end
  119. FFVII.add_money = function( amount )
  120. FFVII.Savemap.money = FFVII.Savemap.money + amount
  121. if FFVII.Savemap.money > 999999 then
  122. FFVII.ItemStorage[ item ] = 999999
  123. end
  124. end
  125. FFVII.get_money = function()
  126. return FFVII.Savemap.money
  127. end
  128. FFVII.remove_money = function( amount )
  129. FFVII.Savemap.money = FFVII.Savemap.money - amount
  130. if FFVII.Savemap.money < 0 then
  131. FFVII.ItemStorage[ item ] = 0
  132. end
  133. end