Page 1 of 1
triggers wtih Inventory:getItemCount wont work
Posted: Sun Oct 30, 2011 9:02 am
by Germangold
hy guys
strange problem
i used to autosell my items when bagspace is all occupied like this
Code: Select all
if (inventory:getItemCount(0) < 6) then -- goto repairs, less then 6 slots aviable
__WPL:setWaypointIndex(__WPL:findWaypointTag("repairs"));
end
but it wont work for me anymore
svn is 670 newest one
then i tried this
Code: Select all
_emptyspace = inventory:getItemCount(0);
printf("Your empty bagspace is:\n ", _emptyspace);
but wont really retunr anything:
Your empty bagspace is:
is a blank space
Re: triggers wtih Inventory:getItemCount wont work
Posted: Sun Oct 30, 2011 9:29 am
by rock5
I never used < myself but I just did a bit of testing. Looks like you can only use it in xml files and NOT between <![CDATA[ and ]]> tags. Are you posibly trying to use it between those tags or in an lua file?
Re: triggers wtih Inventory:getItemCount wont work
Posted: Sun Oct 30, 2011 10:05 am
by Germangold
hi rock5
i am using it inbeetwen a waypoint
Code: Select all
<!-- # 88 --><waypoint x="-11510" z="42556" y="709">
if (inventory:getItemCount(0) < 6) then -- goto repairs, less then 6 slots aviable
__WPL:setWaypointIndex(__WPL:findWaypointTag("repairs"));
end
__WPL:setWaypointIndex(__WPL:findWaypointTag("fromthestart")); </waypoint>
-- repairs
<!-- # 16 --><waypoint x="-11352" z="42478" y="721" tag="repairs"></waypoint>
<!-- # 15 --><waypoint x="-11479" z="42522" y="717"> </waypoint>
<!-- # 14
this waypoint filed worked really fine before
Re: triggers wtih Inventory:getItemCount wont work
Posted: Sun Oct 30, 2011 11:14 am
by rock5
That doesn't look right. The thing you have to understand is if you change the waypoint index, or even load a new waypoint file, the rest of the code at the waypoint will still finish being executed.
So in your example above, if you have less than 6 spaces left it changes to the "repairs" waypoint but then immediately changes it to "fromthestart" regardless. If you use an "if then
else end" construct that would fix it but if the repairs path immediately follows that code, I would write it like this.
Code: Select all
<!-- # 88 --><waypoint x="-11510" z="42556" y="709">
if (inventory:getItemCount(0) > 5) then -- Still got space, go again
__WPL:setWaypointIndex(__WPL:findWaypointTag("fromthestart"));
end
</waypoint>
-- repairs
<!-- # 16 --><waypoint x="-11352" z="42478" y="721"></waypoint>
<!-- # 15 --><waypoint x="-11479" z="42522" y="717"> </waypoint>
<!-- # 14