利用箱子道具呼叫Luac。 最大装载量请个别变更。
- local itemBoxLuac = ModuleBase:createModule('itemBoxLuac')
-
- --矿石
-
- 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}
- --铸锭
-
- 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}
- --木材
-
- local woodList = {10000,10001,10002,10003,10004,10005,10006,10007,10008,10009,10010,10011,10100,10101,70200,70201,70202,70203,70204}
- --木材压缩权
-
- local woodSealedList = {70205,70206,70207,70208,70209,70210,70211,70212,70213,70214,70215,70216,70217,70218,70219,70220,70221,70222,70223}
- --草药
-
- local herbList = {12800,12801,12802,12803,12804,12805,12806,12807,12808,12809,12810,12811,70300,70301,70302,70303,70304}
- --草药压缩权
-
- local herbSealedList = {70305,70306,70307,70308,70309,70310,70311,70312,70313,70314,70315,70316,70317,70318,70319,70320,70321}
- --食材5等级为止
-
- local huntTo5RList = {18211,12006,12404,12400,12004,12401,12002,12402,12409,12000,11201,12003,12407,11601,11200,11600,12001,12408,12005}
- --食材压缩权
-
- local huntTo5RSealedList = {12425,12426,12427,12428,12429,12430,12431,12432,12433,12434,12435,12436,12437,12438,12439,12440,12441,12442,12443}
- --食材到15等级为止
-
- local huntTo15RList = {12411,12410,12413,12406,12403,12412,11202,11226,12415,12416,12417,12418,12419,12420,12421,12422,12423,12424}
- --食材压缩权
-
- local huntTo15RSealedList = {12444,12445,12446,12447,12448,12449,12450,12451,12452,12453,12454,12455,12456,12457,12458,12459,12460,12461}
- --织物
-
- local cottonList = {40738,40739,40740,40741,40742,40743,40744,40745,40746,40747,40748,70410,70400,70401,70402,70403,70404}
- --织物压缩权
- local clothList = {10400,10401,10402,10403,10404,10405,10406,10407,10408,10409,10410,10411,70405,70406,70407,70408,70409}
-
- --最大堆叠数
- local oreChange = 20
- local woodChange = 500
- local herbChange = 500
- local huntChange = 500
- local cottonChange = 20
-
- function itemBoxLuac:onLoad()
- self:logInfo('load')
- self:regCallback('ScriptCallEvent', function(npcIndex, playerIndex, text, msg)
- self:logDebug('ScriptCallEvent', npcIndex, playerIndex, text, msg)
- local itemIndex = 0;
- local materialNum = 0;
- local tradeNum = 0;
-
- if text == 'orebox' then
- for i=1, #oreList do
- itemIndex = Char.HaveItem(playerIndex,oreList[i]);
- if itemIndex > -1 then
- materialNum = Char.ItemNum(playerIndex,oreList[i]);
- if materialNum >= Item.GetData(itemIndex, %道具_最大堆叠数%) then
- tradeNum = math.floor(materialNum/oreChange);
- materialNum = tradeNum*oreChange;
- Char.DelItem(playerIndex, oreList[i], materialNum);
- Char.GiveItem(playerIndex, ingotList[i], tradeNum);
- NLG.SortItem(playerIndex);
- end
- end
- end
- return;
- elseif text == 'woodbox' then
- for i=1, #woodList do
- itemIndex = Char.HaveItem(playerIndex,woodList[i]);
- if itemIndex > -1 then
- materialNum = Char.ItemNum(playerIndex,woodList[i]);
- if materialNum >= Item.GetData(itemIndex, %道具_最大堆叠数%) then
- tradeNum = math.floor(materialNum/woodChange);
- materialNum = tradeNum*woodChange;
- Char.DelItem(playerIndex, woodList[i], materialNum);
- Char.GiveItem(playerIndex, woodSealedList[i], tradeNum);
- NLG.SortItem(playerIndex);
- end
- end
- end
- return;
- elseif text == 'herbbox' then
- for i=1, #herbList do
- itemIndex = Char.HaveItem(playerIndex,herbList[i]);
- if itemIndex > -1 then
- materialNum = Char.ItemNum(playerIndex,herbList[i]);
- if materialNum >= Item.GetData(itemIndex, %道具_最大堆叠数%) then
- tradeNum = math.floor(materialNum/huntChange);
- materialNum = tradeNum * herbChange;
- Char.DelItem(playerIndex, herbList[i], materialNum);
- Char.GiveItem(playerIndex, herbSealedList[i], tradeNum);
- NLG.SortItem(playerIndex);
- end
- end
- end
- return;
- elseif text == 'huntto5rbox' then
- for i=1, #huntTo5RList do
- itemIndex = Char.HaveItem(playerIndex,huntTo5RList[i]);
- if itemIndex > -1 then
- materialNum = Char.ItemNum(playerIndex,huntTo5RList[i]);
- if materialNum >= Item.GetData(itemIndex, %道具_最大堆叠数%) then
- tradeNum = math.floor(materialNum/huntChange);
- materialNum = tradeNum * huntChange;
- Char.DelItem(playerIndex, huntTo5RList[i], materialNum);
- Char.GiveItem(playerIndex, huntTo5RSealedList[i], tradeNum);
- NLG.SortItem(playerIndex);
- end
- end
- end
- return;
- elseif text == 'huntto15rbox' then
- for i=1, #huntTo15RList do
- itemIndex = Char.HaveItem(playerIndex,huntTo15RList[i]);
- if itemIndex > -1 then
- materialNum = Char.ItemNum(playerIndex,huntTo15RList[i]);
- if materialNum >= Item.GetData(itemIndex, %道具_最大堆叠数%) then
- tradeNum = math.floor(materialNum/huntChange);
- materialNum = tradeNum*huntChange;
- Char.DelItem(playerIndex, huntTo15RList[i], materialNum);
- Char.GiveItem(playerIndex, huntTo15RSealedList[i], tradeNum);
- NLG.SortItem(playerIndex);
- end
- end
- end
- return;
- elseif text == 'cottonbox' then
- for i=1, #cottonList do
- itemIndex = Char.HaveItem(playerIndex,cottonList[i]);
- if itemIndex > -1 then
- materialNum = Char.ItemNum(playerIndex,cottonList[i]);
- if materialNum >= Item.GetData(itemIndex, %道具_最大堆叠数%) then
- tradeNum = math.floor(materialNum/cottonChange);
- materialNum = tradeNum*cottonChange;
- Char.DelItem(playerIndex, cottonList[i], materialNum);
- Char.GiveItem(playerIndex, clothList[i], tradeNum);
- NLG.SortItem(playerIndex);
- end
- end
- end
- return;
- end
- return -1;
- end)
- end
-
- function itemBoxLuac:onUnload()
- self:logInfo('unload')
- end
-
- return itemBoxLuac;
复制代码
|