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!
Summon spell, specify location syntax?
Summon spell, specify location syntax?
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
"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
Re: Summon spell, specify location syntax?
Untested, but it probably works.
Replace 'direction' in the spawn statement with '(direction + 2) % 4' if you want it to face away from the party.
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
Re: Summon spell, specify location syntax?
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
}
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
"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
Re: Summon spell, specify location syntax?
Never noticed that getForward thing before. Here I was manually checking for facing and changing the coords.
Re: Summon spell, specify location syntax?
Whoops, it should be:
spawn("snail", party.level, x + dx, y + dy, (direction + 2) % 4)
spawn("snail", party.level, x + dx, y + dy, (direction + 2) % 4)
Re: Summon spell, specify location syntax?
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 wrote:Whoops, it should be:
spawn("snail", party.level, x + dx, y + dy, (direction + 2) % 4)
Re: Summon spell, specify location syntax?
What did you replace the '(direction + 2) % 4' part with?
-
- Posts: 35
- Joined: Fri Jun 15, 2012 7:31 am
- Location: Germany
Re: Summon spell, specify location syntax?
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
In the Grimrock-Editor, a Lua script_entity(i.e. named "mySpells")
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
}
SpoilerShow
Code: Select all
function summon(direction, caster)
local dx, dy = getForward(direction)
spawn("snail", caster.level, x + dx, y + dy,(direction + 2) % 4)