Page 400 of 400

Re: Ask a simple question, get a simple answer

Posted: Sun Feb 02, 2025 10:28 am
by minmay
MonsterComponent has a die() method, you don't need to make your own method for killing a monster.

Re: Useful scripts repository

Posted: Sat Apr 19, 2025 7:41 pm
by supercell1970
I need help with this script. It is probably the wrong forum to post in on here but having trouble finding where to post.
I keep getting this error message and need help to get the script right.

Code: Select all

sDone = false
shownOnce = false
gotTreasure = false
questAccepted = false
questComplete = false

function fight()
    local ratling = findEntity("dialogue_demo_ratling")
    if (ratling) then
        ratling.brain:enable()
    end
    isDone = true
end

function treasure()
    setMouseItem(spawn("cheese").item)
    isDone = true
end

function hasItem()
    local champion = party:getChampion(0) -- Slot 0 = first champion "The getChampion error is nil"

    -- Loop through all items in the champion's inventory
    for i = 1, 32 do -- Each champion has up to 32 inventory slots
        local item = champion:getItem(i)
        if item and item.go.name == "gold_key" then
            return true
        end
    end

    return false
end
edit by Zo Kath Ra:
I've moved your post to a topic where it should feel more at home :D
And taken the liberty of formatting your code with a https://duckduckgo.com/?t=lm&q=lua+beautifier

Re: Useful scripts repository

Posted: Sat Apr 19, 2025 10:48 pm
by Isaac
supercell1970 wrote: Sat Apr 19, 2025 7:41 pm I keep getting this error message and need help to get the script right.
What error message(s), and can you elaborate upon exactly how this script is used, aside from it enabling the ratling. and searching the champion's inventory for the key?

Re: Ask a simple question, get a simple answer

Posted: Sun Jun 15, 2025 8:31 am
by Slava
I keep getting this error message and need help to get the script right.
Your problem is this

Code: Select all

party:getChampion(0)
In Lua arrays start with 1. So the index of the first champion will be 1 and not 0