Page 1 of 2
a script to trigger when a rune is cast
Posted: Tue Oct 28, 2014 7:20 pm
by Karinas23
Much like getting teleported when you cast the balance rune at the en d of the main game....( i dont know shit about scripting )
Basically i want a door to open when a specific rune is cast while stood on a specific tile. any idea how id go about that
Re: a script to trigger when a rune is cast
Posted: Thu Nov 13, 2014 1:35 pm
by akroma222
Karinas23
Define the spell in your spells.lua
Code: Select all
defineSpell{
name = "karinas_spell",
uiName = "Karinas Spell",
requirements = {"concentration", 1},
gesture = 147,
manaCost = 5,
icon = 0,
spellIcon = 0,
description = "door to open when a specific rune is cast while stood on a specific tile.",
onCast = function(champion, x, y, direction, elevation, skillLevel)
customSpellScript.script.karinaSpellCast(champion, x, y, direction, elevation, skillLevel)
end,
}
Then place a script entity in your dungeon called 'customSpellScript' and paste this into it...
Code: Select all
function karinaSpellCast(champion, x, y, direction, elevation, skillLevel)
local square = findEntity("karinaSpellSquare")
if (party.level == square.level
and party.x == square.x
and party.y == square.y
and party.elevation == square.elevation) then
hudPrint("Success!!.... do stuff here.")
karinaDoor.door:open()
playSound("level_up")
else
hudPrint("You need to be standing on the grass...")
champion:playDamageSound()
end
end
Then place an object (forest_floor_01 for example) somewhere in your dungeon and name it 'karinaSpellSquare'
Lastly place a door (castle_door_wood for example) somewhere in your dungeon (probably close by) and name it 'karinaDoor' - DONE!
The spell uses the 3 runes on the left, top left to bottom left.
Re: a script to trigger when a rune is cast
Posted: Thu Nov 13, 2014 1:46 pm
by Karinas23
ty i will try this....i assume gesture = 147 is the runes required ? as in
123
456
789 ?
Re: a script to trigger when a rune is cast
Posted: Thu Nov 13, 2014 2:25 pm
by akroma222
Yup!
The spell uses the 3 runes on the left, top left to bottom left.
Re: a script to trigger when a rune is cast
Posted: Thu Nov 13, 2014 3:04 pm
by Karinas23
now i can create my doors sealed with rank 5 elemental spells ;p
Re: a script to trigger when a rune is cast
Posted: Thu Nov 13, 2014 3:36 pm
by Karinas23
Spell just causes an error ;p
Re: a script to trigger when a rune is cast
Posted: Thu Nov 13, 2014 3:48 pm
by Blichew
What's the error ?
From the top of my head: is the spell actually "castable" ? I mean does it form a line on the casting grid ?
Re: a script to trigger when a rune is cast
Posted: Thu Nov 13, 2014 3:51 pm
by Karinas23
its castable....the error happens when i cast it
Re: a script to trigger when a rune is cast
Posted: Thu Nov 13, 2014 3:54 pm
by Blichew
Looks like you don't have customSpellScript script_entity in the game.
Could you post spell definition here ? code from customSpellScript script_entity might come handy too...
Re: a script to trigger when a rune is cast
Posted: Thu Nov 13, 2014 3:58 pm
by Karinas23
never mind i got it, the danger of having your own name in scripts....automatically capitalising it without realising