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
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Ask a simple question, get a simple answer

Post by AndakRainor »

Well my problem is about procedural generated maps. I noticed that I can't spawn a water mesh when needed, so I have them generated at the initialisation of the mod, and they have the size of the full map. At that point I don't know where the stairs to go down to the map below will be placed. I try to find a way to hide the water that floods the stairs. No luck so far with ForceZWrite. I hope I won't have to give stairs a fixed position because of this, or other cheap solutions...
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Ah. WaterSurfaceMeshComponent builds the mesh when:
- the party enters its level and the mesh hasn't been built already
- the game is reloaded

So it won't automatically build the mesh when newly spawned, but you can make it build the mesh by moving the party to another level and then back. HeightmapComponent behaves the same way.
Of course, the resulting mesh is based entirely on which tiles are underwater, and the user scripting interface can't modify the tile map. But if you were to find a way to modify the tile map anyway, it does get saved and loaded, as does the heightmap, so changing it probably works fine...
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
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Ask a simple question, get a simple answer

Post by AndakRainor »

Excellent news, as the Pandora box was already half opened :D

Edit: Is it okay to chain both party teleports in the same frame?
Last edited by AndakRainor on Thu Feb 08, 2018 6:53 pm, edited 1 time in total.
wagtunes
Posts: 316
Joined: Sun Feb 04, 2018 11:04 pm

Re: Ask a simple question, get a simple answer

Post by wagtunes »

I hope it's okay to post this here even though these questions are for LoG 1. I just starting modding and while I'm pretty clear on the basic stuff, there are a few things I'm a little confused about.

1. I found the command for ending the game. I'm assuming I have to write a Lua script that when whatever event occurs, I simply call that command. My question though has to do with how to customize the game ending. I see the syntax says:

completeGame([cinematicsFile])

I found the info for the file type that the cinematic file has to be and downloaded and installed FFmpeg.

However, in addition to the cinematic file, I want to display text similar to the dream sequence texts in LOG 1 but have no clue how to do that in conjunction with the cinematic file where several messages fade in and fade out, controlled by a timer. So any assistance here will be appreciated. Or do I simply incorporate all script animations into the video file itself? I use Camtasia so I assume that will be capable of giving me what I'm looking for.

2. Would like to create a custom item to be found in a chest in order to trigger the completeGame([cinematicsFile]) command. Is this possible? I've gone through the scripting reference page but might have missed something as it's pretty long. In fact, it's massive.

3. Is there an area where custom Lua scripts like the ones I'm looking for already exist? There is no point in reinventing the wheel if it already exists.

That's about it. Everything else I've pretty much figured out and am through 4 levels of my current dungeon. As a former D&D Dungeon Master, this has been very easy for me story wise.

Any assistance that anybody can give and any other suggestions regarding things that I might not have even thought of would be greatly appreciated.
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

wagtunes wrote: However, in addition to the cinematic file, I want to display text similar to the dream sequence texts in LOG 1 but have no clue how to do that in conjunction with the cinematic file where several messages fade in and fade out, controlled by a timer. So any assistance here will be appreciated. Or do I simply incorporate all script animations into the video file itself? I use Camtasia so I assume that will be capable of giving me what I'm looking for.
There is a page on this website, that outlines creating cinematics for LoG1.
http://www.grimrock.net/modding_log1/ho ... inematics/
2. Would like to create a custom item to be found in a chest in order to trigger the completeGame([cinematicsFile]) command. Is this possible? I've gone through the scripting reference page but might have missed something as it's pretty long. In fact, it's massive.
You can create a chest that runs the script when opened, or when the item is taken from it—define a new item that runs the script when the party picks it up [via party hook]; or when it is used by them [via item hook].
3. Is there an area where custom Lua scripts like the ones I'm looking for already exist? There is no point in reinventing the wheel if it already exists.
Yes there is: viewtopic.php?f=14&t=3099&hilit=useful+scripts
wagtunes
Posts: 316
Joined: Sun Feb 04, 2018 11:04 pm

Re: Ask a simple question, get a simple answer

Post by wagtunes »

Isaac wrote:
wagtunes wrote: However, in addition to the cinematic file, I want to display text similar to the dream sequence texts in LOG 1 but have no clue how to do that in conjunction with the cinematic file where several messages fade in and fade out, controlled by a timer. So any assistance here will be appreciated. Or do I simply incorporate all script animations into the video file itself? I use Camtasia so I assume that will be capable of giving me what I'm looking for.
There is a page on this website, that outlines creating cinematics for LoG1.
http://www.grimrock.net/modding_log1/ho ... inematics/
2. Would like to create a custom item to be found in a chest in order to trigger the completeGame([cinematicsFile]) command. Is this possible? I've gone through the scripting reference page but might have missed something as it's pretty long. In fact, it's massive.
You can create a chest that runs the script when opened, or when the item is taken from it—define a new item that runs the script when the party picks it up [via party hook]; or when it is used by them [via item hook].
3. Is there an area where custom Lua scripts like the ones I'm looking for already exist? There is no point in reinventing the wheel if it already exists.
Yes there is: viewtopic.php?f=14&t=3099&hilit=useful+scripts
Thank you. Appreciate it.
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

AndakRainor wrote:Edit: Is it okay to chain both party teleports in the same frame?
Yep.
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.
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 »

is that possible to change the music of a level permanently with a command?
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
Wrathful
Posts: 2
Joined: Sat Feb 10, 2018 2:01 am

Re: Ask a simple question, get a simple answer

Post by Wrathful »

Hey all, I was wondering if someone could help me with a scripting question.

I'm having trouble with creating some custom GUI. I don't have any formal experience with Lua.

To get to the point, I have defined a custom onDrawGui hook as follows:

Code: Select all

onDrawGui = function(self, context)
	guiT46.script:guiT46Init(context)
end,
This refers to a script in my dungeon named guiT46, which has this code:

Code: Select all

function guiT46Init(context)
	context.font("large")
	context.drawText("Test", width/2, height/2)
end
However, this gives an error when I run the dungeon, saying that the font field cannot be found. Any tips as to how I can fix this?
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: Ask a simple question, get a simple answer

Post by akroma222 »

Wrathful wrote: This refers to a script in my dungeon named guiT46, which has this code:

Code: Select all

function guiT46Init(context)
	context.font("large")
	context.drawText("Test", width/2, height/2)
end
However, this gives an error when I run the dungeon, saying that the font field cannot be found. Any tips as to how I can fix this?
Hey Wrathful,
I usually start any GUI function/script with the following:
SpoilerShow

Code: Select all

function drawChampionInventory(pcomp, context, champion)
	------------------------------------
	local w, h, r = context.width, 		context.height, 	context.width / context.height
	local f = (r < 1.3 and 0.8 or r < 1.4 and 0.9 or 1) * context.height/1080
	local MX, MY = context.mouseX, context.mouseY
	local mLeft, mRight = context.mouseDown(0), context.mouseDown(2)
	
	
	if Editor.isRunning() and context.keyDown("I") and context.mouseDown(0) then 
		context.font("large")																										
		context.color(225, 125, 125, 255)
		local text = "TEST DRAW TEXT"
		-------------------------------
		context.drawText(text, 	w - f * (w / 2  + context.getTextWidth(text)), 	 h - f * h / 2)	
	end
end
The local Var 'f' is used to correct for different screen resolutions .... you then need to multiply X, Y coords by f in subsequent drawTexts / drawImages etc
See how you go with that, happy to help with the GUI stuff :)
Akroma
Post Reply