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 »

akroma222 wrote:Question - can we recreate Attack Swipes ??
I know all the Attack Swipe models are in the asset pack, using "swipe01" material.
...and also that we can set new materials/textures etc etc
Just wondering if we can actually override / replicate / mimic the Attack Swipes ??
Ta!
I did for my Tiger Strength potion; but was a bit of a kludge, and is more of an additive effect.
https://www.dropbox.com/s/tq3vk02qubnp0 ... m.avi?dl=0

This was done by adding a disabled model to the party, and toggling it on/off for any melee attacks. Each time they attack... the custom swipe effect is shown, and then disabled.

**It might also be possible to make a particle effect, and just spawn one in front of the party with each attack; I didn't try that though.

IRRC the engine calls the swipe model files by name, so there didn't seem to be a way to redefine or override that. If it exists as a model component [somewhere], then it might be possible to override that once the name is known ~if such is the case.
Last edited by Isaac on Sat Feb 04, 2017 8:52 pm, edited 1 time in total.
Gradunk
Posts: 54
Joined: Tue Oct 22, 2013 2:26 am
Location: Calgary, Canada

Re: Ask a simple question, get a simple answer

Post by Gradunk »

Code: Select all

function warden4()
	hudPrint ("Did you or did you not? Be quick about it!")
	castle_pit_trapdoor_1:open()
end
what the hell am i doing wrong here? i've looked everywhere and that's what i've found to have worked for others but it crashes my test cause open is a nil value?
i know this is unrelated but thanks
I smell you, i do! You GRADUNK! No be hiding on TORGAL!
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 »

Gradunk wrote:what the hell am i doing wrong here?

Code: Select all

castle_pit_trapdoor_1.door:open()
Objects have component [class] functions in LoG2, it means accessing them by name. Even the party object has a party component, and has to be accessed via party.party.

**You can see these components in the editor in the object inspector.
Last edited by Isaac on Sat Feb 04, 2017 8:56 pm, edited 1 time in total.
Gradunk
Posts: 54
Joined: Tue Oct 22, 2013 2:26 am
Location: Calgary, Canada

Re: Ask a simple question, get a simple answer

Post by Gradunk »

Objects have component functions in LoG2, it means accessing them by name. Even the party object has a party component, and has to be accessed viaq party.party.
ooooooooh thats what the pitComponent thing means. identify what it is you're altering! thanks
I smell you, i do! You GRADUNK! No be hiding on TORGAL!
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 »

Image

Here is the component list:
https://github.com/JKos/log2doc/wiki/Components

The first entry [Component], lists the methods and properties common to all; the rest of the list is information specific to each.
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 »

When I put this code in items.lua, everything works fine:

Code: Select all

function oei(self, champion, slot)
    print(self.go.id, champion:getName(), slot)
end

defineObject{
	name = "bone_amulet_new",
	baseObject = "base_item",
	components = {
		{
			class = "Model",
			model = "assets/models/items/bone_amulet.fbx",
		},
		{
			class = "Item",
			uiName = "Bone Amulet",
			description = "A primitive amulet made out of bones that are bound together with string.",
			gfxIndex = 65,
			weight = 0.2,
			traits = { "necklace" },
			
			onEquipItem = oei,
		},
	},
}
But this code in items.lua crashes the editor with "attempt to call global 'oei' (a nil value)"

Code: Select all

function oei(self, champion, slot)
    print(self.go.id, champion:getName(), slot)
end

defineObject{
	name = "bone_amulet_new",
	baseObject = "base_item",
	components = {
		{
			class = "Model",
			model = "assets/models/items/bone_amulet.fbx",
		},
		{
			class = "Item",
			uiName = "Bone Amulet",
			description = "A primitive amulet made out of bones that are bound together with string.",
			gfxIndex = 65,
			weight = 0.2,
			traits = { "necklace" },
			
			onEquipItem = function(self, champion, slot)
			    oei(self, champion, slot)
			end,
		},
	},
}
Is there any way to call functions defined in a lua file from hooks in the same file?
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Hook functions get a similar environment to ScriptComponents, so they won't see anything that you put in the init files' environment. You can add the 'local' keyword to your oei function to make it an upvalue and then it will work for this purpose, but of course that means you can only use it in hooks that never get serialized.
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: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

minmay wrote:... but of course that means you can only use it in hooks that never get serialized.
How does one know which ones those are? :?
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Not sure, other than trial and error.
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
Mysterious
Posts: 226
Joined: Wed Nov 06, 2013 8:31 am

Re: Ask a simple question, get a simple answer

Post by Mysterious »

Hi all.

I have been searching for a Musical piece or 2 for the Inn I have made in my Mod. Alas to no avail :(

Most of you have heard a musical score play in most RPG Games when you enter a (Inn). So I was wondering can anyone direct me to a site where the Music File would either be free or low cost?

Thank you.
Post Reply