- Joined
- Nov 17, 2010
- Messages
- 6,830
- Solutions
- 586
- Reaction score
- 5,413
This thread in it's entirety is a work in progress.
I have not completed the tutorial, nor have I fully spell-checked it at this point in time.
I will be updating it over the next couple of weeks based on suggestions/criticism.
I will be reserving the first 3 posts for the tutorials, and the 4th post, in case I require the extra space. (which is likely.)
The 4th post will likely be comprised of copy-paste scripts for people to use,
and for the questions/answers section.
I realise that each post can have 25k letters.
I want to try to keep the letter count of each post to 15-20k, in case I need to add additional sections explaining stuff I have missed.
When I feel I have completed this guide to my expectations, I will remove this section.
Cheers to all,
Xikini
--------------------------------------------------------
The newb scripting guide; How to go from Newb to Noob in Ot's.
Hello there, my online name is Xikini. X-uh-keen-EE.
If you can't pronounce my name do not read further! I don't wanna teach you anything! (just kidding.)
Before you start to read this thread you will need to have set-up your server.
Some great tutorials to do this can be found here, here, here and here.
A fully set-up server, in my eyes, requires 4 things.
[1] You and others can create characters.
[2] You and others can log into your server.
[3] You have edited one of your characters into a god character.
[4] You know how to pronounce my name.
If you have completed the above steps, then you are ready to undertake your next challenge, Actually creating your server!
My goal at the end of this thread..
[1] You should know what each of the standard files do. [actions/movements/talkactions/et cetera]
[2] You should know how to create basic scripts.
[3] Teach you things at a very relaxed pace, while explaining everything as if you were explaining to your grandmother how to turn on their pc.
[3] You should feel like you are at least semi-floating on water instead of sinking rapidly into the abyss.
[4] And Finally, you should feel confident that you have gone from newb to noob.
Be warned. I'm notorious for walls of text. Before I even start writing this I'm writing this.
This will likely be a very long wall of text with a few code snippets, and maybe some images/gifs.
I will also like to warn, I am not an educated scripter.
I have never gone to school for any of this knowledge.
I have done everything through trial and error.
My scripting style, comments, any scripts I provide as lessons, are all probably garbage.
However! They are working garbage. Very functional, very working, garbage.
Most of the mods and elite scripters probably shake their head everytime I post help or scripts on this forum.
Basically my knowledge of scripting amounts to knowing how tables/loops/arrays work.
If you went to school for a scripting language, you were probably taught the above three things within your first two weeks of class.
I'm fairly smart. I know how to look around for stuff I don't know, and I'm not afraid to fail.
Nobody should be afraid to fail. Everytime you fail to do something you are gaining valuable knowledge.
However if you fail and give up, the only thing you are learning is how to give up when something proves to be difficult.
If you want to create an OT, I'm telling you right now that you will cry into your pillow three nights from now and wish the headaches would stop coming.
I'm totally kidding. I'm definitely not talking from experience. I definitely wasn't 14 years old.
I was a mature adult with the knowledge of everything. I opened my text document and a server was born within 3 weeks.
Alright, enough kidding around.
Let's start learning the basics.
The difference between your client version and your TFS version.
Your client version is your Tibia Clients Version.
Your client version simply tells you what sprites you will be able to use.
Popular client versions are 7.6, 8.0, 8.6, 9.6, 10.77.. et cetera.
Your TFS version is the version of your server.
Your TFS version will tell other people what kind of scripting style, and what available functions your server is allowed to use.
Popular New TFS versions are 1.1, 1.2.
Popular Old TFS versions are 0.3.6, 0.3.7, 0.4.
Anytime you create a thread on the forum, people will ask what TFS you are using.
If they don't know what TFS you are using, they may post code that is incompatable with your server.
I myself use TFS 0.3.7. All of my examples will be using this TFS, because this is what I am familiar with.
Although Old and New TFS versions are slightly different in coding style, the underlying file structure is fairly the same.
You can tell the difference between Old and New TFS by looking for these :::::.
New TFS will use these things in their code.
From my understanding it will call specific data, then use that data in a function.
Alright, next Topic.
What is the difference between the folders located in data/... , and what do they do?
[insert picture here]
[actions] This type of script is used when a player is interacting with any object. Ctrl + Click
[creaturescripts] This type of script is used when a creature [player/monster/npc] does something.
(When a player advances in skill, when a player looks at something, when a player logs in or out,
When a player takes damage, when a player targets a monster, when a player dies or kills something.
You can then script something to happen.)
[globalevents] This type of script effects many players or all players.
[items] This is where you edit your items and their values. (attack/defence/armor/names of items)
[lib] This holds useful information for scripting. You will probably use 1 or 2 files in here. The rest are UFO's.
[logs] This holds a lot of bug reports. Only useful file for newbs.. might be talkactions - for each player.
If you think a GM is spawning items for players/himself, you can check what talkactions they have used previously.
[monster] This is where you find all of your monsters. You can edit health/attack/defence/loot/et cetera
[movements] This type of script happens when a player walks or equips armor or moves an item onto a square.
[npc] Non-Player Character. This is where your npc files are located.
[raids] This is where you can set-up raids. Nobody fully understands how these work.
[spells] This is where you find spells. Their mana cost / who can use them / how they work.
[talkactions] God commands or player commands. /online or !online
[weapons] These are weapon scripts. They are kind of like spells, but for specific weapons.
[world] Your map. Your map goes here.
You can change these values at anytime. Just restart your server to test the new rates.
There is a ton of more stuff in config.lua you can change.
I'd suggest going through the entire document and fiddling around with stuff.
If you can't easily guess what something does.. I'd suggest not touching it.
Next basic thing would be editing items. data/items/items.xml
For many people this is their first large task.
You open up this document using notepad++ and the first thing you ask is; why is this file so long?!
Good question! It's long, because it holds the data of every single item in the game!
So if you mess something up in here, your server will definitely not load!
Make a back-up! Now!
Over exagerrating. It's not that complicated.
Here is some leather boots.
All these different things to look at, where do you start?
Well most of this is called "XML formatting".
You've seen this before in stages.xml
Well, now let's explain is a bit.
Forget the numbers, words, and other stuff. Let's focus on the basic stuff behind it.
There we go. Less intimidating now.
Same as before when we used [.code][./code] "code tags" to submit our support ticket.
XML just does it a bit different.
When you open a tag you use <>
When you close a tag you use /
If you open a tag on one line, <> but never close it / you can add additional parameters to it.
You can make very simple items such as a dirt floor into one whole line.
Notice that we open and close this item on the same line.
Equipable items usually turn into multiple lines.
Let's start adding information for the leather boots.
So now we have made the sprite id 2643 named to leather boots.
You'll notice we placed all the information regarding the item into the first part of the tag.
This is common for items.. since we will be adding more information to the item, such as weight and armor.
Notice again that the attribute keys open and close on the same line.
Because the item opens on the first line, and closes on the fifth line, all the lines inbetween become this items attributes.
Somewhere in the source code, someone has done all the hard work for us programming what each attribute key does.
All we have to do it edit the attribute keys. If we wanted to we could add more attribute keys to leather boots.
If we find a "life ring", which already has life and mana regeneration, we can simply copy those lines, and put them into our leather boots!
Of course there is many attribute keys you can add to items, and most of them explain themselves by their name itself.
Some attributes will have a simple value of "1".
If it's something like "showcharges" the value of "1" will mean true, and "0" will mean false.
Of course there's no point in having the line if it's false, so you should just remove that attribute.
But Xikini, when I looked for "life ring" I noticed there are two life rings! What gives?
There are special items in the game that "transform" and "decay" over time.
Rings are an easy example.
These are two different items.
2168 is a plain green ring.
2205 is a sparkly green ring.
When you equip a ring in Tibia it turns from a plain ring to a sparkly ring while equipped.
When it's "duration" runs down to "0" it will "decayTo" the item "0".
Because item "0" does not exist (and is probably programmed to delete the item entirely) the ring simply disappears, never to be seen again.
This is probably jumping forward a bit too much, but go to data/movements/movements.xml
Search for 2168 and 2205.
Normally the life ring is all put together in one area, but they might be moved around a little.
For every item in the game that can be equipped to a player, it will need to be "registered" into movements.xml
If the item is not registered to be equipped or deEquipped, then you cannot equip or deEquip that item.
The reason I brought this up, is because plain life rings have the special attribute
and sparkly life rings have this special attribute
When you equip a plain life ring, it will transform into a sparkly life ring.
Because that sparkly life ring transformed in your equipped slot, it is then equipped a second time, but this time registering as the sparkly ring.
When you deEquip the sparkly ring it transforms into the plain life ring again.
Because you are never actually deEquipping a plain life ring, you never need to register it into movements.xml
In either case, jumping back to items.xml, you can simply change some items, then close and restart your server to see the new stuff you added.
Since items.xml is such a large document, I would suggest changing 1-2 items at a time, then testing to make sure you didn't screw anything up.
Once you are done changing your item values and such, come back and we will continue with some basic LUA scripting.
I have not completed the tutorial, nor have I fully spell-checked it at this point in time.
I will be updating it over the next couple of weeks based on suggestions/criticism.
I will be reserving the first 3 posts for the tutorials, and the 4th post, in case I require the extra space. (which is likely.)
The 4th post will likely be comprised of copy-paste scripts for people to use,
and for the questions/answers section.
I realise that each post can have 25k letters.
I want to try to keep the letter count of each post to 15-20k, in case I need to add additional sections explaining stuff I have missed.
When I feel I have completed this guide to my expectations, I will remove this section.
Cheers to all,
Xikini
--------------------------------------------------------
The newb scripting guide; How to go from Newb to Noob in Ot's.
Hello there, my online name is Xikini. X-uh-keen-EE.
If you can't pronounce my name do not read further! I don't wanna teach you anything! (just kidding.)
Before you start to read this thread you will need to have set-up your server.
Some great tutorials to do this can be found here, here, here and here.
A fully set-up server, in my eyes, requires 4 things.
[1] You and others can create characters.
[2] You and others can log into your server.
[3] You have edited one of your characters into a god character.
[4] You know how to pronounce my name.
If you have completed the above steps, then you are ready to undertake your next challenge, Actually creating your server!
My goal at the end of this thread..
[1] You should know what each of the standard files do. [actions/movements/talkactions/et cetera]
[2] You should know how to create basic scripts.
[3] Teach you things at a very relaxed pace, while explaining everything as if you were explaining to your grandmother how to turn on their pc.
[3] You should feel like you are at least semi-floating on water instead of sinking rapidly into the abyss.
[4] And Finally, you should feel confident that you have gone from newb to noob.
Be warned. I'm notorious for walls of text. Before I even start writing this I'm writing this.
This will likely be a very long wall of text with a few code snippets, and maybe some images/gifs.
I will also like to warn, I am not an educated scripter.
I have never gone to school for any of this knowledge.
I have done everything through trial and error.
My scripting style, comments, any scripts I provide as lessons, are all probably garbage.
However! They are working garbage. Very functional, very working, garbage.
Most of the mods and elite scripters probably shake their head everytime I post help or scripts on this forum.
Basically my knowledge of scripting amounts to knowing how tables/loops/arrays work.
If you went to school for a scripting language, you were probably taught the above three things within your first two weeks of class.
I'm fairly smart. I know how to look around for stuff I don't know, and I'm not afraid to fail.
Nobody should be afraid to fail. Everytime you fail to do something you are gaining valuable knowledge.
However if you fail and give up, the only thing you are learning is how to give up when something proves to be difficult.
If you want to create an OT, I'm telling you right now that you will cry into your pillow three nights from now and wish the headaches would stop coming.
I'm totally kidding. I'm definitely not talking from experience. I definitely wasn't 14 years old.
I was a mature adult with the knowledge of everything. I opened my text document and a server was born within 3 weeks.
Alright, enough kidding around.
Let's start learning the basics.
The difference between your client version and your TFS version.
Your client version is your Tibia Clients Version.
Your client version simply tells you what sprites you will be able to use.
Popular client versions are 7.6, 8.0, 8.6, 9.6, 10.77.. et cetera.
Your TFS version is the version of your server.
Your TFS version will tell other people what kind of scripting style, and what available functions your server is allowed to use.
Popular New TFS versions are 1.1, 1.2.
Popular Old TFS versions are 0.3.6, 0.3.7, 0.4.
Anytime you create a thread on the forum, people will ask what TFS you are using.
If they don't know what TFS you are using, they may post code that is incompatable with your server.
I myself use TFS 0.3.7. All of my examples will be using this TFS, because this is what I am familiar with.
Although Old and New TFS versions are slightly different in coding style, the underlying file structure is fairly the same.
You can tell the difference between Old and New TFS by looking for these :::::.
New TFS will use these things in their code.
From my understanding it will call specific data, then use that data in a function.
Alright, next Topic.
What is the difference between the folders located in data/... , and what do they do?
[insert picture here]
[actions] This type of script is used when a player is interacting with any object. Ctrl + Click
[creaturescripts] This type of script is used when a creature [player/monster/npc] does something.
(When a player advances in skill, when a player looks at something, when a player logs in or out,
When a player takes damage, when a player targets a monster, when a player dies or kills something.
You can then script something to happen.)
[globalevents] This type of script effects many players or all players.
[items] This is where you edit your items and their values. (attack/defence/armor/names of items)
[lib] This holds useful information for scripting. You will probably use 1 or 2 files in here. The rest are UFO's.
[logs] This holds a lot of bug reports. Only useful file for newbs.. might be talkactions - for each player.
If you think a GM is spawning items for players/himself, you can check what talkactions they have used previously.
[monster] This is where you find all of your monsters. You can edit health/attack/defence/loot/et cetera
[movements] This type of script happens when a player walks or equips armor or moves an item onto a square.
[npc] Non-Player Character. This is where your npc files are located.
[raids] This is where you can set-up raids. Nobody fully understands how these work.
[spells] This is where you find spells. Their mana cost / who can use them / how they work.
[talkactions] God commands or player commands. /online or !online
[weapons] These are weapon scripts. They are kind of like spells, but for specific weapons.
[world] Your map. Your map goes here.
XML:
This contains different stuff. mounts/outfits/quests/stages/vocations are the most useful files in here.
And that's it for that.
Let's also quickly discuss some basic knowledge of how to post in Support/Requests.
Let's say you find an error, and after searching around for other people with the same issue, you can't find a solution. Alright, let's post in Support.
[URL]https://otland.net/forums/support.16/[/URL]
Here's a quick template.
Make a good Title. TFS 0.3.7: Lever to spawn monsters is not working
What TFS are you using? 0.3.7
What is the problem? My lever is not working when I click on it.
Post your script. [.code]script goes here[./code] (without the dots.)
Is there errors in your console? (console is the black window that shows up when you host your server)
Yeah I found this error. [.code]error goes here[./code] (without the dots.)
What have you tried to fix the problem? Post any script changes you tried.
Please help me senpai's.
If nobody helps you after 24 hours, type 'bump', and update with more script changes you have tried.
If you fixed your problem, it is acceptable to post before 24 hours with your solution, and then edit your title with the tag "Solved".
You always want to post your solution, so if someone else has the same problem, they can find your solution!
-- Rant Start
It is absolutely unacceptable to edit your first post to 'Blank' or 'Fixed my problem. Close thread//'.
You are apart of a community. Yes, we all have our own projects and ambitions, but if you don't support the community, the community will die.
Editing your main post to "sorry stupid question, solved." or anything similar is arrogant and greedy.
If you had this problem and found the solution, post your solution!
You will be helping someone who currently has the same problem, and could NOT find the solution!
-- end of rant.
If someone else helped you, or attempted to help you, LIKE their post, and post any errors you found with their solution.
If their reply solved your problem, LIKE their post, tell everyone your problem is solved, and edit your title to solved.
[Insert gif on how to edit title]
For requests is the same thing, except you ask people to make you stuff.
[URL]https://otland.net/forums/requests.132/[/URL]
Give them your TFS version.
Tell them what you want your script to do.
Hope and pray someone will make or help you make the script your wanting.
If nobody helps you after 24 hours, type 'bump'.
Remember, Forums are slow. Just be patient.
These people are taking time our of their lives to help you with your problem or request.
Be courteous, and don't lash out at people if their post does not help you.
Back into the basics.
Useful stuff to install.
Remere's Map Editor -- basically the most used map editor of all time.
[URL]https://remeresmapeditor.com/marklar.php[/URL]
Notepad++ -- This makes your eyes stop burning. Basically it will highlight special keywords.
[URL]https://notepad-plus-plus.org/download/v6.9.2.html[/URL]
Let's learn some basic server-wide stuff now.
First thing you want to do as a newb, Create a back-up file of anything you want to change.
If you screw-up something and your server won't load, just replace your edited file with your back-up file.
Back-up files save lives. I promise.
How to set-up experience, loot and skill rates, and free premium.
Very simple. in your config.lua search for
[premium] Until you find "freePremium" or something to that effect. Set to 'true'.
Then search for
[rates] Here you will find your rates.
Rates set as 1.0 = regular tibia rates. (or very close to.)
Anything above 1.0 is a multiplier. so 2.0 = 2x experience. (you can also do 0.5 to make half experience)
Skills/Magic/Loot/Experience is easily adjustable.
For experience you have the option of using "experienceStages".
If you change this to "true" you can further adjust how players gain experience.
Go to data/XML/stages.xml
I'm not sure what you'll see there, but here is a quick example of what you could do.
You get higher multipliers from starting levels, which eventually slow down and completely stop at level 500, as max level.
[code]<?xml version="1.0" encoding="UTF-8"?>
<stages>
<world id="0" multiplier="1">
<stage minlevel="1" maxlevel="99" multiplier="10"/>
<stage minlevel="100" maxlevel="199" multiplier="8"/>
<stage minlevel="200" maxlevel="299" multiplier="6"/>
<stage minlevel="300" maxlevel="399" multiplier="3"/>
<stage minlevel="400" maxlevel="499" multiplier="1"/>
<stage minlevel="500" multiplier="0"/>
</world>
</stages>
There is a ton of more stuff in config.lua you can change.
I'd suggest going through the entire document and fiddling around with stuff.
If you can't easily guess what something does.. I'd suggest not touching it.
Next basic thing would be editing items. data/items/items.xml
For many people this is their first large task.
You open up this document using notepad++ and the first thing you ask is; why is this file so long?!
Good question! It's long, because it holds the data of every single item in the game!
So if you mess something up in here, your server will definitely not load!
Make a back-up! Now!
Over exagerrating. It's not that complicated.
Here is some leather boots.
Code:
<item id="2643" name="leather boots">
<attribute key="weight" value="900" />
<attribute key="armor" value="1" />
<attribute key="slotType" value="feet" />
</item>
Well most of this is called "XML formatting".
You've seen this before in stages.xml
Well, now let's explain is a bit.
Forget the numbers, words, and other stuff. Let's focus on the basic stuff behind it.
Code:
<item>
</item>
Same as before when we used [.code][./code] "code tags" to submit our support ticket.
XML just does it a bit different.
When you open a tag you use <>
When you close a tag you use /
If you open a tag on one line, <> but never close it / you can add additional parameters to it.
You can make very simple items such as a dirt floor into one whole line.
Notice that we open and close this item on the same line.
Code:
<item id="103" name="dirt" />
Let's start adding information for the leather boots.
Code:
<item id="2643" name="leather boots">
</item>
You'll notice we placed all the information regarding the item into the first part of the tag.
This is common for items.. since we will be adding more information to the item, such as weight and armor.
Notice again that the attribute keys open and close on the same line.
Code:
<item id="2643" name="leather boots">
<attribute key="weight" value="900" />
<attribute key="armor" value="1" />
<attribute key="slotType" value="feet" />
</item>
Somewhere in the source code, someone has done all the hard work for us programming what each attribute key does.
All we have to do it edit the attribute keys. If we wanted to we could add more attribute keys to leather boots.
If we find a "life ring", which already has life and mana regeneration, we can simply copy those lines, and put them into our leather boots!
Code:
<item id="2643" name="leather boots">
<attribute key="weight" value="900" />
<attribute key="armor" value="1" />
<attribute key="healthGain" value="2" />
<attribute key="healthTicks" value="6000" />
<attribute key="manaGain" value="8" />
<attribute key="manaTicks" value="6000" />
<attribute key="slotType" value="feet" />
</item>
Some attributes will have a simple value of "1".
If it's something like "showcharges" the value of "1" will mean true, and "0" will mean false.
Of course there's no point in having the line if it's false, so you should just remove that attribute.
But Xikini, when I looked for "life ring" I noticed there are two life rings! What gives?
There are special items in the game that "transform" and "decay" over time.
Rings are an easy example.
Code:
<item id="2168" article="a" name="life ring">
<attribute key="weight" value="80" />
<attribute key="slotType" value="ring" />
<attribute key="transformEquipTo" value="2205" />
<attribute key="stopduration" value="1" />
<attribute key="showduration" value="1" />
</item>
<item id="2205" article="a" name="life ring (faster regeneration)">
<attribute key="weight" value="80" />
<attribute key="slotType" value="ring" />
<attribute key="decayTo" value="0" />
<attribute key="transformDeEquipTo" value="2168" />
<attribute key="duration" value="1200" />
<attribute key="healthGain" value="2" />
<attribute key="healthTicks" value="6000" />
<attribute key="manaGain" value="8" />
<attribute key="manaTicks" value="6000" />
<attribute key="showduration" value="1" />
<attribute key="showattributes" value="1" />
</item>
2168 is a plain green ring.
2205 is a sparkly green ring.
When you equip a ring in Tibia it turns from a plain ring to a sparkly ring while equipped.
When it's "duration" runs down to "0" it will "decayTo" the item "0".
Because item "0" does not exist (and is probably programmed to delete the item entirely) the ring simply disappears, never to be seen again.
This is probably jumping forward a bit too much, but go to data/movements/movements.xml
Search for 2168 and 2205.
Normally the life ring is all put together in one area, but they might be moved around a little.
Code:
<movevent type="Equip" itemid="2168" slot="ring" event="function" value="onEquipItem"/>
<movevent type="Equip" itemid="2205" slot="ring" event="function" value="onEquipItem"/>
<movevent type="DeEquip" itemid="2205" slot="ring" event="function" value="onDeEquipItem"/>
If the item is not registered to be equipped or deEquipped, then you cannot equip or deEquip that item.
The reason I brought this up, is because plain life rings have the special attribute
Code:
<attribute key="transformEquipTo" value="2205" />
Code:
<attribute key="transformDeEquipTo" value="2168" />
When you equip a plain life ring, it will transform into a sparkly life ring.
Because that sparkly life ring transformed in your equipped slot, it is then equipped a second time, but this time registering as the sparkly ring.
When you deEquip the sparkly ring it transforms into the plain life ring again.
Because you are never actually deEquipping a plain life ring, you never need to register it into movements.xml
In either case, jumping back to items.xml, you can simply change some items, then close and restart your server to see the new stuff you added.
Since items.xml is such a large document, I would suggest changing 1-2 items at a time, then testing to make sure you didn't screw anything up.
Once you are done changing your item values and such, come back and we will continue with some basic LUA scripting.
Last edited: