Page 179 of 395

Re: Ask a simple question, get a simple answer

Posted: Thu Jan 05, 2017 8:16 am
by THOM
The lightning_bolt_blast has an irritating behaviour (like all the other blasts have). What if you spawn something else? e.g. "barrel_crate_block"

Re: Ask a simple question, get a simple answer

Posted: Thu Jan 05, 2017 8:43 am
by Killcannon
THOM wrote:The lightning_bolt_blast has an irritating behaviour (like all the other blasts have). What if you spawn something else? e.g. "barrel_crate_block"

Irritating at this point is putting it lightly, I did go ahead and try a barrel_crate_block, beach_crab, and plate_cuirass. None of them spawned when triggered. I tried a different map with the same result. Out of curiosity. I went back to the puzzle that I know was working fine earlier before running into this problem and it is no longer working. So... ~tosses papers into the air~ ... I guess the dungeon is broke? Funny thing is, the puzzles that I used the spawner object with still work fine.

Re: Ask a simple question, get a simple answer

Posted: Thu Jan 05, 2017 9:50 am
by THOM
Have you edited the dungeon File by hand? Maybe something went wrong then.

Re: Ask a simple question, get a simple answer

Posted: Thu Jan 05, 2017 11:21 am
by alois
Killcannon wrote:
Isaac wrote:The function is called once, but each pass through the x loop usually comes with a full pass through the y loop, [7 passes through the y loop, if fmax == 3].

Is this nested loop intended just for spawning a set number of lightning bolts in fixed positions?

**If so, there might be a simpler way to script it.
Interestingly enough if I do this:

Code: Select all

function frostexplosion()

	spawn("lightning_bolt_blast", 1, 22, 9, 0, 1) print("Yes 2")

end
It doesn't work either, and 22, 9 is the location of the pressure plate. I don't think this script could any simpler than that. It's still faithfully printing "Yes 2" though, and printing it once.
Aren't you spawning blasts at the wrong level number? In your dungeon, the level number is 5 :)
Also, the "else part" stops the loop as soon as x = 0 and y = 0, i.e., halfway through the loops.

Alois :)

Re: Ask a simple question, get a simple answer

Posted: Thu Jan 05, 2017 4:29 pm
by Killcannon
alois wrote: Aren't you spawning blasts at the wrong level number? In your dungeon, the level number is 5 :)
Also, the "else part" stops the loop as soon as x = 0 and y = 0, i.e., halfway through the loops.

Alois :)
Seriously? ..... I... well slap a dunce cap on me and call me stupid. I'd been playing with the map positions in the project to keep them 'geographically' together as I added and removed maps. I somehow was under the impression that the 'level' coordinate in the function referred to the spell caster level, not the maps number in the list; and that the elevation was the 'level' everyone was speaking about. Don't ask me how I came up with that, as I seriously don't remember. Though it all makes sense to me now and I cannot believe how silly this has all been.

Thanks Alois for downloading and checking out the files for me, and thanks to everyone else as I led them through a maze of misinformation and misunderstanding on my part.

Re: Ask a simple question, get a simple answer

Posted: Thu Jan 05, 2017 4:34 pm
by alois
Killcannon wrote:
alois wrote: Aren't you spawning blasts at the wrong level number? In your dungeon, the level number is 5 :)
Also, the "else part" stops the loop as soon as x = 0 and y = 0, i.e., halfway through the loops.

Alois :)
Seriously? ..... I... well slap a dunce cap on me and call me stupid. I'd been playing with the map positions in the project to keep them 'geographically' together as I added and removed maps. I somehow was under the impression that the 'level' coordinate in the function referred to the spell caster level, not the maps number in the list; and that the elevation was the 'level' everyone was speaking about. Don't ask me how I came up with that, as I seriously don't remember. Though it all makes sense to me now and I cannot believe how silly this has all been.

Thanks Alois for downloading and checking out the files for me, and thanks to everyone else as I led them through a maze of misinformation and misunderstanding on my part.
If you do not want to remember the level number, you can use "spawn(object,party.level,x,y,facing,elevation)". In this way, the spawned object is in the same level as the party.

Alois :)

