Exide
I am amazingly focused right now!
- Reaction score
- 448
Hi.
I made a thread about counting number of items (strings) a few weeks ago.
Siretu helped me and my triggers works great.
There is a small problem, though.
The trigger Siretu made for me does something like this:
*takes one item
*finds another one
*stacks them together
*forget the first item
*repeat until there are no more items of the same type
This is good except for one thing:
When I try to access InventoryAmount[*] it returns "0"
If I got 6 items of "Type A" the list will look something like this:
InventoryAmount[1] = 0
InventoryAmount[2] = 0
InventoryAmount[3] = 0
InventoryAmount[4] = 0 //All six of these are the same type of item
InventoryAmount[5] = 0
InventoryAmount[6] = 6
So my triggers (aka me) is having trouble knowing where to look for the correct array for each item.
Here are the triggers:
In another trigger I'm doing this:
(In the following trigger I have used another trigger to create buttons, that is why I have to loop through them all to check which one is used.)
and finally, I'm trying to use the info in a third trigger:
The variables to look out for are:
InventoryAmount[], UsedItemNumber and UsedItem
the rest of the code is not important.
What happens:
In the third trigger, I can't find the correct InventoryAmount[] array value: resulting in the game returning 0 and "closing the pop-up screens."
EDIT: I think I have found the problem, but I'm not sure how to fix it.
In this trigger:
When I create "Use" buttons -I believe I create one button for each item (unlike Siretu's count trigger which stack items and remove the other value). Meaning for six items of the same type I create six different buttons. When I then loop through them all my trigger finds the first button and reacts to it; setting UsedItemNumber to that number - when the item is actually stacked up on number six.
I believe adding a way to remove unnecessary buttons created this way will fix my problem.
I made a thread about counting number of items (strings) a few weeks ago.
Siretu helped me and my triggers works great.
There is a small problem, though.
The trigger Siretu made for me does something like this:
*takes one item
*finds another one
*stacks them together
*forget the first item
*repeat until there are no more items of the same type
This is good except for one thing:
When I try to access InventoryAmount[*] it returns "0"
If I got 6 items of "Type A" the list will look something like this:
InventoryAmount[1] = 0
InventoryAmount[2] = 0
InventoryAmount[3] = 0
InventoryAmount[4] = 0 //All six of these are the same type of item
InventoryAmount[5] = 0
InventoryAmount[6] = 6
So my triggers (aka me) is having trouble knowing where to look for the correct array for each item.
Here are the triggers:
Trigger:
- InventoryItemCheckAmount
- Events
- Local Variables
- loop = 0 <Integer>
- secondloop = 0 <Integer>
- checkname = "" <String[99]>
- Conditions
- Actions
- General - For each integer loop from 1 to 99 with increment 1, do (Actions)
- Actions
- Variable - Set InventoryAmount[loop] = 0
- Actions
- General - For each integer loop from 1 to 99 with increment 1, do (Actions)
- Actions
- Variable - Set checkname[loop] = InventoryItem[loop]
- General - For each integer secondloop from 1 to 99 with increment 1, do (Actions)
- Actions
- General - If (Conditions) then do (Actions) else do (Actions)
- If
- checkname[secondloop] == checkname[loop]
- checkname[secondloop] != ""
- Then
- Variable - Set InventoryAmount[secondloop] = (InventoryAmount[secondloop] + 1)
- General - If (Conditions) then do (Actions) else do (Actions)
- If
- loop != secondloop
- Then
- Variable - Set checkname[loop] = ""
- Else
- If
- Else
- If
- General - If (Conditions) then do (Actions) else do (Actions)
- Actions
- Actions
- General - For each integer loop from 1 to 99 with increment 1, do (Actions)
In another trigger I'm doing this:
(In the following trigger I have used another trigger to create buttons, that is why I have to loop through them all to check which one is used.)
Trigger:
- Inventory UseItem
- Events
- Dialog - Any Dialog Item is used by Player Any Player with event type Clicked
- Local Variables
- loop = 0 <Integer>
- Conditions
- CombatCheck == False
- Actions
- General - For each integer loop from 1 to 99 with increment 1, do (Actions)
- Actions
- General - If (Conditions) then do (Actions) else do (Actions)
- If
- (Used dialog item) == InventoryItemUseButton[loop]
- Then
- Trigger - Run Inventory Set UseItemStats (Ignore Conditions, Don't Wait until it finishes)
- Trigger - Turn (Current trigger) Off
- Variable - Set UsedItem = InventoryItem[loop]
- Variable - Set UsedItemNumber = loop
- Dialog - Set MenuUseItemDialogItem[5] text to ("Choose hero to use " + (("<c val="00FFFF">" + ((Text(UsedItem)) + "</c>")) + " on.")) for (All players)
- Dialog - Show MenuUseItemDialog for (All players)
- Dialog - Show MenuUseItemStatsDialog for (All players)
- General - Break
- Else
- If
- General - If (Conditions) then do (Actions) else do (Actions)
- Actions
- General - For each integer loop from 1 to 99 with increment 1, do (Actions)
- Events
and finally, I'm trying to use the info in a third trigger:
Trigger:
- General - If (Conditions) then do (Actions) else do (Actions)
- If
- InventoryAmount[UsedItemNumber] <= 0
- Then
- ------- No more items of that type, closing the pop-up screens
- Variable - Set UsedItem = ""
- Dialog - Hide MenuUseItemDialog for (All players)
- Dialog - Hide MenuUseItemStatsDialog for (All players)
- Trigger - Turn Inventory UseItem On
- Else
- If
The variables to look out for are:
InventoryAmount[], UsedItemNumber and UsedItem
the rest of the code is not important.
What happens:
In the third trigger, I can't find the correct InventoryAmount[] array value: resulting in the game returning 0 and "closing the pop-up screens."
EDIT: I think I have found the problem, but I'm not sure how to fix it.
In this trigger:
Trigger:
- Menu Inventory
- Events
- Local Variables
- usebuttoncheck = False <Boolean>
- loop = 0 <Integer>
- i = 35 <Integer>
- Conditions
- Actions
- Trigger - Turn Open Menu Off
- Trigger - Run InventoryItemCheckAmount (Ignore Conditions, Don't Wait until it finishes)
- General - For each integer loop from 1 to 99 with increment 1, do (Actions)
- Actions
- Dialog - Destroy InventoryItemLabelName[loop]
- Dialog - Destroy InventoryItemLabelDescription[loop]
- Dialog - Destroy InventoryItemLabelAmount[loop]
- Dialog - Destroy InventoryItemLabelValue[loop]
- Dialog - Destroy InventoryItemUseButton[loop]
- Actions
- General - For each integer loop from 1 to 99 with increment 1, do (Actions)
- Actions
- General - If (Conditions) then do (Actions) else do (Actions)
- If
- InventoryItem[loop] != ""
- Then
- Variable - Set usebuttoncheck = (InventoryUseButtonCheck(InventoryItem[loop]))
- General - If (Conditions) then do (Actions) else do (Actions)
- If
- usebuttoncheck == True
- Then
- General - If (Conditions) then do (Actions) else do (Actions)
- If
- CombatCheck == False
- Then
- ------- Create "Use" Button
- Dialog - Create a button for dialog MenuInventoryDialog with the dimensions (50, 23) anchored to Top Left with an offset of (40, (85 + i)) setting the tooltip to "" with button text "Use" and the hover image set to ""
- Variable - Set InventoryItemUseButton[loop] = (Last created dialog item)
- Else
- If
- General - If (Conditions) then do (Actions) else do (Actions)
- Else
- If
- Dialog - Create a label for dialog MenuInventoryDialog with the dimensions (200, 50) anchored to Top Left with an offset of (100, (85 + i)) with the text (Text(InventoryItem[loop])) color set to White text writeout set to False with a writeout duration of 0.0
- Variable - Set InventoryItemLabelName[loop] = (Last created dialog item)
- Dialog - Create a label for dialog MenuInventoryDialog with the dimensions (400, 50) anchored to Top Left with an offset of (300, (85 + i)) with the text (Text((InventoryItemGetDescription(InventoryItem[loop])))) color set to White text writeout set to False with a writeout duration of 0.0
- Variable - Set InventoryItemLabelDescription[loop] = (Last created dialog item)
- Dialog - Create a label for dialog MenuInventoryDialog with the dimensions (200, 50) anchored to Top Left with an offset of (700, (85 + i)) with the text (Text(InventoryAmount[loop])) color set to White text writeout set to False with a writeout duration of 0.0
- Variable - Set InventoryItemLabelAmount[loop] = (Last created dialog item)
- Dialog - Create a label for dialog MenuInventoryDialog with the dimensions (200, 50) anchored to Top Left with an offset of (900, (85 + i)) with the text (Text((InventoryItemValueCheck(InventoryItem[loop])))) color set to White text writeout set to False with a writeout duration of 0.0
- Variable - Set InventoryItemLabelValue[loop] = (Last created dialog item)
- Variable - Set i = (i + 20)
- General - If (Conditions) then do (Actions) else do (Actions)
- If
- InventoryAmount[loop] == 0
- Then
- Dialog - Destroy InventoryItemLabelName[loop]
- Dialog - Destroy InventoryItemLabelDescription[loop]
- Dialog - Destroy InventoryItemLabelAmount[loop]
- Dialog - Destroy InventoryItemLabelValue[loop]
- Dialog - Destroy InventoryItemUseButton[loop]
- Variable - Set i = (i - 20)
- Else
- If
- Else
- If
- General - If (Conditions) then do (Actions) else do (Actions)
- Actions
- Dialog - Show MenuInventoryDialog for (All players)
When I create "Use" buttons -I believe I create one button for each item (unlike Siretu's count trigger which stack items and remove the other value). Meaning for six items of the same type I create six different buttons. When I then loop through them all my trigger finds the first button and reacts to it; setting UsedItemNumber to that number - when the item is actually stacked up on number six.
I believe adding a way to remove unnecessary buttons created this way will fix my problem.