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!
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Zo Kath Ra wrote: Thu Feb 07, 2019 11:30 pm How does BrainComponent:dropItemOn(string, string) work?
The first argument should be the id of an item and the second argument should be the id of an object with a SurfaceComponent named "surface". If the monster is carrying the item and is next to the surface, it will play its dropItemOnSurface animation, and when it receives a "dropItem" animation event, it will drop the item on the surface provided it can still reach the surface.
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.
ColdDeadStone
Posts: 24
Joined: Sat Nov 26, 2016 12:12 pm

Re: Ask a simple question, get a simple answer

Post by ColdDeadStone »

Hello! I get an error message when loading a savegame:

Code: Select all

=== Software Failure ===

[string "MessageSystem.lua"]:0: could not resolve object reference with id stabportalfake_1
stack traceback:
	[C]: in function 'assert'
	[string "MessageSystem.lua"]: in function 'loadState'
	[string "GameMode.lua"]: in function 'loadGame'
	[string "GameMode.lua"]: in function 'update'
	[string "Grimrock.lua"]: in function 'display'
	[string "Grimrock.lua"]: in main chunk
I can't find anything special on the object and would like to know what could cause this error. Does anyone have an idea :?:
Here is a definition of one of the objects that cause problems:

Code: Select all

defineObject{
	name = "stabportalfake",
	components = {
		{
			class = "Model",
			name = "frame",
			model = "assets/models/env/portal_frame.fbx",
			staticShadow = true,
		},
		{
			class = "Model",
			name = "planeModel",
			model = "assets/models/env/portal_plane.fbx",
			material = "portal_locked",
		},
		{
			class = "Portal",
			onArrival = function()
			end,
		},
		{
			class = "Door",
			sparse = true,
			enabled = true,
		},
		{
			class = "Light",
			offset = vec(0, 1, 0),
			type = "point",
			color = vec(0.9, 1.0, 1.3),
			brightness = 12,
			range = 6,
			castShadow = true,
			onUpdate = function(self)
				local noise = math.noise(Time.currentTime()*1 + 123) * 0.5 + 0.9
				self:setBrightness(noise * 15)
			end,
		},
		{
			class = "Particle",
			name = "particle2",
			particleSystem = "portal_particles",
			emitterMesh = "assets/models/env/portal_rim_emitter.fbx",
		},
		{
			class = "Particle",
			name = "particle3",
			particleSystem = "portal_particles_radial",
			emitterMesh = "assets/models/env/portal_radial_emitter.fbx",
		},
		{
			class = "Particle",
			name = "islandSymbol",
			particleSystem = "portal_particles_island",
			emitterMesh = "assets/models/env/portal_island_emitter.fbx",
		},
	},
	placement = "wall",
	tags = { "door" },
	editorIcon = 124,
	minimalSaveState = true,
}
minimalSaveState true or false makes no difference! I am grateful for every idea!

Edit: if i swap my portals with the original portals ("portal_locked") then it works... so there must be a error in my defineObject!
Edit2: Okay, after 20 exports I found the problem. This class

Code: Select all

		{
			class = "Model",
			name = "planeModel",
			model = "assets/models/env/portal_plane.fbx",
			material = "portal_locked",
		},
needs to be at the bottom and minimalsavestate must be false... dont know why and i dont like it (minimalsavestate) but if it works then I guess it has to be this way... :cry:
Sorry for my poor english... hope you understand what i try to say! :)
User avatar
Zo Kath Ra
Posts: 937
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Ask a simple question, get a simple answer

Post by Zo Kath Ra »

ColdDeadStone wrote: Sat Feb 09, 2019 11:34 am Edit2: Okay, after 20 exports I found the problem. This class

Code: Select all

		{
			class = "Model",
			name = "planeModel",
			model = "assets/models/env/portal_plane.fbx",
			material = "portal_locked",
		},
needs to be at the bottom and minimalsavestate must be false... dont know why and i dont like it (minimalsavestate) but if it works then I guess it has to be this way... :cry:
Removing "minimalSaveState = true," is enough to make it work for me, I didn't have to move the "planeModel".
ColdDeadStone
Posts: 24
Joined: Sat Nov 26, 2016 12:12 pm

Re: Ask a simple question, get a simple answer

Post by ColdDeadStone »

