Lua:
function ResourceDropGetInitalize()
local i = 0
local trigger = CreateTrigger()
print("started resource drop get init")
local ResourceDropGetConditions = function()
print("Resource Picked Up")
local item = GetItemTypeId(GetManipulatedItem())
print("Picked up "..GetItemName(item))
correctitem = false
for i = 1, 6, 1 do
if item == CraftItemTable[i] then
return true
end
end
end
local ResourceDropGetActions = function()
local i
local item = GetItemTypeId(GetManipulatedItem())
local itemindex
for i = 1, 6, 1 do
if item == CraftItemTable[i] then
itemindex = i
break
end
end
UpdateHeroData(itemindex, 1)
print("Resource Updated")
end
i = 0
while true do
if i > MaxPlayerIndex then
break
end
print("testing player "..i.."playstate")
if (GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING) then
dCall(TriggerRegisterPlayerUnitEventSimple(trigger, Player(i), EVENT_PLAYER_UNIT_PICKUP_ITEM), "ResourceDropEvent Added")
print("player"..i.."player unit event established")
end
i = i + 1
end
print("adding resource conditions")
dCall(TriggerAddCondition(trigger, Condition(ResourceDropGetConditions)),"ResourceDropConditions Added")
print("adding resource actions")
dCall(TriggerAddAction(trigger, ResourceDropGetActions),"ResourceDropAction Added")
end
So that is my code, dCall just does an xpcall and prints the error plus the string shown.
With my xpcalls I get these errors, although it runs through all of the code and has no problem looking at the player state.
attempt to call event value
attempt to call triggercondition value
attempt to call triggeraction value.
I just came back to working on this project from a long absence. I thought this system worked fine before, but it didn't do anything when I've come back so I added these xpcalls to try and figure out the problem, but this leaves me at a loss for what to try next.