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!
rlewarne04
Posts: 13
Joined: Wed Feb 04, 2015 9:05 pm

Re: Ask a simple question, get a simple answer

Post by rlewarne04 »

Ahhh I see, ok thanks Isaac I'll check more prudently next time :)
rlewarne04
Posts: 13
Joined: Wed Feb 04, 2015 9:05 pm

Re: Ask a simple question, get a simple answer

Post by rlewarne04 »

I just tested it using :isActivated and it works fine. Onto specific item triggers now lol :)
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Ask a simple question, get a simple answer

Post by AndakRainor »

Is it possible to loop through all spells definitions ? I would like to generate automatically all the corresponding scrolls rather than define them individually (and I have a ton of spells).
User avatar
Isaac
Posts: 3182
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

AndakRainor wrote:Is it possible to loop through all spells definitions ? I would like to generate automatically all the corresponding scrolls rather than define them individually (and I have a ton of spells).
What exactly are you trying to do? (Or, what specifically do you need done?)

Are you trying to 'loop through' a list of currently defined spells?, or trying to spawn a collection of scrolls? [..in an alcove?]
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Ask a simple question, get a simple answer

Post by AndakRainor »

Isaac wrote:
AndakRainor wrote:Is it possible to loop through all spells definitions ? I would like to generate automatically all the corresponding scrolls rather than define them individually (and I have a ton of spells).
What exactly are you trying to do? (Or, what specifically do you need done?)

Are you trying to 'loop through' a list of currently defined spells?, or trying to spawn a collection of scrolls? [..in an alcove?]
Oh sorry ! It is not about spawning anything that's why I'm a little lost... I defined a lot of spells, and I need to define all the corresponding scrolls. I wondered if there was an easy way to do it or if I needed to write each definition individually (long task in perspective). I know how to manipulate entities or components but what about definitions themselves ?
User avatar
Isaac
Posts: 3182
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

AndakRainor wrote:Oh sorry ! It is not about spawning anything that's why I'm a little lost... I defined a lot of spells, and I need to define all the corresponding scrolls. I wondered if there was an easy way to do it or if I needed to write each definition individually (long task in perspective). I know how to manipulate entities or components but what about definitions themselves ?
There is.

You are free to create & call functions in the initial scripts.

You could do something like this [pseudo]:

Code: Select all

function makeScrolls()
...
end
makeScrolls()
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Ask a simple question, get a simple answer

Post by AndakRainor »

Isaac wrote:
AndakRainor wrote:Oh sorry ! It is not about spawning anything that's why I'm a little lost... I defined a lot of spells, and I need to define all the corresponding scrolls. I wondered if there was an easy way to do it or if I needed to write each definition individually (long task in perspective). I know how to manipulate entities or components but what about definitions themselves ?
There is.

You are free to create & call functions in the initial scripts.

You could do something like this [pseudo]:

Code: Select all

function makeScrolls()
...
end
makeScrolls()
Thanks ! So any idea how I could access all the spells definitions in this function and for each get its name and uiName (the two values necessary to define a spell scroll) ?
rlewarne04
Posts: 13
Joined: Wed Feb 04, 2015 9:05 pm

Re: Ask a simple question, get a simple answer

Post by rlewarne04 »

Hi guys

I've been trying for hours to get a script to work in which a Skull placed on a forest altar will trigger a teleporter to activate. Simple if done using connectors, I know. But I only want it to activate the teleporter with the skull and have nothing happen with any other item placed on it. I've looked in the scripting reference and tried different methods and I even watched an alcove puzzle tutorial and tried to make it work with this but it didn't and I'm sure I'm either missing something very simple or very obvious.

Maybe one of you could help me write a script to make it possble?

Thanks in advance
User avatar
Isaac
Posts: 3182
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

rlewarne04 wrote:Hi guys

I've been trying for hours to get a script to work in which a Skull placed on a forest altar will trigger a teleporter to activate. Simple if done using connectors, I know. But I only want it to activate the teleporter with the skull and have nothing happen with any other item placed on it. I've looked in the scripting reference and tried different methods and I even watched an alcove puzzle tutorial and tried to make it work with this but it didn't and I'm sure I'm either missing something very simple or very obvious.

Maybe one of you could help me write a script to make it possble?

Thanks in advance
;)
This is the dungeon alcove version. Should be placed in object.lua

Code: Select all

defineObject{
	name = "dungeon_skull_alcove",
	baseObject = "base_alcove",
	components = {
		{
			class = "Model",
			model = "assets/models/env/dungeon_wall_alcove.fbx",
			staticShadow = true,

		},
		{
			class = "Occluder",
			model = "assets/models/env/dungeon_wall_alcove_occluder.fbx",
		},

						{
			class = "Surface",
			offset = vec(0, 0.85, 0.2),
			size = vec(1.3, 0.65),
			onInsertItem = function(self, item)
								if item.go.name == "skull" then
									skull_teleporter_1.controller:activate() -- This MUST match the name of your teleporter. In this case the name is "skull_teleporter_1"
								end
							end
		},

	},
}
rlewarne04
Posts: 13
Joined: Wed Feb 04, 2015 9:05 pm

Re: Ask a simple question, get a simple answer

Post by rlewarne04 »

Ok That looks great. I'm putting all of that into object.lua?

So do I change it to a forest altar by altering the script you gave me to fit what I need?

Thank you so much :)
Post Reply