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
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Pompidom wrote: Thu Sep 27, 2018 10:13 pm not really, but it should be easy to figure out looking at other editor files,

what I need the most help with is a scriptline that:

findEntity vampire_7 and then spawn a fire effect on the random location where his brain got disabled.

Code: Select all

--call delayedDeath() when ready

function delayedDeath()
	delayedCall(self.go.id, 2, "death")
end

function death()
	if vampire_7 then
		vampire_7:spawn('wall_fire')
		vampire_7.monster:die()
	end	
end
__________

Alternately:

Code: Select all

--This one can affect any monster

function delayedDeath(monsterId) 
	local monster = findEntity(monsterId)
	if monster then
		monster:spawn('wall_fire')
		monster.brain:disable()
		delayedCall(self.go.id, 5, 'death', monsterId)
	end	
end

function death(monsterId)
	local monster = findEntity(monsterId)
	if monster then
		monster.monster:die()
		monster:playSound('party_fall')
	end	
end

--call delayedDeath when ready

delayedDeath('vampire_7')
Last edited by Isaac on Thu Sep 27, 2018 11:21 pm, edited 3 times in total.
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 »

Instead of spawning a wall_fire on the monster's tile, you can set the monster on fire:
viewtopic.php?f=22&t=7951&p=90491#p90491
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 »

That works. 8-)

*But it looks better to use both: (...though one might just want the vampire itself to burn.)

Image

Code: Select all

function delayedDeath(monsterId) 
	local monster = findEntity(monsterId)
	if monster then
		monster.monster:setCondition("burning",5)
		monster:spawn('wall_fire')
		monster.brain:disable()
		delayedCall(self.go.id, 5, 'death', monsterId)
	end	
end

function death(monsterId)
	local monster = findEntity(monsterId)
	if monster then
		monster.monster:die()
		monster:playSound('party_fall')
	end	
end

--call delayedDeath when ready

delayedDeath('vampire_7')
Pompidom
Posts: 497
Joined: Sun May 06, 2018 9:42 pm

Re: Ask a simple question, get a simple answer

Post by Pompidom »

EDIT: I got it working properly :)
Thank you!
Pompidom
Posts: 497
Joined: Sun May 06, 2018 9:42 pm

Re: Ask a simple question, get a simple answer

Post by Pompidom »

Is there a script/code line that resets an object to the default position it was assigned to?

In this particular case a g1_catwalk that moves up and down as an elevator.

The movement script is halted by a floor trigger and then you press a button to reset it to the default position.
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 »

Usually one just stores the location, then uses it later in the script. For one object, you can just manually record it in the script.

Code: Select all

g1_catwalk_1_starting_location = {level=1, x=15, y=15, facing=0, elevation=0}  --for example
But if you have placed a lot of them (or if the object spawns at a random location each time), it is convenient to have them record their own locations into a dedicated script, with a setter function. Code placed in any of the object's onInit hooks, could call a script with whatever its current location is, and store it there for later use.
Last edited by Isaac on Sat Sep 29, 2018 7:48 pm, edited 1 time in total.
Pompidom
Posts: 497
Joined: Sun May 06, 2018 9:42 pm

Re: Ask a simple question, get a simple answer

Post by Pompidom »

I will just need to use it on a few objects.

I'll see what I can do with this line :)
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 »

Here is a more compact way to do it:

Code: Select all

g1_catwalk_1_starting_location = {15,15,0,0,1}
If used in the same script as the above:

Code: Select all

g1_catwalk_1:setPosition(unpack(g1_catwalk_1_starting_location))
_____

But of course... If it is just the one object, then all you really need is just to call the setPosition function with the known starting location:

Code: Select all

g1_catwalk_1:setPosition(15,15,0,0,1)
If you want that called from a button or trigger, then you put in in its own function, and add a connector from the trigger.

Code: Select all

function resetLoc()
g1_catwalk_1:setPosition(15,15,0,0,1)
end
furiousuk
Posts: 6
Joined: Wed Mar 09, 2016 12:18 am

Re: Ask a simple question, get a simple answer

Post by furiousuk »

Thanks @pompidom and @Zo Kath Ra for the answers on the torch stuff. Got it working now.

Now setting to work on changing particle and glow colour for different types of torch.
User avatar
KhrougH
Posts: 76
Joined: Tue Sep 04, 2018 11:45 pm
Location: Roma

Re: Ask a simple question, get a simple answer

Post by KhrougH »

here is my simple question:
i'm using a "setWorldPosition" on a "lock":
https://drive.google.com/open?id=1jMe4V ... 8n5QVcB7b
but i can't use a key to open the door because on the visual position it doesn't work and at the center of the screen (where the lock should be without "setWorldPosition") the champion throw the key.

how can i solve this problem?

for the moment i'm putting the lock in the original position,

https://drive.google.com/open?id=1QhGsX ... 3STyHnRp-E

unlock the door without opening it and when you click on the door the lock disappear (onClick ... lock:destroy)

https://drive.google.com/open?id=1xTqRw ... eu6OFPGM-
but why it doesn't work with the "world positioning"?
[...]
All those moments will be lost in time, like tears in rain.
Time to die.
Post Reply