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
THOM
Posts: 1280
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Ask a simple question, get a simple answer

Post by THOM »

Wasn't there a possibillity to scale down the dimensions of a model in the object definition? Kind of an equivalent to setMaterial? I cannot find an entry in the definition reference. But I believe I have read somewhere in a post about that...
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
minmay
Posts: 2789
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

You cannot scale individual components. You can translate them with the "offset" field or Component:setOffset() and rotate them with the "rotation" field or Component:setRotationAngles().
You can, however, scale entire GameObjects: get the object's transformation matrix from GameObject:getRotation(), apply whatever changes you want (which could include scaling), and pass it back to GameObject:setRotation().
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
Isaac
Posts: 3188
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Skuggasveinn wrote:If you want a very simple animation for the sarcophagus like moving it backwards one tile then that can probably be done with a script that changes its offset every frame until its in place, scripting is not my strong suit ;),(so here is hoping someone will jump in with a good model offset move example)
Another way to achieve this is to rotate the gate node; this also works in LoG1.
User avatar
THOM
Posts: 1280
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Ask a simple question, get a simple answer

Post by THOM »

is there a way to get identified, which floortrigger is pressed?

what I want to do is having a line of floortriggers. if a monster steps on one of them I want to have it pushed on the next one. for certain reasons I cannot use teleporters - I want the monster to be moved.

to avoid making several copies of nearly the same script, I'm looking for a way to identify which trigger is activated, send this information to my script and move the monster on that specific floortrigger. But I have no idea how to identify the trigger and send it's coordinates to my script...

script would look something like

local floortrigger = [information about trigger/coordinates]
local monster = [monster on same coordinates of floortrigger]
monster:knockback(0)
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
User avatar
Zo Kath Ra
Posts: 940
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Ask a simple question, get a simple answer

Post by Zo Kath Ra »

THOM wrote:is there a way to get identified, which floortrigger is pressed?

what I want to do is having a line of floortriggers. if a monster steps on one of them I want to have it pushed on the next one. for certain reasons I cannot use teleporters - I want the monster to be moved.

to avoid making several copies of nearly the same script, I'm looking for a way to identify which trigger is activated, send this information to my script and move the monster on that specific floortrigger. But I have no idea how to identify the trigger and send it's coordinates to my script...

script would look something like

local floortrigger = [information about trigger/coordinates]
local monster = [monster on same coordinates of floortrigger]
monster:knockback(0)
Put this function in a script entity:

Code: Select all

function test(caller)
	hudPrint(caller.go.id)
end
Then add a connector to the floor trigger that calls this function.
User avatar
THOM
Posts: 1280
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Ask a simple question, get a simple answer

Post by THOM »

Danke :)

This function works. So, I hoped, I could deduce a simple solution. But sadly "caller.go.monster" doesn't seem to exist.

Will find a more painful way...

EDIT: Nonsense. The result of "caller.go.id" ist the trigger, not the triggering monster...
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
minmay
Posts: 2789
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

You ASKED for the trigger, not the triggering monster. You can find the triggering monster by using trigger.go.map:entitiesAt(trigger.go.x,trigger.go.y).
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
THOM
Posts: 1280
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Ask a simple question, get a simple answer

Post by THOM »

@minmay: I meant with "nonsense" myself... just wanted to edit in, what my earlier writing was... ;)

Still some problems.

I have to do a delayedCall, because I have to stop the monsteranimation (therefore the monster self triggers the script, the knockback won't run while it's moving).
But to to handle this, I have to forward somehow which monster is meant.

I tried this, but caller seems to be an invalid message...

Code: Select all

function moveMonsterNorth(caller)
	for e in party.map:entitiesAt(caller.go.x, caller.go.y) do
		if e.monster then
			e.animation:stop()
			delayedCall(self.go.id, 0.01, "move2", caller)
		end
	end
end

function move2(caller)
	for e in party.map:entitiesAt(caller.go.x, caller.go.y) do
		if e.monster then
			e.monster:knockback(0)
		end
	end
end
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
minmay
Posts: 2789
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Store the caller's id instead of the caller itself (which is unserializable and should NEVER be stored), and use findEntity() to retrieve it. Also you want to use caller.go.map, not party.map, otherwise you will get the wrong map if the party is on the level.
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
THOM
Posts: 1280
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Ask a simple question, get a simple answer

Post by THOM »

Thanks.

my final result:

Code: Select all

function moveMonsterNorth(caller)
	for e in caller.go.map:entitiesAt(caller.go.x, caller.go.y) do
		if e.monster then
			calling = caller.go.id
			e.animation:stop()
			delayedCall(self.go.id, 0.01, "move2", calling)
		end
	end
end

function move2(calling)
	for e in party.map:entitiesAt(findEntity(calling).x, findEntity(calling).y) do
		if e.monster then
			e.monster:knockback(0)
		end
	end
end
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
Post Reply