map object has no function to get the level number?? Ugh

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!
Post Reply
MrChoke
Posts: 324
Joined: Sat Oct 25, 2014 7:20 pm

map object has no function to get the level number?? Ugh

Post by MrChoke »

I am finding that I need to write a function that iterates through all of the maps in the game (using Dungeon.getMap(number)) in order to find the level number of a map object. I have to match the level coordinates of the map object in question to the map objects being iterated. We have getName(), getLevelCoords(), etc... but no getLevel()???

Anyway, seems like a miss to me. Maybe I am missing something. There isn't anything in the scripting reference that I can see nor did I find anything with trial and error testing.
Scotty
Posts: 69
Joined: Fri Nov 07, 2014 2:59 pm

Re: map object has no function to get the level number?? Ugh

Post by Scotty »

But isn't level index essentially the "input" to get back co-ords, name etc. You can't get any of that information without giving a level index at some point, so getLevel() would just return the value you already knew.

Unless I'm misunderstanding the question :?
MrChoke
Posts: 324
Joined: Sat Oct 25, 2014 7:20 pm

Re: map object has no function to get the level number?? Ugh

Post by MrChoke »

Scotty wrote:But isn't level index essentially the "input" to get back co-ords, name etc. You can't get any of that information without giving a level index at some point, so getLevel() would just return the value you already knew.

Unless I'm misunderstanding the question :?
Here is the situation I am having. I am using another map function, getAdjacentLevel(number, number, number). Each number is the X, Y and Z direction for the adjacent level you want to get for this map. What it returns is the map object of the adjacent level. That's great but what is that map's level number!?!? Its not on the map object. That is the problem.
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: map object has no function to get the level number?? Ugh

Post by JKos »

Here is a workaround

Code: Select all

function getMapLevel(map)
	for ent in map:allEntities() do
		return ent.level
	end
end
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
MrChoke
Posts: 324
Joined: Sat Oct 25, 2014 7:20 pm

Re: map object has no function to get the level number?? Ugh

Post by MrChoke »

JKos wrote:Here is a workaround

Code: Select all

function getMapLevel(map)
	for ent in map:allEntities() do
		return ent.level
	end
end
Yes, that would work. I did a work around too. I will admit yours is more simple than mine. Thanks.
Post Reply