Thursday, April 19, 2012

Drag and drop item combination

There are a few map with this system, but as usual they are protected.

What does it do?: i'll explain it with and example:

------------------------------------------------

I have 2 items of the same type in the inventory (2 potion of healing, one with 5 charges and one with 2 charges). I do a right click on one, move the item on top of the other and finally a left click on it. Now i have a single potion of healing with 7 charges in the inventory.

------------------------------------------------



I can't find a way to make this trigger because i don't know which Event will run the accions.

How do i make accions to run when im moving items in the inventory?

CHUNK WHERE ARE YOU??!!|||i'm not sure if this will address your problem, but to avoid this situation from occuring where two of the same items appearing in your inventory which are charged, use the event aqcuire item, and condition item is a consumable classification, and also item equals to item in slot 1 or 2 or 3 etc... , this will check if you already have the item if so then do event - set charge equal to current charge + the new one, and thus they merge together like in dota.|||Do you mean when you purchase Tangos in Dota? No, i DONT want the items to combinate themself automatically when i have 2 or more of the same type the inventory.

I want to do it manually with the drag and drop method.|||Finally i figured it out...


Code:
Untitled Trigger 001
Events
Unit - A unit Is issued an order targeting an object
Conditions
Potion of Healing Equal to (Item-type of (Target item of issued order))
(Target item of issued order) Equal to (Item carried by (Ordered unit) in slot 1)
Actions
Wait 0.00 seconds
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Target item of issued order) Equal to (Item carried by (Ordered unit) in slot 2)
Potion of Healing Equal to (Item-type of (Item carried by (Ordered unit) in slot 1))
Then - Actions
Item - Set charges remaining in (Item carried by (Ordered unit) in slot 2) to ((Charges remaining in (Item carried by (Ordered unit) in slot 2)) + (Charges remaining in (Item carried by (Ordered unit) in slot 1)))
Item - Remove (Item carried by (Ordered unit) in slot 1)
Else - Actions
Do nothing
Skip remaining actions



Every Potion of Healing from slot 1 that you drag and drop into the slot 2 (where there is another Potion of Healing) will be combined.

Making this trigger for all item slots combination (30) will be long.

Suggestions? Any way to make less triggers? or perhaps a better trigger...

PD.: if i remove the Action "Wait 0.00 seconds", nothing works.|||The most efficient method would be to use a Integer Loop (1 to 6) to scan all the inventory slots, and use an if/then in the loop to check if the item in slot (int a) is the target item of the order or matching item type of the targeted item.|||Quote:






View Post

CHUNK WHERE ARE YOU??!!




At work.

I'd help, but I've never used a system where you track moving items within the inventory, so I'd need to clear some time to do some actual testing in order to make sure what I was suggesting works - and I haven't had that kind of time recently. Try ST's suggestions and maybe I will have some spare time later tonight to try some things and make some suggestions about how to improve your code.|||I've designed a very simple, elegant trigger that functions perfectly and is very compact - but unfortunately, it requires the use of my customized World Editor, or at least a modified one, because it converts orders to integers (required to detect the destination slot) and that isn't an option in the standard WE.

However, I converted that trigger to JASS and here's a link to the map with the code converted: http://www.jx3.net/TDG/stuff/DragandDropJASS.w3x

Let me know if it won't open or there is some problem with it. Seemed to be working fine for me when I tested it after converting.|||Your trigger works great.

Can you tell me what do i need to see the actual trigger? I only understand some random things from Jass.

I made my triggers too. Its not an elegant trigger like yours but it works fine. Check it out.

http://rapidshare.com/files/79806503...ion_2.w3x.html|||The underlying trigger just converts the order to an integer. Some orders have no orderstring, but the unit is issued an order and that order occurs in the form of a number. In this case, the order to move an item to a slot is #85200X where the slot number +1 fills the X value. So the order to put something in slot 1 is #852002, slot 2 is #852003, slot 3 is #852004, etc.

There's a JASS function that does this, but no comparable GUI function - so for our editor, Shvegait (in this case) took the JASS function and made a custom GUI action for it. In some cases, you can get around this sort of step by just using a custom script line in a trigger - but in this case the custom script function actually occurs in a condition and there's no option in the standard editor for adding a custom script condition - which is why I couldn't show you the trigger in a non-JASS format.

