Ask a simple question, get a simple answer

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

MonsterComponent has a die() method, you don't need to make your own method for killing a monster.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
supercell1970
Posts: 7
Joined: Mon Mar 11, 2024 11:44 pm

Re: Useful scripts repository

Post 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
User avatar
Isaac
Posts: 3190
Joined: Fri Mar 02, 2012 10:02 pm

Re: Useful scripts repository

Post 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?
Post Reply

Return to “Mod Creation”