| 10-17-2006, 03:19 PM | #1 |
ok basically, drag and drop one item onto another, and create another new item, I've look into InvX and try to learn something from it and did a small experimet Result : failed (if sucessed i wont be asking here =.=") First, the setup for the recipe JASS:function Item_Combo takes integer item1id, integer item2id, integer resultid returns nothing local string k1=I2S(item1id) local string k2=I2S(item2id) call StoreInteger(udg_gc,k1,"com"+k2,resultid) call StoreInteger(udg_gc,k2,"com"+k1,resultid) endfunction function SetupInventorySystem takes nothing returns nothing //item combo //the list get longer and longer and so on call Item_Combo('rat6','rat9','ratc') call Item_Combo('dada','dede','boom') // just an example call Item_Combo('dudu','didi','baam') // just an example endfunction //=========================================================================== function InitTrig_Setup_Inventory_System takes nothing returns nothing call ExecuteFunc("SetupInventorySystem") endfunction JASS:function DragDrop takes nothing returns nothing local gamecache g = udg_gc local integer i = GetIssuedOrderId() local unit u = GetTriggerUnit() //-----------------Triggering unit local item x = UnitItemInSlot(u,i-852002) //-------transfering item local item y = GetOrderTargetItem() //-------------targeted item local integer sloty = i-852002 local integer ix = GetItemTypeId(x) local integer iy = GetItemTypeId(y) local string sx = I2S(ix) local string sy = I2S(iy) local integer result if HaveStoredInteger(g,sx,"com"+sy) then set result = GetStoredInteger(g,sx,"com"+sy) call RemoveItem(x) call RemoveItem(y) call UnitAddItemToSlotById(u,result,sloty) endif set g=null set u=null set x=null set y=null set sx=null set sy=null endfunction //=========================================================================== function InitTrig_Inventory_Item_Combine takes nothing returns nothing local trigger t = CreateTrigger() call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER ) call TriggerAddAction( t, function DragDrop ) set t = null endfunction p/s the game shows no error during saving, just not working ![]() |
| 10-17-2006, 03:32 PM | #2 |
currently seems the problem lies with the gc variable, maybe it is not initialized correctly |
| 10-17-2006, 03:38 PM | #3 |
hmmm it seems so, maybe global game cache wont work for this ? because i just extract and modift the triggers... so what should i do ? someting like this ? (go test again... =|) JASS:
call InitGameCacheBJ( "CombineSystem.w3v" )
set udg_gc = GetLastCreatedGameCacheBJ() |
| 10-17-2006, 03:50 PM | #4 |
maybe that is getting initialized after the InitTrig_Setup_Inventory_System is called. Could depend on random World Editor decisions, but if you are initializing it in a trigger with a map initialization event then it surelly would be initialized in the wrong time |
| 10-17-2006, 04:38 PM | #5 |
ah yeah, guess my problem is temporary solved, i moved my main game cache intialisation to this trigger and it seems that things are going fine for now (temporary... =.=) so teacher, is there anyway to make sure the game cache get initialised FIRST before running other initalisation triggers ? |
| 10-17-2006, 06:46 PM | #6 |
As a matter of fact, there is. There are 2 ways one involves some oscure methods to make sure a trigger is compiled first and the other one involves my preprocessor and the //! library command |
