Summon spell, specify location syntax?

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Summon spell, specify location syntax?

Post by msyblade »

Makin a new summon spell, got it all except the placement of the spawn, (ie. location) I'd like it to just appear 1 square in front of you, here's what I got and it all works/no errors,even says "discovered new spell "Summon". Snail simply doesnt appear cause i havent specified where to spawn it.

defineSpell{
name = "summon",
uiName = "Summon",
skill = "spellcraft",
level = 16,
runes = "ACD",
manaCost = 35,
onCast = function(caster, x, y, direction, skill)
spawn("crab")
end
}
I know its pretty simple, just need the syntax at spawn("crab") for location. Thanx!
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
Decayer
Posts: 65
Joined: Sat Oct 13, 2012 3:19 pm

Re: Summon spell, specify location syntax?

Post by Decayer »

Untested, but it probably works.

Code: Select all

onCast = function(caster, x, y, direction, skill)
local dx, dy = getForward(direction)
spawn("crab", caster.level, x + dx, y + dy, direction)
end
Replace 'direction' in the spawn statement with '(direction + 2) % 4' if you want it to face away from the party.
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Re: Summon spell, specify location syntax?

Post by msyblade »

Thank u decayer, It is not giving any errors on export or casting, but nothing appears on succesful cast. Heres what I have now (thanx again)

defineSpell{
name = "summon",
uiName = "Summon",
skill = "spellcraft",
level = 16,
runes = "ACD",
manaCost = 35,
onCast = function(caster, x, y, direction, skill)
local dx, dy = getForward(direction)
spawn("snail", caster.level, x + dx, y + dy,(direction + 2) % 4)
end
}
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
Lmaoboat
Posts: 359
Joined: Wed Apr 11, 2012 8:55 pm

Re: Summon spell, specify location syntax?

Post by Lmaoboat »

Never noticed that getForward thing before. Here I was manually checking for facing and changing the coords.
Decayer
Posts: 65
Joined: Sat Oct 13, 2012 3:19 pm

Re: Summon spell, specify location syntax?

Post by Decayer »

Whoops, it should be:
spawn("snail", party.level, x + dx, y + dy, (direction + 2) % 4)
Grimorial
Posts: 13
Joined: Sun Oct 07, 2012 4:18 am

Re: Summon spell, specify location syntax?

Post by Grimorial »

Decayer wrote:Whoops, it should be:
spawn("snail", party.level, x + dx, y + dy, (direction + 2) % 4)
I tried this with on use for an item without the (direction +2)%4. I did swap caster.level for party.level and it just kept crashing the editor. Any thoughts?
Decayer
Posts: 65
Joined: Sat Oct 13, 2012 3:19 pm

Re: Summon spell, specify location syntax?

Post by Decayer »

What did you replace the '(direction + 2) % 4' part with?
Lollgramoth
Posts: 35
Joined: Fri Jun 15, 2012 7:31 am
Location: Germany

Re: Summon spell, specify location syntax?

Post by Lollgramoth »

Call a function in a LUA script_entity. That will not solve your problem, but it will prevent the game from crashing if the error occures. And it will give you an error message.

spells.lua
SpoilerShow

Code: Select all

defineSpell{
name = "summon",
uiName = "Summon",
skill = "spellcraft",
level = 16,
runes = "ACD",
manaCost = 35,
onCast = function(caster, x, y, direction, skill) 
 mySpells.summon(direction, caster)
end
}
In the Grimrock-Editor, a Lua script_entity(i.e. named "mySpells")
SpoilerShow

Code: Select all

function summon(direction, caster)
local dx, dy = getForward(direction)
spawn("snail", caster.level, x + dx, y + dy,(direction + 2) % 4)
Post Reply