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!
User avatar
Zo Kath Ra
Posts: 932
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Ask a simple question, get a simple answer

Post by Zo Kath Ra »

kelly1111 wrote: Thu Apr 06, 2023 8:38 pm Just testing something in chatgtp ...
What exactly did you ask ChatGPT?
Did it generate the code you posted?
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: Ask a simple question, get a simple answer

Post by bongobeat »

Zo Kath Ra wrote: Thu Apr 06, 2023 4:59 pm
bongobeat wrote: Thu Apr 06, 2023 10:33 am it is in a single script file, without anything else, and linked to 2 buttons named mkbforge1 and mkbforge2

I'm asking because some players seems to have trouble with that, if the right combination is not found at first.
Maybe I have done something wrong here. This is just copy paste and modify from another script that someone made for me.
How does the puzzle work?

And how does the script work?
(if you can't answer this question, then that's the problem)

And what "trouble" are the players having?
It helps to be precise when reporting bugs...
The player has to look for the right combination in a room and then press accordingly the left button or the righ button (the hint are marqued as "L" or "R") and the button are placed left and right to the main hint.
They are related, in the script, to 1 or 2.

So when the player press a button, it enters "1" or "2" in the script, and then the script check if the good combination has been made.
Also the script is checking that only 2 buttons are linked to it and they should be named with whatever you want, but you need a number at last, 1 and 2.
If the wrong sequence is made, the script should reset itself that the next combination entered will be checked again, until the good one.


But regarding the players feedback, if you put the bad combination at first it seems that the script didn't reset properly.
They say if they doesn't do the right combination at the first time, they had to do it more than once then, even if (at the second time) the right combination has been made.

As I said that script is not my doing. Someone made me this script, can't remember who. And I use it a few time.
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
Banaora
Posts: 162
Joined: Wed Jun 05, 2013 9:39 am

Re: Ask a simple question, get a simple answer

Post by Banaora »

Maybe it is enough to enable sound feedback in the function combinationReset().

The way it is now you can enter "111222121211121" and it will not be accepted even though the string contains the correct solution because it will reset after the 3rd 1. And the player could wonder why that is when he doesn't get any kind of feedback.
User avatar
Zo Kath Ra
Posts: 932
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Ask a simple question, get a simple answer

Post by Zo Kath Ra »

Banaora wrote: Thu Apr 06, 2023 9:25 pm Maybe it is enough to enable sound feedback in the function combinationReset().

The way it is now you can enter "111222121211121" and it will not be accepted even though the string contains the correct solution because it will reset after the 3rd 1. And the player could wonder why that is when he doesn't get any kind of feedback.
You're probably right about the cause of the problem, and the solution.

But I think the original code is more complicated than it needs to be, so here's a simpler version.

Code: Select all

combination = "11222121211121"
count = 0 -- number of correctly guessed digits

function buttonCombination(callerButtonComponent)
	if count == #combination then
		hudPrint("The puzzle has already been solved!")
	elseif string.sub(callerButtonComponent.go.id, -1) == string.sub(combination, count + 1, count + 1) then
		-- last character in the pressed button's id == next digit in the combination
		count = count + 1
		if count == #combination then
			hudPrint("You have solved the puzzle!")
		end
	else
		hudPrint("Wrong button! The puzzle has been reset.")
		count = 0
	end
end
And here's a version that doesn't reset the puzzle, which is even simpler.

Code: Select all

combination = "11222121211121"
keypresses = ""

function buttonCombination(callerButtonComponent)
	keypresses = keypresses .. string.sub(callerButtonComponent.go.id, -1)
	if #keypresses > #combination then
		keypresses = string.sub(keypresses, 2)
	end
	
	if keypresses == combination then
		hudPrint("You have solved the puzzle!")
		-- deactivate the buttons
	end
end
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: Ask a simple question, get a simple answer

Post by bongobeat »

Zo Kath Ra wrote: Thu Apr 06, 2023 11:03 pm
Banaora wrote: Thu Apr 06, 2023 9:25 pm Maybe it is enough to enable sound feedback in the function combinationReset().

The way it is now you can enter "111222121211121" and it will not be accepted even though the string contains the correct solution because it will reset after the 3rd 1. And the player could wonder why that is when he doesn't get any kind of feedback.
You're probably right about the cause of the problem, and the solution.

But I think the original code is more complicated than it needs to be, so here's a simpler version.

Code: Select all

combination = "11222121211121"
count = 0 -- number of correctly guessed digits