I can, however, let you see what it would look like if you had modified your editor to allow integer to order conversions:


Code:
Drag and Drop Items TDGWE
Events
Unit - A unit Is issued an order targeting an object
Conditions
(Charges remaining in (Target item of issued order)) Greater than 0
(Number of items carried by (Ordered unit)) Greater than 1
Or - Any (Conditions) are true
Conditions
(Item carried by (Ordered unit) in slot 1) Equal to (Target item of issued order)
(Item carried by (Ordered unit) in slot 2) Equal to (Target item of issued order)
(Item carried by (Ordered unit) in slot 3) Equal to (Target item of issued order)
(Item carried by (Ordered unit) in slot 4) Equal to (Target item of issued order)
(Item carried by (Ordered unit) in slot 5) Equal to (Target item of issued order)
(Item carried by (Ordered unit) in slot 6) Equal to (Target item of issued order)
Actions
For each (Integer A) from 1 to 6, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Issued order) Equal to (Order((852001 + (Integer A))))
(Item carried by (Ordered unit) in slot (Integer A)) Not equal to (Target item of issued order)
(Item-type of (Item carried by (Ordered unit) in slot (Integer A))) Equal to (Item-type of (Target item of issued order))
Then - Actions
Item - Set charges remaining in (Target item of issued order) to ((Charges remaining in (Target item of issued order)) + (Charges remaining in (Item carried by (Ordered unit) in slot (Integer A))))
Item - Remove (Item carried by (Ordered unit) in slot (Integer A))
Else - Actions

The event is obvious. The conditions are set up to keep the trigger from running when it isn't necessary (only charged items, more than one item in the inventory, and only items being moved around in the inventory). Then the actions are a simple comparison to make sure that the unit is moving the item to a new slot (you don't want the item lost if they move it to the slot it is currently in) and then a comparison between the item being moved and the item-type at the destination slot. Then the whole thing is looped for all 6 slots so it works everywhere.

----------------------------------

If you are interested in modding your own WE to be able to do this, I can tell you the JASS components you would need to add the function if you wanted to follow Shve's tutorial on modding the editor:

You'd need to add this function to the custom script area of the map (found by clicking the map icon with the map name at the top of the trigger module):


Code:
function I2Ocode takes integer i returns integer
return i
endfunction

This takes the order as an integer and returns it as an integer. It sounds odd, but that's what you need to do in this case to see the integer.

And then you just need to add some lines to the TriggerData.txt and TriggerStrings.txt files (if you follow the tutorial, you'd understand that part). In ours, those lines look like this for TriggerData.txt

Under categories:


Code:
TC_EXTRA=WESTRING_TRIGCAT_EXTRA,ReplaceableTextures\WorldEditUI\Actions-Logical

Under trigger calls:


Code:
I2Ocode=1,0,ordercode,integer
_I2Ocode_Defaults=_
_I2Ocode_Category=TC_EXTRA

and this for TriggerStrings.txt under Trigger Call Strings:


Code:
I2Ocode="Convert Integer To Order"
I2Ocode="Order(",~Integer,")"
I2OcodeHint="Useful for retrieving integer-based types."

Modding the editor is pretty easy if you are willing to take the time to read through that tutorial.|||I know this is an old post, but had a thought about the integer to order conversions in GUI...

instead of using:

(Issued order) Equal to (Order((852001 + (Integer A))))

you could use:

Custom script: set udg_someintegervariable = GetIssuedOrderId()

If (All Conditions are True) then do (Then Actions) else do (Else Actions)

If - Conditions

someintegervariable Equal to (852001 + (Integer A))

Just my 2 cents :)|||I accept: The underlying trigger just converts the order to an integer. Some orders have no orderstring, but the unit is issued an order and that order occurs in the form of a number.

_____________________

Credit assurance pret immobilier emprunt banquaire | Comparatif assurance pret immobilier taux credit simulation | Credit assurance pret immobilier

No comments:

Post a Comment