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!
Badgert
Posts: 258
Joined: Sun Jan 29, 2017 6:14 pm

Re: Ask a simple question, get a simple answer

Post by Badgert »

I planned to use 2 identical subjects (2 skulls).
Tried to substitute in your script

skull_placed = false
skull_placed = false

function checkAltar(altar, item)
if altar.go == altar_3 and skull.go == skull then
skull_placed = true
else
if altar.go == altar_4 and skull.go == skull then
skull_placed = true
end
end

if skull_placed == true and skull_placed == true then
castle_secret_door_1.door:open()
end
end

- I have a bug. What did I do wrong?
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

It only needs updated to use your specific object ids. I'd say re-copy/paste the original script, then alter only those to match the ones you will use.

Example (excerpts):
if altar.go == altar_3 and item.go == skull_1 then

if altar.go == altar_4 and item.go == skull_2 then

if item1_placed == true and item2_placed == true then
castle_secret_door_1.door:open()
SpoilerShow
Technically (but not required)...
item1_placed == true and item2_placed == true

...could be replaced with:
item1_placed and item2_placed
( But that's just needlessly showing off. :mrgreen: )

It never occurred to me to just compare the table names instead of the ids; which is pretty neat, and seems to work across save & reloads.

@Torquemada
It is most certainly adding extra bloat... but I find that it can sometimes make mystery-black-box scripts a lot easier for the unsure to customize, by defining what they need to edit as simple strings when possible, (and best near the top?). Using those string variables in the script; eliminating the need for them to edit function blocks.
Torquemada
Posts: 25
Joined: Fri Apr 05, 2013 10:52 pm

Re: Ask a simple question, get a simple answer

Post by Torquemada »

Isaac wrote:It only needs updated to use your specific object ids. I'd say re-copy/paste the original script, then alter only those to match the ones you will use.

Example (excerpts):
if altar.go == altar_3 and item.go == skull_1 then

if altar.go == altar_4 and item.go == skull_2 then

if item1_placed == true and item2_placed == true then
castle_secret_door_1.door:open()
SpoilerShow
Technically (but not required)...
item1_placed == true and item2_placed == true

...could be replaced with:
item1_placed and item2_placed
( But that's just needlessly showing off. :mrgreen: )

It never occurred to me to just compare the table names instead of the ids; which is pretty neat, and seems to work across save & reloads.

@Torquemada
It is most certainly adding extra bloat... but I find that it can sometimes make mystery-black-box scripts a lot easier for the unsure to customize, by defining what they need to edit as simple strings when possible, (and best near the top?). Using those string variables in the script; eliminating the need for them to edit function blocks.
I agree, but I tried to make the script as simple as possible, magic numbers and in this case magic strings are never a pretty thing :)
Torquemada
Posts: 25
Joined: Fri Apr 05, 2013 10:52 pm

Re: Ask a simple question, get a simple answer

Post by Torquemada »

Badgert wrote:I planned to use 2 identical subjects (2 skulls).
Tried to substitute in your script

skull_placed = false
skull_placed = false

function checkAltar(altar, item)
if altar.go == altar_3 and skull.go == skull then
skull_placed = true
else
if altar.go == altar_4 and skull.go == skull then
skull_placed = true
end
end

if skull_placed == true and skull_placed == true then
castle_secret_door_1.door:open()
end
end

- I have a bug. What did I do wrong?
Try this code, it checks the contents of both altars each time you put new item on either one.
Link the onInsertItem to checkAltars function, you only need to edit the id names in checkAltars function

Code: Select all

function hasSkull(altar)
	for i,item in altar.surface:contents() do
		print(item.go.name)
		if item.go.name == "skull" then
			return true
		end
	end
	return false
end

function checkAltars()
	if hasSkull(altar_1) and hasSkull(altar_2) then
		dungeon_secret_door_1.door:open()
	end
end
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Badgert wrote:I planned to use 2 identical subjects (2 skulls).
Are these generic (anywhere in the dungeon) skulls?
Skulls that could come right out of a Minotaur's inventory?
Or are they specific skulls that the player has to find?
Badgert
Posts: 258
Joined: Sun Jan 29, 2017 6:14 pm

Re: Ask a simple question, get a simple answer

Post by Badgert »

Torquemada
Thank you so much! Everything works fine!

Isaac
I plan to use 2 fancy_skull from the zim_assets.
User avatar
Nathaniel
Posts: 111
Joined: Sun Jul 26, 2015 9:09 pm
Location: Ukraine

Re: Ask a simple question, get a simple answer

Post by Nathaniel »

Hi guys! :)
Tell me please how to change the color of lighting, which "turns on" when you select the "Light" spell. Is it possible to choose a color with the help of the RGB palette?
Legend of Grimrock 1.3.7
Legend of Grimrock II 2.2.4
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Ask a simple question, get a simple answer

Post by zimberzimber »

Nathaniel wrote:Hi guys! :)
Tell me please how to change the color of lighting, which "turns on" when you select the "Light" spell. Is it possible to choose a color with the help of the RGB palette?
If you know the name of the light spell LightComponent, then its easily modifiable like any other light source.
But if you want more control over what happens within the component (onUpdate) then you'll have to add a new LightComponent to the party object, and replace vanilla light spell with your own, which would interact with it (fadeIn/colors/fadeOut).
My asset pack [v1.10]
Features a bit of everything! :D
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Is there a way to alter game sounds dynamically during play? Meaning the sounds the game uses during regular play... not object or user assigned sound components. For instance, if I wanted to change the sound the game will use for player damage—or falling, or menu-ticks, etc... and then change it back to the default. How can these sounds be accessed by script during the game?
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Ask a simple question, get a simple answer

Post by zimberzimber »

Didn't meddle in GUI much, but wouldn't no click sound, and have the sound be played through whatever it triggers work?
My asset pack [v1.10]
Features a bit of everything! :D
Post Reply