function buttonCombination(callerButtonComponent)
	if count == #combination then
		hudPrint("The puzzle has already been solved!")
	elseif string.sub(callerButtonComponent.go.id, -1) == string.sub(combination, count + 1, count + 1) then
		-- last character in the pressed button's id == next digit in the combination
		count = count + 1
		if count == #combination then
			hudPrint("You have solved the puzzle!")
		end
	else
		hudPrint("Wrong button! The puzzle has been reset.")
		count = 0
	end
end
And here's a version that doesn't reset the puzzle, which is even simpler.

Code: Select all

combination = "11222121211121"
keypresses = ""

function buttonCombination(callerButtonComponent)
	keypresses = keypresses .. string.sub(callerButtonComponent.go.id, -1)
	if #keypresses > #combination then
		keypresses = string.sub(keypresses, 2)
	end
	
	if keypresses == combination then
		hudPrint("You have solved the puzzle!")
		-- deactivate the buttons
	end
end
Will try that, thanks!
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
User avatar
7Soul
Posts: 209
Joined: Sun Oct 19, 2014 1:56 am
Location: Brazil

Re: Ask a simple question, get a simple answer

Post by 7Soul »

Is it possible to have fog in a map that has an ocean? I tested the usual sky fog with ocean and the ocean is rendered on top of the fog
Join the LoG discord server: https://discord.gg/ArgAgNN :D

My Mods
minmay
Posts: 2770
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Yes. For example, Shipwreck Beach in the main game has both.
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.
User avatar
The_Morlock
Posts: 15
Joined: Sun Jun 02, 2024 6:15 am

Re: Ask a simple question, get a simple answer

Post by The_Morlock »

Hey everyone,

Using the LoG2 Dungeon Editor, how do you move all mapped cells and their contents? One one of my maps, I realized I was off by one X and one Y coordinate. I want to select all and move up one and right one. Currently, the only way I know to do this is to select all assets, move them over, and then the tiles... that's where it is a PITA, I have to basically recreate the tile map.... twice. Once to tile the floor and one to tile the walls.

Am I missing something here?

Thank you!
My Project(s): Grimstone Keep, a reimagining of the 1995 Interplay game, Stonekeep.
Discord: https://discord.gg/AfZVYHc8JX
Patreon: https://patreon.com/GrimstoneKeep
User avatar
Isaac
Posts: 3179
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

The dungeon editor doesn't support moving the solid bounds of the dungeon walls in a group, but the map levels themselves are just simple text blocks, found in the Dungeon.lua file; found in your mod's scripts folder. It is possible to edit the tile elevations in a text editor. Each number represents the height of one tile.

Code: Select all

loadLayer("tiles", {
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,1,1,1,1,1,2,2,2,2,1,1,1,2,2,1,1,1,1,1,2,2,2,2,2,2,2,2,
	2,2,2,2,2,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,
	2,2,2,2,2,1,1,1,1,1,2,2,2,2,2,2,2,2,2,1,1,1,1,1,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,2,2,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2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
})
SpoilerShow
Image
User avatar
The_Morlock
Posts: 15
Joined: Sun Jun 02, 2024 6:15 am

Re: Ask a simple question, get a simple answer

Post by The_Morlock »

Isaac wrote: Fri Jun 07, 2024 2:19 am The dungeon editor doesn't support moving the solid bounds of the dungeon walls in a group, but the map levels themselves are just simple text blocks, found in the Dungeon.lua file; found in your mod's scripts folder. It is possible to edit the tile elevations in a text editor. Each number represents the height of one tile.

Code: Select all

loadLayer("tiles", {
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,1,1,1,1,1,2,2,2,2,1,1,1,2,2,1,1,1,1,1,2,2,2,2,2,2,2,2,
	2,2,2,2,2,1,1,1,1,1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,2,2,2,2,2,
	2,2,2,1,1,1,2,2,1,1,1,2,2,2,1,1,1,2,2,1,1,1,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,1,1,2,2,1,1,1,2,2,2,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,1,1,1,2,2,2,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
})
SpoilerShow
Image
Thank you for that. I might use that at some point, but I guess I'll stick with the default LMB and RMB method.

Since there is a dedicated Brush tool, one method to do this would be to press WASD to move the whole map around since those are already mapped under the assets tool to move things around.

Thanks!
My Project(s): Grimstone Keep, a reimagining of the 1995 Interplay game, Stonekeep.
Discord: https://discord.gg/AfZVYHc8JX
Patreon: https://patreon.com/GrimstoneKeep
Post Reply