(WIP) Curious Conundrum / CFD 2012 submission

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
Redweaver
Posts: 68
Joined: Tue Dec 04, 2012 1:13 am
Location: Illinois, USA

Re: (WIP) Curious Conundrum / CFD 2012 submission

Post by Redweaver »

Grimwold wrote:Nope. I suspect this is an old message... the error messages remain on the console until they are cleared. Did you try clicking the "clr" button in the editor to clear the console? then see if the message re-appears.
So THAT is what the "clr" button does?!? So simple. Another "problem" solved! :lol:

Thanks bunches, Grim. Have a virtual version of your favorite beverage on me!
My finished mods:
A Curious Conundrum http://grimrock.nexusmods.com/mods/135 also on Steam Workshop

Current WIP:
Lair of Unarak http://grimrock.nexusmods.com/mods/137
User avatar
Redweaver
Posts: 68
Joined: Tue Dec 04, 2012 1:13 am
Location: Illinois, USA

Re: (WIP) Curious Conundrum / CFD 2012 submission

Post by Redweaver »

How can I make a lever reset to the up/deactivated position immediately after use or upon a button press.

This:

Code: Select all

function resetLevers()
   lever_1:deactivate()
   lever_2:deactivate()
   lever_3:deactivate()
end
Did not do what I thought it would do. :lol:

I need a lua class.
My finished mods:
A Curious Conundrum http://grimrock.nexusmods.com/mods/135 also on Steam Workshop

Current WIP:
Lair of Unarak http://grimrock.nexusmods.com/mods/137
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: (WIP) Curious Conundrum / CFD 2012 submission

Post by Komag »

this page is your friend:
http://www.grimrock.net/modding/scripting-reference/

under Lever there is no lever:deactivate(), but you can use lever:toggle() or setLeverState("deactivated") (but I can't remember if that properly triggers any deactivate connections)
Finished Dungeons - complete mods to play
User avatar
Redweaver
Posts: 68
Joined: Tue Dec 04, 2012 1:13 am
Location: Illinois, USA

Re: (WIP) Curious Conundrum / CFD 2012 submission

Post by Redweaver »

Komag wrote:this page is your friend:
http://www.grimrock.net/modding/scripting-reference/

under Lever there is no lever:deactivate(), but you can use lever:toggle() or setLeverState("deactivated") (but I can't remember if that properly triggers any deactivate connections)
Good to have the reminder that that is there. Tough for me to learn from that, though. I do much better with a more conversational approach, like videos and back and forth forum posts and such. Thanks for pointing me at it again.

Code: Select all

function resetLevers()
   lever_1:setLeverState(deactivated)
   lever_2:setLeverState(deactivated)
   lever_3:setLeverState(deactivated)
end
That didn't do it, either.
My finished mods:
A Curious Conundrum http://grimrock.nexusmods.com/mods/135 also on Steam Workshop

Current WIP:
Lair of Unarak http://grimrock.nexusmods.com/mods/137
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: (WIP) Curious Conundrum / CFD 2012 submission

Post by Komag »

you have to do it like I wrote it, with the quotes, since "deactivated" is a string :)
Finished Dungeons - complete mods to play
User avatar
Redweaver
Posts: 68
Joined: Tue Dec 04, 2012 1:13 am
Location: Illinois, USA

Re: (WIP) Curious Conundrum / CFD 2012 submission

Post by Redweaver »

Komag wrote:you have to do it like I wrote it, with the quotes, since "deactivated" is a string :)
Yeah, caught that just a moment ago.

Code: Select all

function resetLevers()
   lever_1:setLeverState("deactivated")
      lever_1:toggle()
   lever_2:setLeverState("deactivated")
      lever_2:toggle()
   lever_3:setLeverState("deactivated")
      lever_3:toggle()
end
That didn't do it either. The "deactivate" just sets the state, no animation or sound. I just want to put a couple levers back into the "up" position, why is that challenging?



The toggles....yeah, sometimes I'm dense.

Code: Select all

function resetLevers()
   lever_1:setLeverState("deactivated")
   lever_2:setLeverState("deactivated")
   lever_3:setLeverState("deactivated")
end
My finished mods:
A Curious Conundrum http://grimrock.nexusmods.com/mods/135 also on Steam Workshop

Current WIP:
Lair of Unarak http://grimrock.nexusmods.com/mods/137
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: (WIP) Curious Conundrum / CFD 2012 submission

