knighters god
Active Member
- Joined
- Feb 14, 2009
- Messages
- 166
- Solutions
- 1
- Reaction score
- 40
How it looks like. *NOTE* I have only tested this on TFS 1.2 *NOTE*
The point of this thread is because, why not? It's a fun little thing ^^
About this script: This script will make a monster appear when you walk off a special tile. This tile also talks!
The point of making this script is because I want to improve in lua.
Install the script!
First navigate to data\movements\scripts
Create a new lua file with the name tileTrap.lua and add the following code to it.
Do not forget to edit the script with a unique id of you own!
in movements.xml add the following.
Do not forget to edit the script with a unique id of you own!
To add the unique id in RME you will have to right click on the tile and choose properties. Below Action id is Unique id. Enter you Unique id in the Unique id slot. Example: 11001.
Regards: Knighters God
The point of this thread is because, why not? It's a fun little thing ^^
About this script: This script will make a monster appear when you walk off a special tile. This tile also talks!
The point of making this script is because I want to improve in lua.
Install the script!
First navigate to data\movements\scripts
Create a new lua file with the name tileTrap.lua and add the following code to it.
Do not forget to edit the script with a unique id of you own!
Code:
local config =
{
_tileID = 426, -- The item id you choose to step on -- This is a stone tile
_itemUID = XXXXX, -- The unique id you choose to place in the map editor. Example: 11001 *NOTE* Must be the same as in movements.xml *NOTE*
_spawn = -- v |The spawn points| v
{
[1] = {x = 997, y = 989, z = 10}, -- To add a new spawnpoint all you have to do is add this line '[X] = {x = XXXX, y = YYYY, z = ZZ}'
[2] = {x = 994, y = 991, z = 10},
[3] = {x = 996, y = 991, z = 10}, -- When adding a new spawnpoint, do not forget to add a , (comma) after the spawnpoint above. Also add +1 to the number above inside [x]
[4] = {x = 993, y = 989, z = 10}
}, -- ^ |The spawn points| ^
_monsters =
{
[1] = "Orc",
[2] = "Orc Warlord", -- To add more monsters you will have to add more of these lines. [X] = "NAME OF YOUR MONSTER"
[3] = "Demon",
[4] = "Rat", -- When adding a new monster, do not forget to add a , (comma) after the monster above. Also add +1 to the number above inside [x]
[5] = "Orc Leader",
[6] = "Terror Bird",
[7] = "Cave Rat",
[8] = "Snake",
[9] = "Rotworm Queen",
[10] = "Minotaur Guard"
},
_StartDialogues =
{
[1] = "Could you please get your feet off of me?", -- To add a new dialogue when you step on the item you choose, add this. [X] = "YOUR DIALOGUE HERE",
[2] = "I just wanted to be a normal stone tile.",
[3] = "Why can't we just be friends? All you have to do is step off of me and say sorry <3",
[4] = "You will pay for this...",
[5] = "I can't belive you just stepped on me...", -- When adding a new dialogue, do not forget to add a , (comma) after the dialogue above. Also add +1 to the number above inside [x]
[6] = "What have I ever done to you?",
[7] = "*cough* *cough* *cough* *cough*",
[8] = "I'm getting to old for this.",
[9] = "Thank you for putting your feet right there. I'll give you a present.",
[10] = "Dick!"
},
_EndDialogues =
{
[1] = "HAHA! YOU FOOL!",
[2] = "PROTECT YOURSELF AGAINST THIS!",
[3] = "NEVER TRUST A STONE TILE! MUAHAHAHA! **Altough my brother hates this kind of stuff.** ",
[4] = "TASE MY ANGER!",
[5] = "How about I'll just give you a friend!",
[6] = "Don't see it as hatred for you. See it as payback.",
[7] = "SAY HELLO TO MY LITTLE FRIEND!",
[8] = "Here! Have a suprise!",
[9] = "Is it your birthday? WELL, HAPPY BIRTHDAY!",
[10] = "Make yourself a new friend... IN HELL!"
}
}
function onStepIn(creature, item, pos, fromPos)
if item.uid == config._itemUID and item.itemid == config._tileID then
--doCreateItem(2160, 5, pos) -- If you uncomment this line of code you will create an item underneath, when a creature (Players or monsters) walks on it. doCreateItem(ITEMID, AMOUNT, pos)
doCreatureSay(creature, config._StartDialogues[math.random(1, #config._StartDialogues)], TALKTYPE_ORANGE_1)
doSendMagicEffect(getCreaturePosition(creature), CONST_ME_HITAREA)
end
return true
end
function onStepOut(creature, item, pos, fromPos)
doSummonCreature(config._monsters[math.random(1, #config._monsters)], config._spawn[math.random(1, #config._spawn)])
doCreatureSay(creature, config._EndDialogues[math.random(1, #config._EndDialogues)], TALKTYPE_ORANGE_1)
doSendMagicEffect(getCreaturePosition(creature), CONST_ME_GIFT_WRAPS)
return true
end
Do not forget to edit the script with a unique id of you own!
Code:
<movevent event="StepIn" uniqueid="XXXXX" script="tileTrap.lua"/> <!-- XXXXX = uniqe id. For example 11001 -->
<movevent event="StepOut" uniqueid="XXXXX" script="tileTrap.lua"/> <!-- Grab the same uniqe id has above -->
To add the unique id in RME you will have to right click on the tile and choose properties. Below Action id is Unique id. Enter you Unique id in the Unique id slot. Example: 11001.
Regards: Knighters God