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: 2788
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Returning false from the onDamage hook works fine for me. You are using the actual hook, and not just adding a connector, right?
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 »

minmay wrote:Returning false from the onDamage hook works fine for me. You are using the actual hook, and not just adding a connector, right?
Nope, it was a connector in this case. I guess that explains it. I had hoped not to need to define it initially. The script works as intended, it just isn't capable of canceling an attack this way. :(
I'll try it in the hook; I assume it will work then.
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 »

Found out, that there is a monster-condition "stunned".

I've tried to create a weappon, that stunns monsters. So far everything works, but all what happens is, the monster gets a bunch of stars that swirls around it's head for some secounds. No other effect AFAIK. Have I missed something or is this an unfinished implementation? Can't remember to see this effect in the main-campaign.
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
minmay
Posts: 2788
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Stun makes the monster wait longer between performing actions. Mostly useless imo, since that means the AI is less controllable/predictable.
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 wrote:Stun makes the monster wait longer between performing actions. Mostly useless imo, since that means the AI is less controllable/predictable.
I expected something like that. Not my thing then, too...

Next question: Is there a possibility to disable monster-components from monster-groups? I would like to have some monsters-groups standing frozen-like when the party is entering the areal. Nomally I would do this by disabeling the brain and animation component. But groups do not offer the checkboxes to do this in the editor. Any ideas, how to adress the monsters in a group? Then I could do this in a script... And no: defining the monstergroup as "guard" is not the same I have in mind...
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
User avatar
AdrTru
Posts: 223
Joined: Sat Jan 19, 2013 10:10 pm
Location: Trutnov, Czech Republic

Re: Ask a simple question, get a simple answer

Post by AdrTru »

What i must do for vizualization hooks from controller component in my objekt? For player managed connectors. E. G. My custom onActivate.
My LOG2 projects: virtual money, Forge recipes, liquid potions and
MultiAlcoveManager, Toolbox, Graphic text,
User avatar
The cube
Posts: 94
Joined: Tue Apr 23, 2013 6:09 pm
Location: Barren Desert

Re: Ask a simple question, get a simple answer

Post by The cube »

I know the id of a item, how do i find the items name?

Do i have to iterate through the whole map?
alois
Posts: 112
Joined: Mon Feb 18, 2013 7:29 am

Re: Ask a simple question, get a simple answer

Post by alois »

The cube wrote:I know the id of a item, how do i find the items name?

Do i have to iterate through the whole map?
No; if you know the id, then just do "findEntity(id).name" (if you need the object coordinates, do "findEntity.x" etc).

Alois :)
User avatar
The cube
Posts: 94
Joined: Tue Apr 23, 2013 6:09 pm
Location: Barren Desert

Re: Ask a simple question, get a simple answer

Post by The cube »

Code: Select all

function summonStones()
	if golem.bossfight:isEnabled() then
		spawn("summon_stone", 1, 11, 5, 1, 0)
		spawn("summon_stone", 1, 17, 5, 3, 0)
		delayedCall(golem_bossfight_script, 20, summonStones())
	end
end
When i trigger this script, the game lags out and i have to close it with control panel. What's wrong?
minmay
Posts: 2788
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

http://en.wikipedia.org/wiki/Infinite_l ... _recursion
When you call a function, the code inside it runs. Your function is immediately calling itself every time it is called because of this line:

Code: Select all

delayedCall(golem_bossfight_script, 20, summonStones())
So it will continue calling itself indefinitely until the Lua virtual machine runs out of stack space.
Since your function doesn't even return anything, I assume you meant to do this:

Code: Select all

delayedCall("golem_bossfight_script", 20, "summonStones")
delayedCall is just like a connector, the action needs to be a string argument that will be the message sent to the object's component named "controller".
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