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: 2697
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay » Sat Nov 07, 2020 5:38 am

ItemComponent has a setStackSize() method that lets you change the number of items in the stack. Use that to make a stack of pellets (or any other stackable item).

dm_lock_coinslot decreases its coinsNeeded counter value by 1 each time a coin is inserted, and when the value reaches 0, it disables its LockComponent. So if you want to reuse a coin slot after it's been fully paid, you can just enable the LockComponent again and set the coinsNeeded value again.

Or if you mean that you just want the coinslot to accept an unlimited number of coins, set the coinsNeeded counter value to a negative number; then it will never disable the LockComponent.
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.

IttaBitta
Posts: 19
Joined: Thu Oct 22, 2020 12:14 am

Re: Ask a simple question, get a simple answer

Post by IttaBitta » Sun Nov 08, 2020 3:48 am

minmay wrote:
Sat Nov 07, 2020 5:38 am
ItemComponent has a setStackSize() method that lets you change the number of items in the stack. Use that to make a stack of pellets (or any other stackable item).

dm_lock_coinslot decreases its coinsNeeded counter value by 1 each time a coin is inserted, and when the value reaches 0, it disables its LockComponent. So if you want to reuse a coin slot after it's been fully paid, you can just enable the LockComponent again and set the coinsNeeded value again.

Or if you mean that you just want the coinslot to accept an unlimited number of coins, set the coinsNeeded counter value to a negative number; then it will never disable the LockComponent.
I am not sure I understand. Can I have an example?

User avatar
7Soul
Posts: 166
Joined: Sun Oct 19, 2014 1:56 am
Location: Brazil

Re: Ask a simple question, get a simple answer

Post by 7Soul » Sun Nov 08, 2020 8:10 am

IttaBitta wrote:
Sun Nov 08, 2020 3:48 am
minmay wrote:
Sat Nov 07, 2020 5:38 am
ItemComponent has a setStackSize() method that lets you change the number of items in the stack. Use that to make a stack of pellets (or any other stackable item).

dm_lock_coinslot decreases its coinsNeeded counter value by 1 each time a coin is inserted, and when the value reaches 0, it disables its LockComponent. So if you want to reuse a coin slot after it's been fully paid, you can just enable the LockComponent again and set the coinsNeeded value again.

Or if you mean that you just want the coinslot to accept an unlimited number of coins, set the coinsNeeded counter value to a negative number; then it will never disable the LockComponent.
I am not sure I understand. Can I have an example?
Spawn an item with

Code: Select all

local var = spawn( spawn stuff here )
Then you can refer to the newly created object using that variable name

Code: Select all

var.item:setStackSize(10)
Or you can do it all in one go

Code: Select all

spawn( spawn stuff here ).item:setStackSize(10)
Join the LoG discord server: https://discord.gg/ArgAgNN :D

My Mod The Old Nexus (wip)

minmay
Posts: 2697
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay » Sun Nov 08, 2020 8:17 am

To set the stack size of a pellet_box with an id of my_box_of_pellets to 500:

Code: Select all

my_box_of_pellets.item:setStackSize(500)
To "reset" a dm_lock_coinslot with an id of my_coin_slot_id so that it will accept 5 coins:

Code: Select all

my_coin_slot_id.lock:enable()
my_coin_slot_id.coinsNeeded:setValue(5)
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.

IttaBitta
Posts: 19
Joined: Thu Oct 22, 2020 12:14 am

Re: Ask a simple question, get a simple answer

Post by IttaBitta » Sun Nov 08, 2020 9:01 am

I'm spawning into an alcove though
...

Code: Select all

tomb_alcove_2.surface:addItem(spawn("pellet_box").item:setStackSize(10))
?

hyteria
Posts: 263
Joined: Sat Dec 29, 2012 8:22 pm

Re: Ask a simple question, get a simple answer

Post by hyteria » Sun Nov 08, 2020 12:31 pm

hello !

how i can stun my party for 2-3 sec plz ?

thx

ratman
Posts: 137
Joined: Fri Jan 10, 2020 1:13 am

Re: Ask a simple question, get a simple answer

Post by ratman » Sun Nov 08, 2020 5:32 pm

Where are the base conditions defined? I am trying to make my own polymorph potion, except an ogre instead of a bear 8-) , and when I look at the polymorph potion definition it says:

Code: Select all

champion:setCondition("bear_form", 1)
So I tried to look at the condition 'bear form', but none of the conditions are defined in the asset pack.

User avatar
Skuggasveinn
Posts: 561
Joined: Wed Sep 26, 2012 5:28 pm

Re: Ask a simple question, get a simple answer

Post by Skuggasveinn » Sun Nov 08, 2020 6:08 pm

ratman wrote:
Sun Nov 08, 2020 5:32 pm
Where are the base conditions defined? I am trying to make my own polymorph potion, except an ogre instead of a bear 8-) , and when I look at the polymorph potion definition it says:

Code: Select all

champion:setCondition("bear_form", 1)
So I tried to look at the condition 'bear form', but none of the conditions are defined in the asset pack.
You are right, they are not part of the asset pack. But you can define your own condition, example is here.
https://github.com/JKos/log2doc/wiki/Asset-Definitions

Also this topic.
viewtopic.php?f=22&t=14528&hilit=polymorph

kind regards
Skuggasveinn.
Link to all my LoG 2 assets on Nexus.
Link to all my LoG 1 assets on Nexus.

minmay
Posts: 2697
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay » Sun Nov 08, 2020 7:57 pm

IttaBitta wrote:
Sun Nov 08, 2020 9:01 am
I'm spawning into an alcove though
...

Code: Select all

tomb_alcove_2.surface:addItem(spawn("pellet_box").item:setStackSize(10))
?
setStackSize() doesn't return the ItemComponent, so that won't work. You'll need this:

Code: Select all

do
	local pbox = spawn("pellet_box").item
	tomb_alcove_2.surface:addItem(pbox)
	pbox:setStackSize(500)
end
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.

IttaBitta
Posts: 19
Joined: Thu Oct 22, 2020 12:14 am

Re: Ask a simple question, get a simple answer

Post by IttaBitta » Tue Nov 10, 2020 6:54 am

Thanks for all your help, btw

More mod mishaps - I tried to use Zimber's assets and I've had a lot of trouble
Trouble one:
Image
things lead me to think it wants me to 'merge' zim_party with my party definition... but I don't know where or WHAT that definition is.

Post Reply