Page 245 of 400

Re: Ask a simple question, get a simple answer

Posted: Mon Jul 02, 2018 10:44 pm
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.

Re: Ask a simple question, get a simple answer

Posted: Tue Jul 03, 2018 6:55 pm
by kelly1111
Thanks Minmay. I overlooked the commented part. It is working now.

Re: Ask a simple question, get a simple answer

Posted: Tue Jul 03, 2018 7:53 pm
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? : :(

Re: Ask a simple question, get a simple answer

Posted: Tue Jul 03, 2018 8:31 pm
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.

Re: Ask a simple question, get a simple answer

Posted: Tue Jul 03, 2018 9:02 pm
by Pompidom
Worx perfect with negative coinneeded -1

Thank you!

Re: Ask a simple question, get a simple answer

Posted: Tue Jul 03, 2018 11:48 pm
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?

Re: Ask a simple question, get a simple answer

Posted: Wed Jul 04, 2018 12:34 pm
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

Re: Ask a simple question, get a simple answer

Posted: Wed Jul 04, 2018 12:40 pm
by kelly1111
What is the work around?

Re: Ask a simple question, get a simple answer

Posted: Wed Jul 04, 2018 2:41 pm
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)

Re: Ask a simple question, get a simple answer

Posted: Wed Jul 04, 2018 3:32 pm
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