Post by Grimwold »

Just wanted to check that you are sorted with the levers?

If not, are you trying to reset each lever after it has been switched, or reset all three when the puzzle is completed?

To reset each one immediately, you could try adding a connector to itself and setting it to deactivate when the lever is activated (I have not tried this!)

To reset all three after the puzzle is finished you can use setLeverState to do it without animation, or you could use toggle to do it with animation. If only some of the levers will be in the activated state, you could use

Code: Select all

if lever_1:getLeverState() == "activated" then 
  lever_1:toggle() 
end
to only toggle the ones that are activated.
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: (WIP) Curious Conundrum / CFD 2012 submission

Post by Grimwold »

Grimwold wrote: To reset each one immediately, you could try adding a connector to itself and setting it to deactivate when the lever is activated (I have not tried this!)
apparently this doesn't work as levers don't accept activation events... however to get this effect of deactivating instantly you could use the following function

Code: Select all

function leverDeactivate(self)
  self:toggle()
end
and connect each lever to this function AS WELL as any other connections for what the lever should actually do.

This basically turns a lever into a button!!

I realise this is probably not what you want at all, but I find it interesting.
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Re: (WIP) Curious Conundrum / CFD 2012 submission

Post by msyblade »

Redweaver, in the C.A.P. (Community Asset Pack) thread, u can get crismans 3 sockets (left/right eye, and mouth socket) that take ANY gem, and his pack of 9 gems, all together.

Crismans Gems:
viewtopic.php?f=14&t=3752&start=80

Crismans sockets:

viewtopic.php?f=14&t=3411&start=250

or just put this code in your objects.lua (credit to crisman)

Code: Select all

    cloneObject{
                name = "eye_socket_left",
                baseObject = "eye_socket_left",
                onInsertItem = function (self, item)
                             local a, b = string.find (item.name, "_gem")
                             return a ~= nil and b == string.len(item.name)  and self:getItemCount() == 0
                             end,
    }   

    cloneObject{
                name = "eye_socket_right",
                baseObject = "eye_socket_right",
                onInsertItem = function (self, item)
                             local a, b = string.find (item.name, "_gem")
                             return a ~= nil and b == string.len(item.name)  and self:getItemCount() == 0
                             end,
    }   

    cloneObject{
                name = "mouth_socket",
                baseObject = "mouth_socket",
                onInsertItem = function (self, item)
                             local a, b = string.find (item.name, "_gem")
                             return a ~= nil and b == string.len(item.name)  and self:getItemCount() == 0
                             end,
    } 
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
User avatar
Redweaver
Posts: 68
Joined: Tue Dec 04, 2012 1:13 am
Location: Illinois, USA

Re: (WIP) Curious Conundrum / CFD 2012 submission

Post by Redweaver »

msyblade wrote:Redweaver, in the C.A.P. (Community Asset Pack) thread, u can get crismans 3 sockets (left/right eye, and mouth socket) that take ANY gem, and his pack of 9 gems, all together.

Crismans Gems:
viewtopic.php?f=14&t=3752&start=80

Crismans sockets:

viewtopic.php?f=14&t=3411&start=250

or just put this code in your objects.lua (credit to crisman)

Code: Select all

    cloneObject{
                name = "eye_socket_left",
                baseObject = "eye_socket_left",
                onInsertItem = function (self, item)
                             local a, b = string.find (item.name, "_gem")
                             return a ~= nil and b == string.len(item.name)  and self:getItemCount() == 0
                             end,
    }   

    cloneObject{
                name = "eye_socket_right",
                baseObject = "eye_socket_right",
                onInsertItem = function (self, item)
                             local a, b = string.find (item.name, "_gem")
                             return a ~= nil and b == string.len(item.name)  and self:getItemCount() == 0
                             end,
    }   

    cloneObject{
                name = "mouth_socket",
                baseObject = "mouth_socket",
                onInsertItem = function (self, item)
                             local a, b = string.find (item.name, "_gem")
                             return a ~= nil and b == string.len(item.name)  and self:getItemCount() == 0
                             end,
    } 
Perfect! Thanks! Next is tracking down the code to make a door open on a monster's death.
My finished mods:
A Curious Conundrum http://grimrock.nexusmods.com/mods/135 also on Steam Workshop

Current WIP:
Lair of Unarak http://grimrock.nexusmods.com/mods/137
Post Reply