Re: Ask a simple question, get a simple answer

Posted: Thu Jan 05, 2017 9:56 pm
by billb52
akroma222 wrote:
billb52 wrote:Hi All, Can anyone help with 'swamp_dead_tree' I want to be able to click on the hole in the tree to retrieve/place objects in or out of hole and have a connector
that will activate/deactivate door etc. I have set baseObject = "altar" on swamp_dead_tree defineObject and added class = "Surface", class = "Clickable" and
class = "Socket" but cannot get any item to be in the hole altering offset/size vec. Am I barking up the wrong tree here? Is there a better way PLS Help
Hey billb52,
here is a simple definition of swamp_dead_tree with added Surface and Clickable components
Add an item like long_sword to it in the editor - then change the offset/size vec etc
SpoilerShow

Code: Select all

defineObject{
	name = "swamp_dead_tree_new",
	baseObject = "base_obstacle",
	components = {
		{
			class = "Model",
			model = "assets/models/env/swamp_dead_tree.fbx",
			staticShadow = true,
		},
		-----------------------------cut pasted from asset pack 2 - base objects
		{
			class = "Surface",
			offset = vec(0, 0.85, 0.2),
			size = vec(1.3, 0.65),
			--debugDraw = true,
		},
		{
			class = "Clickable",
			offset = vec(0, 0.85+0.4, 0.2),
			size = vec(1.3, 0.8, 0.65),
			--debugDraw = true,
		},
		------------------------------
	},
	placement = "floor",
	editorIcon = 172,
	automapTile = "trees",
	minimalSaveState = true,
}
If you wanted to use a Socket component then change the Surface component for this Socket component
Again you will need to change the offset - this is straight from the asset pack Torch Holder
SpoilerShow

Code: Select all

{
			class = "Socket",
			offset = vec(0.05, 1.53, -0.25),
			rotation = vec(0, -20, -90),
			onAcceptItem = function(self, item)
				return (item.go.name == "...item_that_fits..." or item.go.name == "...another_item_that_fits...") and self:count() == 0
			end,
		},
Alternatively, to simply make an item retrievable from the swamp tree hole - dont add any components and just use:

Code: Select all

item_that_fits:setWorldPosition(vec(x, y ,z))
item_that_fits:setWorldRotationAngles(x, y ,z)
This - im fairly sure - is how the Island Master's letter is placed in the Forest Oak hole (in Grimrock 2's forest)
Thx you were a great help!

Re: Ask a simple question, get a simple answer

Posted: Fri Jan 06, 2017 12:57 am
by zimberzimber
How do I modify a hook through scripts outside outside of a definition?
For example, I want this to apply to a monster...

Code: Select all

onDie = function(self)
	print(self.go.id)
end,
But only if I define it through a script entity. Something like...

Code: Select all

function spawnMonster()
	local m = spawn("myMonster", 1, 1, 1, 1, 0)
	m.monster.onDie = function(self)
		print(self.go.id)
	end
end

Re: Ask a simple question, get a simple answer

Posted: Fri Jan 06, 2017 2:32 am
by minmay
You cannot dynamically modify hooks, but you can always define a hook that calls a function you can dynamically change - that's why the hook framework was created to do this automatically for you.
This still won't let you add hooks to dynamically created Components though.

Re: Ask a simple question, get a simple answer

Posted: Fri Jan 06, 2017 3:47 am
by Isaac
zimberzimber wrote:How do I modify a hook through scripts outside outside of a definition?
minmay wrote:You cannot dynamically modify hooks, but you can always define a hook that calls a function you can dynamically change
...Addendum: Pre-existing hooks can have connectors applied dynamically; but these connected functions cannot cancel the event/action.

Example:

Code: Select all

function died(monster) print('A spawned  '..monster.go.name.." just died!") end
function think(monster) print('A spawned  '..monster.go.name.." thought of something!") end

function poof()
	local dX,dY = getForward(party.facing)
	local M = spawn("crowern",party.level, party.x+dX, party.y+dY, (party.facing+2)%4, party.elevation)
	M.monster:addConnector("onDie", self.go.id, "died")
	M.brain:addConnector("onThink", self.go.id, "think")
end
poof()