Re: Useful scripts repository
Posted: Sat Aug 13, 2016 7:46 pm
mbmpf...
Welp I am an idiot xDTHOM wrote:You can't do this with standard-commands. You have to write a print-text-on-screen-function by your own. But out of the hat I have no solution how to do that...
hudPrint has a given time.
This simply does not work. I have tried everything and tested every scenario possible. My guess is that in the course of 6 years since this was posted, some of the variables have changed and thus, are returning nil values. No matter what I do, any item I pick up and place in inventory doesn't trigger the script to execute the true function.Billick wrote:A couple of script functions I wrote to check if anybody in your party is carrying a particular type of item:
The first function calls the second function. Pass in the name of the item you want to check for into checkForItemParty. You would use it like this:Code: Select all
function checkForItemParty(item) local i = 1 repeat if checkForItem(party:getChampion(i), item) then return true end i = i + 1 until i == 5 return false end function checkForItem(champion, item) local i = 1 repeat local itemObj = champion:getItem(i) if itemObj ~= nil then if itemObj.name == item then return true end end i = i+1 until i == 32 return false end
Edit: fixed invalid function namesCode: Select all
if checkForItemParty("torch") then print("We have a torch") else print("We don't have a torch") end
Code: Select all
function check()
if checkForItemParty("torch")
then print("We have a torch")
else print("We don't have a torch")
end
end
Code: Select all
function checkForItemParty(item)
local i = 1
repeat
local test, championName = checkForItem(party:getChampion(i), item)
if test --successful
then return true, championName
end
i = i + 1
until i == 5
return false
end
function checkForItem(champion, item)
local i = 1
repeat
local itemObj = champion:getItem(i)
if itemObj ~= nil then
if itemObj.name == item
then return true, champion:getName()
end
end
i = i+1
until i == 32
return false
end
function checkByTrigger(triggerId)
if triggerId and triggerId.id then
local index = triggerId.id:find("@")
local item = "<no item>"
if index and index < #triggerId.id then
item = triggerId.id:sub(index+1)
else print("Error: no index character in trigger object id")
end
local test, championName = checkForItemParty(item)
if item then
---[[
print(championName,"has the item :"..item)
--]]
else print(championName,"doesn't have the item :"..item)
end
return
end
print('Error: table expected, got', triggerId," ")
end