Zo Kath Ra wrote: Sat Feb 09, 2019 1:17 pm Removing "minimalSaveState = true," is enough to make it work for me, I didn't have to move the "planeModel".
Well, if you took my definition from above, then thats "strange"... I'll try that one more time... >> 10 minutes later >> damn it... you're right... i certainly didn't save the objects.lua when i set minimalsavestate to false and exported it again with true... That was one hour of my life... wasted... :lol: Thanks for answering! Have a good day! :D
Sorry for my poor english... hope you understand what i try to say! :)
Pompidom
Posts: 497
Joined: Sun May 06, 2018 9:42 pm

Re: Ask a simple question, get a simple answer

Post by Pompidom »

Can you add a clickable component with a connector to custom monsters? is there any code I can add to the monster object file?
This way you can talk to npc's that are walking around. Would it work if I simply snip some connector/clickable code from a custom altar for example?

Besides talking to npc's, it can be used to pickpocket npc's if you can make it direction dependant.
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 »

Components can be added (and even removed) on the fly in objects, including monsters. Connectors do trigger component hooks, but are limited (unlike the defined hooks) in that they cannot cancel an event.

Using a defined hook (that returns false), the code can stop an attack, or prevent a monster's death—for instance; connectors cannot do this. They work fine for when you do not need to cancel the hook events.
kelly1111
Posts: 349
Joined: Sun Jan 20, 2013 6:28 pm

Re: Ask a simple question, get a simple answer

Post by kelly1111 »

lostsol wrote: Thu Jan 10, 2019 8:17 pm I've had success with this in the past, and I can look into my stuff a bit later on, if you don't find a solution before then. In the meantime:

Try copying the forest ground tile definition and change the heightmapMaterial to the material you want to use. Make sure it is the name of a material (not an object) and make sure the material you are using is defined (defineMaterial). And of course, place a heightmap object on the level you are working on.

If all goes well, then try adding in the ceiling, pillar and wall to the definition.
This one still got me puzzeled... I tried adding stuff to the forest ground tile definition. Did everything in the order you mentioned, but am still left with a blank void tile instead of the heightmap material ...
Can you (or someone else?) replicate in indoor heigtmap (like mine tileset one) ...or post the code you used?
Pompidom
Posts: 497
Joined: Sun May 06, 2018 9:42 pm

Re: Ask a simple question, get a simple answer

Post by Pompidom »

Not sure if it's related, but when I was going full multi floor ape shit on a map, manual object ceilings in the middle replaced the upper ceiling into a void and then crashed the editor after a short while. Maybe it's something similar. I was not able to use certain ceiling objects into the -7 / +7 vertical grid as it would completely erase the upper ceiling.
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 »

To use a heightmap floor requires placing a heightmap object on the map. With that in place, you can see the effects of changes made in the heightmap editor.

Floor tiles that don't use heightmaps, or elevation changes on any tile, usually leave holes in the landscape, for the [separate] floor objects being raised or lowered.
lostsol
Posts: 86
Joined: Mon Apr 02, 2018 4:51 pm

Re: Ask a simple question, get a simple answer

Post by lostsol »

kelly1111 wrote: Mon Feb 11, 2019 10:02 pm This one still got me puzzeled... I tried adding stuff to the forest ground tile definition. Did everything in the order you mentioned, but am still left with a blank void tile instead of the heightmap material ...
Can you (or someone else?) replicate in indoor heigtmap (like mine tileset one) ...or post the code you used?
Outside of a missing heightmap object, the only issue I can think of is the fact that you are running larger map sizes. I could be totally wrong, but for the heck of it try using your tileset on a clean editor project with modest 32x32 levels.

Here is the mine tileset, edited for use with heightmap (the ceilings, pillars will still look jagged though):

Code: Select all

defineTile{
	name = "mine_floor",
	editorIcon = 192,
	color = {120,120,120,255},
	builder = "dungeon",
	heightmapMaterial = "mine_floor_01",
	ceiling = {
		"mine_ceiling_01", 50,
		"mine_ceiling_02", 50,
	},
	wall = {
		"mine_elevation_edge", 1,
	},
	ceilingShaft = "mine_ceiling_shaft",
}
https://drive.google.com/open?id=1OeDiA ... K-yjju_Nbl
Post Reply