cgmsv引擎论坛

 找回密码
 注册/Sign up
搜索
查看: 435|回复: 2

[LUA] 将收集物全部变形为压缩道具的Luac

[复制链接]

Rank: 1

发表于 2023-8-8 11:55:25 | 显示全部楼层 |阅读模式
利用箱子道具呼叫Luac。 最大装载量请个别变更。


  1. local itemBoxLuac = ModuleBase:createModule('itemBoxLuac')
  2. --矿石
  3. local oreList = {9600,9601,9602,9603,9604,9605,9606,9607,9608,9609,9610,9631,9633,9635,9637,9639,9641,9708,70100,70101,70102,70103,70104,70105}
  4. --铸锭
  5. local ingotList = {9611,9612,9613,9614,9615,9616,9617,9618,9619,9620,9621,9632,9634,9636,9638,9640,9642,9700,70106,70107,70108,70109,70110,70111}
  6. --木材
  7. local woodList = {10000,10001,10002,10003,10004,10005,10006,10007,10008,10009,10010,10011,10100,10101,70200,70201,70202,70203,70204}
  8. --木材压缩权
  9. local woodSealedList = {70205,70206,70207,70208,70209,70210,70211,70212,70213,70214,70215,70216,70217,70218,70219,70220,70221,70222,70223}
  10. --草药
  11. local herbList = {12800,12801,12802,12803,12804,12805,12806,12807,12808,12809,12810,12811,70300,70301,70302,70303,70304}
  12. --草药压缩权
  13. local herbSealedList = {70305,70306,70307,70308,70309,70310,70311,70312,70313,70314,70315,70316,70317,70318,70319,70320,70321}
  14. --食材5等级为止
  15. local huntTo5RList = {18211,12006,12404,12400,12004,12401,12002,12402,12409,12000,11201,12003,12407,11601,11200,11600,12001,12408,12005}
  16. --食材压缩权
  17. local huntTo5RSealedList = {12425,12426,12427,12428,12429,12430,12431,12432,12433,12434,12435,12436,12437,12438,12439,12440,12441,12442,12443}
  18. --食材到15等级为止
  19. local huntTo15RList = {12411,12410,12413,12406,12403,12412,11202,11226,12415,12416,12417,12418,12419,12420,12421,12422,12423,12424}
  20. --食材压缩权
  21. local huntTo15RSealedList = {12444,12445,12446,12447,12448,12449,12450,12451,12452,12453,12454,12455,12456,12457,12458,12459,12460,12461}
  22. --织物
  23. local cottonList = {40738,40739,40740,40741,40742,40743,40744,40745,40746,40747,40748,70410,70400,70401,70402,70403,70404}
  24. --织物压缩权
  25. local clothList = {10400,10401,10402,10403,10404,10405,10406,10407,10408,10409,10410,10411,70405,70406,70407,70408,70409}
  26. --最大堆叠数
  27. local oreChange = 20
  28. local woodChange = 500
  29. local herbChange = 500
  30. local huntChange = 500
  31. local cottonChange = 20
  32. function itemBoxLuac:onLoad()
  33.   self:logInfo('load')
  34.   self:regCallback('ScriptCallEvent', function(npcIndex, playerIndex, text, msg)
  35.         self:logDebug('ScriptCallEvent', npcIndex, playerIndex, text, msg)
  36.         local itemIndex = 0;
  37.         local materialNum = 0;
  38.         local tradeNum = 0;
  39.        
  40.         if text == 'orebox' then
  41.                 for i=1, #oreList do
  42.                         itemIndex = Char.HaveItem(playerIndex,oreList[i]);
  43.                         if itemIndex > -1 then
  44.                                 materialNum = Char.ItemNum(playerIndex,oreList[i]);
  45.                                 if materialNum >= Item.GetData(itemIndex, %道具_最大堆叠数%) then
  46.                                         tradeNum = math.floor(materialNum/oreChange);
  47.                                         materialNum = tradeNum*oreChange;
  48.                                         Char.DelItem(playerIndex, oreList[i], materialNum);
  49.                                         Char.GiveItem(playerIndex, ingotList[i], tradeNum);
  50.                                         NLG.SortItem(playerIndex);
  51.                                 end
  52.                         end
  53.                 end
  54.                 return;
  55.         elseif text == 'woodbox' then
  56.                 for i=1, #woodList do
  57.                         itemIndex = Char.HaveItem(playerIndex,woodList[i]);
  58.                         if itemIndex > -1 then
  59.                                 materialNum = Char.ItemNum(playerIndex,woodList[i]);
  60.                                 if materialNum >= Item.GetData(itemIndex, %道具_最大堆叠数%) then
  61.                                         tradeNum = math.floor(materialNum/woodChange);
  62.                                         materialNum = tradeNum*woodChange;
  63.                                         Char.DelItem(playerIndex, woodList[i], materialNum);
  64.                                         Char.GiveItem(playerIndex, woodSealedList[i], tradeNum);
  65.                                         NLG.SortItem(playerIndex);
  66.                                 end
  67.                         end
  68.                 end
  69.                 return;
  70.         elseif text == 'herbbox' then
  71.                 for i=1, #herbList do
  72.                         itemIndex = Char.HaveItem(playerIndex,herbList[i]);
  73.                         if itemIndex > -1 then
  74.                                 materialNum = Char.ItemNum(playerIndex,herbList[i]);
  75.                                 if materialNum >= Item.GetData(itemIndex, %道具_最大堆叠数%) then
  76.                                         tradeNum = math.floor(materialNum/huntChange);
  77.                                         materialNum = tradeNum * herbChange;
  78.                                         Char.DelItem(playerIndex, herbList[i], materialNum);
  79.                                         Char.GiveItem(playerIndex, herbSealedList[i], tradeNum);
  80.                                         NLG.SortItem(playerIndex);
  81.                                 end
  82.                         end
  83.                 end
  84.                 return;
  85.         elseif text == 'huntto5rbox' then
  86.                 for i=1, #huntTo5RList do
  87.                         itemIndex = Char.HaveItem(playerIndex,huntTo5RList[i]);
  88.                         if itemIndex > -1 then
  89.                                 materialNum = Char.ItemNum(playerIndex,huntTo5RList[i]);
  90.                                 if materialNum >= Item.GetData(itemIndex, %道具_最大堆叠数%) then
  91.                                         tradeNum = math.floor(materialNum/huntChange);
  92.                                         materialNum = tradeNum * huntChange;
  93.                                         Char.DelItem(playerIndex, huntTo5RList[i], materialNum);
  94.                                         Char.GiveItem(playerIndex, huntTo5RSealedList[i], tradeNum);
  95.                                         NLG.SortItem(playerIndex);
  96.                                 end
  97.                         end
  98.                 end
  99.                 return;
  100.         elseif text == 'huntto15rbox' then
  101.                 for i=1, #huntTo15RList do
  102.                         itemIndex = Char.HaveItem(playerIndex,huntTo15RList[i]);
  103.                         if itemIndex > -1 then
  104.                                 materialNum = Char.ItemNum(playerIndex,huntTo15RList[i]);
  105.                                 if materialNum >= Item.GetData(itemIndex, %道具_最大堆叠数%) then
  106.                                         tradeNum = math.floor(materialNum/huntChange);
  107.                                         materialNum = tradeNum*huntChange;
  108.                                         Char.DelItem(playerIndex, huntTo15RList[i], materialNum);
  109.                                         Char.GiveItem(playerIndex, huntTo15RSealedList[i], tradeNum);
  110.                                         NLG.SortItem(playerIndex);
  111.                                 end
  112.                         end
  113.                 end
  114.                 return;
  115.         elseif text == 'cottonbox' then
  116.                 for i=1, #cottonList do
  117.                         itemIndex = Char.HaveItem(playerIndex,cottonList[i]);
  118.                         if itemIndex > -1 then
  119.                                 materialNum = Char.ItemNum(playerIndex,cottonList[i]);
  120.                                 if materialNum >= Item.GetData(itemIndex, %道具_最大堆叠数%) then
  121.                                         tradeNum = math.floor(materialNum/cottonChange);
  122.                                         materialNum = tradeNum*cottonChange;
  123.                                         Char.DelItem(playerIndex, cottonList[i], materialNum);
  124.                                         Char.GiveItem(playerIndex, clothList[i], tradeNum);
  125.                                         NLG.SortItem(playerIndex);
  126.                                 end
  127.                         end
  128.                 end
  129.                 return;
  130.         end
  131.     return -1;
  132.   end)
  133. end
  134. function itemBoxLuac:onUnload()
  135.   self:logInfo('unload')
  136. end
  137. return itemBoxLuac;
复制代码
0001.png

0002.png



itemBoxLuac.zip

34.68 KB, 下载次数: 0, 下载积分: 金币 -1

Rank: 1

 楼主| 发表于 2023-8-10 22:33:39 | 显示全部楼层

水曜之域
沒有 data, 所以任意添加...
您需要登录后才可以回帖 登录 | 注册/Sign up

本版积分规则

手机版|cgmsv引擎论坛

GMT+8, 2024-5-19 06:12 , Processed in 0.160735 second(s), 11 queries , Gzip On, MemCached On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表