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
Slava
Posts: 51
Joined: Sun Aug 30, 2015 2:10 pm

Re: Ask a simple question, get a simple answer

Post by Slava »

Can you please tell me why it's not working
GameMode.setMaxStatistic(“secrets_found”, 100)
GameMode.setMaxStatistic(“treasures_found”, 0)
are they hardcoded?
My Generations of Kings mod
Link to Nexus mods
User avatar
Zo Kath Ra
Posts: 940
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Ask a simple question, get a simple answer

Post by Zo Kath Ra »

Slava wrote: Thu Dec 26, 2024 9:38 am Can you please tell me why it's not working
GameMode.setMaxStatistic(“secrets_found”, 100)
GameMode.setMaxStatistic(“treasures_found”, 0)
are they hardcoded?
Works for me.
If you upload a test dungeon to Nexusmods, we can try to reproduce the error.

Merry Christmas!
User avatar
7Soul
Posts: 212
Joined: Sun Oct 19, 2014 1:56 am
Location: Brazil

Re: Ask a simple question, get a simple answer

Post by 7Soul »

Slava wrote: Wed Dec 25, 2024 8:47 am
7Soul wrote: Tue Dec 24, 2024 7:37 pm But this causes an exception saying addItem requires an ItemComponent:
Try this

Code: Select all

local gem = "blue_gem"
for e in self.go.map:entitiesAt(self.go.x, self.go.y + dy) do
	if e and e.surface then
		local o = spawn(gem).item		
		e.go.surface:addItem(o) 
		break
	end
end
That's the same code I posted, just more verbal. As such the same error happens


This works:

Code: Select all

local altar = findEntity(altarId)
if altar then
	altar.surface:addItem(spawn("blue_gem").item) -- addItem accepts the item
end
This doesn't:

Code: Select all

for e in self.go.map:entitiesAt(self.go.x, self.go.y) do
	if e.surface then 
		e.surface:addItem(spawn("blue_gem").item) -- addItem says parameter 1 is not an item
		break
	end
end
Join the LoG discord server: https://discord.gg/S6pYmuAwWm :D

My Mods
User avatar
Slava
Posts: 51
Joined: Sun Aug 30, 2015 2:10 pm

Re: Ask a simple question, get a simple answer

Post by Slava »

Zo Kath Ra wrote: Thu Dec 26, 2024 2:19 pm If you upload a test dungeon to Nexusmods, we can try to reproduce the error.
Thank you! I've already figured it out, the problem was something else.

Now I have another question.
When I set champion:setHealth(0)
(Don't ask why. I just need to kill champion instantly. :lol: )
After resurrection champion does not require food.
I found a solution to the problem - champion:damage(champion:getHealth(), “pure”),
but I'm wondering why this happens?
My Generations of Kings mod
Link to Nexus mods
User avatar
MS-Max
Posts: 5
Joined: Mon Nov 04, 2024 8:04 pm

Re: Ask a simple question, get a simple answer

Post by MS-Max »

The description for ‘defineRecipe’ is
‘Defines a new recipe or replases an existing recipe’.
However, the recipe is not replaced, but only extended. The old combination continues to work.
Why is this the case?
User avatar
Slava
Posts: 51
Joined: Sun Aug 30, 2015 2:10 pm

Re: Ask a simple question, get a simple answer

Post by Slava »

MS-Max wrote: Tue Jan 14, 2025 8:08 pm Why is this the case?
this is a simple enough question, but nevertheless requires a detailed answer, given that you are, I assume, a novice. Welcome!
You can find the line import “assets/scripts/standard_assets.lua” in the files of your mod, namely in init.lua.
If you downloaded the asset pack grimrock 2 then in the file standard_assets.lua you can see the line import “assets/scripts/recipes.lua”. This is what makes the recipes work in parallel. You can remove the line “assets/scripts/standard_assets.lua” from your init.lua, copy the standard_assets.lua file with the line “assets/scripts/recipes.lua” previously removed from it to your modification folder (you need to rewrite the line to import “mod_assets/scripts/standard_assets.lua”). This will disable vanilla recipes. Now you can define your own! You welcome!

Translated with DeepL.com (free version)
My Generations of Kings mod
Link to Nexus mods
User avatar
MS-Max
Posts: 5
Joined: Mon Nov 04, 2024 8:04 pm

Re: Ask a simple question, get a simple answer

Post by MS-Max »

Thank you very much, Slava, for answering my question so quickly.
However, I didn't necessarily want a solution, but an explanation of why in this particular case the definition is extended and not replaced. Then maybe I could find a solution to my question myself. I already know the solution you suggest.
But I'd rather avoid doing it that way, because I tried it once before on another problem some time ago, and it did solve the one problem, but I then experienced many new complications.
But thanks again for your help, I appreciate your solution orientation.

btw. I also use DeepL (Write/Translate)
minmay
Posts: 2787
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

defineRecipe() will replace any existing recipe with the same ingredients. It won't replace an existing recipe if it has different ingredients from that recipe, even if the recipe creates the same item.
This is so that you can have multiple recipes that create the same item. For example, in Grimrock 1, there are two different recipes for potion_cure_poison; if defineRecipe() replaced existing recipes for the same item, this wouldn't be possible.
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
MS-Max
Posts: 5
Joined: Mon Nov 04, 2024 8:04 pm

Re: Ask a simple question, get a simple answer

Post by MS-Max »

Okay, now I understand.
I have now given the old ingredient combinations new definitions and then assigned them to level 6.
So they are no longer active.
Thanks.
Post Reply