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!
Pompidom
Posts: 497
Joined: Sun May 06, 2018 9:42 pm

Re: Ask a simple question, get a simple answer

Post by Pompidom »

function wardenrepair()
warden_2.brain:seek(16,17)
end

I disabled monster component

After the first step he gets stuck frozen. What am i missing?
the location he needs to walk to is 3 steps forward. There is nothing blocking him.
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 »

Pompidom wrote: Fri Apr 05, 2019 6:48 pm function wardenrepair()
warden_2.brain:seek(16,17)
end

I disabled monster component

After the first step he gets stuck frozen. What am i missing?
the location he needs to walk to is 3 steps forward. There is nothing blocking him.
viewtopic.php?p=84148#p84148
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

1. you should disable the BrainComponent, not the MonsterComponent, to stop the monster from moving on its own
2. seek() only takes one step, it doesn't put the monster into some kind of seeking state, it just takes one step towards the target
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.
Pompidom
Posts: 497
Joined: Sun May 06, 2018 9:42 pm

Re: Ask a simple question, get a simple answer

Post by Pompidom »

https://www.youtube.com/watch?v=VUuQsmzIiQ4

hooked the scripts to a timer. Works great :)
User avatar
vanblam
Posts: 243
Joined: Sun Nov 09, 2014 12:15 am

Re: Ask a simple question, get a simple answer

Post by vanblam »

I think I'm missing something on my math here and I can't figure out what it is. I can't get "nothing" to spawn more then the others, I keep getting the same amount, definitely more then 80% its more like 20% even if I have my math set to 50%. Most likely I'm doing something wrong.

Code: Select all

local autoDecoFloorDetail2 = function(self)
   local g = self.go
   local choice = math.random()
   if choice <= 0.04 then
      spawn("rc_ground_tiles_04",g.level,g.x,g.y,math.random(0,3),g.elevation)
   elseif choice <= 0.08 then
      spawn("rc_ground_tiles_02",g.level,g.x,g.y,math.random(0,3),g.elevation)
   elseif choice <= 0.12 then
      spawn("rc_ground_tiles_05",g.level,g.x,g.y,math.random(0,3),g.elevation)
   elseif choice <= 0.16 then
      spawn("rc_ground_tiles_03",g.level,g.x,g.y,math.random(0,3),g.elevation)
   elseif choice <= 0.20 then
      spawn("rc_ground_tiles_01",g.level,g.x,g.y,math.random(0,3),g.elevation)
   else
	  spawn("nothing",g.level,g.x,g.y,math.random(0,3),g.elevation)
   end
end
That should spawn "nothing" 80% no?

Code: Select all

defineObject{
	name = "nothing",
	baseObject = "base_floor_decoration",
	components = {
		{
			class = "Null",
		},
		
	},
	editorIcon = 96,
}
That is my "nothing" object.

EDIT: Ok I think I found my problem LOL.. I can't do this can I?

Code: Select all

defineObject{
	name = "base_cave_ground",
	baseObject = "base_floor",
	components = {
		{
			class = "Null",
			name = "grass",
			onInit = autoDecoFloorDetail,
		},
		{
			class = "Null",
			name = "tiles",
			onInit = autoDecoFloorDetail2,
		},
		{
			class = "Null",
			name = "pebbles",
			onInit = autoDecoFloorDetail3,
		},
	},
}
What would be the proper way to spawn 3 separate details on the same tile?
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

It's not clear to me what your objective is here. Why do you have this "nothing" object at all, instead of just not spawning anything there? You have three of these autoDecoFloorDetail functions but are only showing one of them, are the others similar?

The function you posted does spawn "nothing" 79.999999999999977796% of the time, so there's something you're not showing us.
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
vanblam
Posts: 243
Joined: Sun Nov 09, 2014 12:15 am

Re: Ask a simple question, get a simple answer

Post by vanblam »

minmay wrote: Sat Apr 06, 2019 6:22 am It's not clear to me what your objective is here. Why do you have this "nothing" object at all, instead of just not spawning anything there? You have three of these autoDecoFloorDetail functions but are only showing one of them, are the others similar?

The function you posted does spawn "nothing" 79.999999999999977796% of the time, so there's something you're not showing us.
I am stupid ROFLMAO.. turns out when I was exporting my pebbles I had a floor tile not hidden on another layer hahahaha. so when I was running them all I thought I was getting more tiles. O M G .. face palm.

Yes I have 3 separate functions running on the same floor tile and I want there to be a chance nothing will spawn there. basically I want there to be a chance for a tile,pebble and grass with a mix of the 3. So you could have a grass and a tile, tile and a pebble, just a tile etc.

On another note how would I get nothing to spawn there on the "else"? or can you end it with "elseif"?
Last edited by vanblam on Sat Apr 06, 2019 6:56 am, edited 1 time in total.
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

vanblam wrote: Sat Apr 06, 2019 6:49 amOn another note how would I get nothing to spawn there on the "else"? or can you end it with "elseif"?
um...if you want to do nothing, you don't need an "else" at all, just put the "end" there!
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
vanblam
Posts: 243
Joined: Sun Nov 09, 2014 12:15 am

Re: Ask a simple question, get a simple answer

Post by vanblam »

Code: Select all

if choice3 >= 0.4 then
	  spawn("rc_ground_pebbles_04",g.level,g.x,g.y,math.random(0,3),g.elevation)
	elseif choice3 >= 0.5 then
	  spawn("rc_ground_pebbles_01",g.level,g.x,g.y,math.random(0,3),g.elevation)
	elseif choice3 >= 0.6 then
	  spawn("rc_ground_pebbles_02",g.level,g.x,g.y,math.random(0,3),g.elevation)
	elseif choice3 >= 0.7 then
	  spawn("rc_ground_pebbles_03",g.level,g.x,g.y,math.random(0,3),g.elevation)
end
So like that?
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Exactly like that.
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.
Post Reply