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!
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

You don't need to mess with the definition of dm_lock_coinslot at all. That functionality is already present, as explained in the comment directly above the definition:

Code: Select all

-- The coinslot consumes one coin with each click, decrementing coinsNeeded by 1
-- each time, until it reaches 0. Connectors added to the lock will trigger
-- every time a coin is inserted. Connectors added to coinsNeeded will trigger
-- only when all of the required coins have been inserted. Once coinsNeeded
-- reaches 0, additional coins will not be consumed.
-- If you wish for the lock to consume an infinite number of coins, set the
-- coinsNeeded value to a negative number.
Simply connect the lock component to your counter in the editor, and set the coinsNeeded component's initial value to -1 in the editor (to accept unlimited coins).

There are also several examples of how to use dm_lock_coinslot in the example dungeon.
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.
kelly1111
Posts: 349
Joined: Sun Jan 20, 2013 6:28 pm

Re: Ask a simple question, get a simple answer

Post by kelly1111 »

Thanks Minmay. I overlooked the commented part. It is working now.
Pompidom
Posts: 497
Joined: Sun May 06, 2018 9:42 pm

Re: Ask a simple question, get a simple answer

Post by Pompidom »

Speaking of coin slots.

Many tutorials or links are expired. especially prozail's links to alcove shops.

I'm looking to make some basic simple single item alcove slot machines.
put in 1 dm_copper_coin in the coin slot and a healing potion appears in the alcove, repeatable for as many copper coins you have.

I checked the dmdungeon for examples but all they do is open doors.
Anyone that wants to write it? : :(
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Make a script_entity with a function like this:

Code: Select all

function makeHealingPotion()
	your_alcove_id.surface:addItem(spawn("potion_healing").item)
end
Then connect the coin slot's lock component to the script_entity and select that function.
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.
Pompidom
Posts: 497
Joined: Sun May 06, 2018 9:42 pm

Re: Ask a simple question, get a simple answer

Post by Pompidom »

Worx perfect with negative coinneeded -1

Thank you!
Pompidom
Posts: 497
Joined: Sun May 06, 2018 9:42 pm

Re: Ask a simple question, get a simple answer

Post by Pompidom »

When you place an item (let's say a healing potion) on the ground with the editor.
you can deselect it's "item" box. This way the item becomes scenery and you can not pick up the item.
However if you take a 2nd healing potion out of your inventory and then click with that potion on the other potion, you suddenly have both potions in your hand.

Any way to prevent that?
Pompidom
Posts: 497
Joined: Sun May 06, 2018 9:42 pm

Re: Ask a simple question, get a simple answer

Post by Pompidom »

Pompidom wrote: Tue Jul 03, 2018 11:48 pm When you place an item (let's say a healing potion) on the ground with the editor.
you can deselect it's "item" box. This way the item becomes scenery and you can not pick up the item.
However if you take a 2nd healing potion out of your inventory and then click with that potion on the other potion, you suddenly have both potions in your hand.

Any way to prevent that?

Edit*
Nevermind, I found a work around
kelly1111
Posts: 349
Joined: Sun Jan 20, 2013 6:28 pm

Re: Ask a simple question, get a simple answer

Post by kelly1111 »

What is the work around?
Pompidom
Posts: 497
Joined: Sun May 06, 2018 9:42 pm

Re: Ask a simple question, get a simple answer

Post by Pompidom »

So basically stackable items had this problem. My goal was to place items in alcove shops as a "picture" so you know what you're buying when pushing in a coin.

I don't know exactly why and how.

But what I did as workaround was simply place the item on a different tile and then use WorldPosition script to place it where I wanted it to be (in this case on the right side of the alcove)

It works now and as you can see in the screenshots the alchemy ingredients are just scenery now, and cannot be picked up even with another identical item in your hand.

https://ibb.co/i7eshJ
https://ibb.co/dndzwd
https://ibb.co/i0kUwd
https://ibb.co/dHjTpy

(crappy screenshots from toaster laptop from girlfriend)
Pompidom
Posts: 497
Joined: Sun May 06, 2018 9:42 pm

Re: Ask a simple question, get a simple answer

Post by Pompidom »

what's the script for showing a text when pressing a button?

edit: found it.
function reekText()
hudPrint("The room reeks of death.")
end
Post Reply