[LUA] understanding lua - Gamerz Needs - For All Your Gaming Needs!
 

[LUA] understanding lua

Tibia Discuss, [LUA] understanding lua at Game Discussion & Downloads forum; ithink we should go right to the point... 1. so... first you have to decide what kind of script you ...


Go Back   Gamerz Needs - For All Your Gaming Needs! > All Other Games listed here!! > Game Discussion & Downloads > Tibia
Forgot Password? | Sign Up!


Reply
 
Bookmark this Thread Tools Display Modes
  #1  
Old 08-13-2008, 05:49 PM
Sagatori's Avatar
Registered Users +
This user has no status.
 
----
 
Last Online: 09-07-2010 04:51 PM
Join Date: Feb 2007
Age: 18
Posts: 471
Post Thanks / Like
Tokens: 0 - [Spend]
Gil: 0
Points: 41,271.00
[LUA] understanding lua

ithink we should go right to the point...

1.

so...
first you have to
decide what kind of script you are going to make. otherwise you will not come anywhere ^.-

the options is to make a movement a creature a talk action or an action script.

-action script-
action scripts are mostly used for quests and as the name says,
the script is going to make an action. its going to do something when you have used that item (or something else). the action script will not do anything before you have made it to do something. for example: if you right click on a switch to use it then the action will be executed. else if you don't use it, then nothing will happen. its as simple as that.

-movement script-
movement scripts are mostly used for making an action when someone or something "moves". so in this script you don't have to use anything. as soon as you walk on something or make a "move" then the action will be executed.
its the opposite of the action script, the action script must be used to be executed, the movement script can't be executed by using it.

-creature script-
creature script is the script for like your first visit on a server or such things. so you have to make a creature script if you want to modify the first item that a character will start with. here you can modify many things that is executed by a character while it does something more different then using and such, this one cant be used or on-moved. you cant see this one and you can't touch this one.
this can also for example send you a message when you kill someone or when you die. and as i said you can't technically (touch) death ^.-

-talk action script-
and again as the name says... the action executes when you talk, cannot be used, on moved or seen. just talked. so you can make something bad happen to the person who swear because swearing is talking.



2.

the starting on all of these scripts are different:

action scripts starts like this:
Code:

Quote:
function onUse(cid, item, frompos, item2, topos)
movement scripts start like this:
Code:

Quote:
function onStepIn(cid, item, pos)
or like this:
Code:

Quote:
function onStepOut(cid, item, pos)
creature script starts is a little special, it depends on what will execute the action, if you want the action to be executed when someone dies then:
Code:

Quote:
function onDie(cid, corpse)
or when someone log in:
Code:

function onLogin(cid)

talk action script start:
Code:

Quote:
function onSay(cid, words, param)
then there is more things that must be added to complete the script such as pointing out the item ids, action or unique ids that can execute the action, if you make an action script that you want to be executed when you use a lever then you have to point out what item id, action id or unique id the lever has, otherwise the game will give you an error saying that it don't know what can execute the action.

tip: don't make the action be executed just with a item id, thats just stupid, because that will make all the item that have the same item id like this do the same thing, so if you make 2 quests, one annihilator one pits of inferno but you write so that the action gets executed by the item id of a lever and both these quests are using the the same lever, then it can happen terrible things XD. so i recommend that you use the unique id, you do it like this:
first you have to find a unique id that is not used by anything else, then you write like this in your action script:
Code:

Quote:
if item.uid == 1234 then
then you have to write the unique id 1234 on the item that you want to execute the action, first you open the mapeditor and place that item on the map then you open its properities and write 1234

(1234 is an example).



3.

now when you have decided what kind of script you want to make... then you have to know what functions you are able to use. i think it will be hard to remember exactly all the functions that the lua have for tibia, but there is another option:

this file exists in the most TFS servers, in the "doc" folder.
lua functions.txt

the file contains many use full functions that can be used while scripting in lua. it also explains the "get" functions. the get functions are used to get information from the game to do an action to the information it gets, for example the promotion NPC uses "getPlayerVocation(cid)" to gather information about what vocation id a player has, and then you use the "do" function to make the action, you will be using doPlayerSetVocation(cid,voc). It will make the action to set the players vocation to another vocation id. so instead of the "voc" you write the vocation id of the vocation that you want the npc to promote to. but that just sounds bad, this will just make so that if everyone with different vocation ids talk s to him then he will however change the vocation id of them to the vocation id you have written instead of the "voc". so you have to use the "if" function, it will give the game more options, the "if" function will make the game think like "if the player have vocation id 3 then do something, else do something else". you can make as many if that you want. if can be used before all functions that you see in the document that i have attached, it can be used like "if getPlayerSex" or just "if doPlayerRemoveMoney".

if you make a little more advanced selling npc then you will need the if function because the npc must remove the money from the player when the npc gives the player something. none wants their npc to give free item to everyone XD. so you have to use the "if doPlayerRemoveMoney" function, but you have to learn the game what "money" is, of course a computer can't know everything by it self. so you have to write this at the beginning of the script:

Code:
Quote:
player_gold = getPlayerItemCount(cid,2148)
player_plat = getPlayerItemCount(cid,2152)*100
player_crys = getPlayerItemCount(cid,2160)*10000
player_money = player_gold + player_plat + player_crys
this will teach the computer how the cash system works.
so now the npc will know what item id the cash have and that he can take 2 platinum instead of 200 gp too, otherwise if he don't know, he/she will not take anything else then the currency id that you made him to take.

so you might now try to make your own script and mix with it a little till you learn the thing you want to learn.

i strongly recommend that you use a "template" because then you dont have to write things that you MUST have in the script many times(like the start of a script).
just copy another script of the type you are going to write in and delete the lines you don't need and write your own.

-sorry i wrote no capital letters at the start of all the sentences but it just makes the work harder ^^-

i hope you learned something!
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Main Navigation
Home
Forums
Games
News
Top Games
Cheats
Articles
Reviews
User Control Panel
Advertising
RSS Feed
Affiliates
Anime Desire
Webhosting
2Moons
Adventure Quest
AirRivals
America's Army
Anarchy Online
Archlord
Audition
Battlefield Series
Cabal Online
Call Of Duty Series
Combat Arms
Conquer Online
Counter Strike
Cross Fire
Day of Defeat
Deicide Online
Diablo Series
Doom Series
Drift City
Enemy Territory
Eudemons Online
Final Fantasy
Flyff (Fly For Fun)
Game Discussion & Downloads
Ghost Online
Granado Espada
Grand Theft Auto Series
Guild Wars
Gunbound
Gunz Online
Habbo Hotel
Half-Life 2
Hero Online
Knights Online
Maple Story
Medal of Honor
MU Online
Neopets
Pangya
Quake Series
Ragnarok Online
Rakion
Rappelz
Red Orchestra
Rose Online
Runescape
Scions of Fate
Silkroad Online
Sims Series
Soldier Front
Starcraft
Tales of Pirates
Tibia
The Ship
Trickster Online
TS Online
Unreal Tournament
War Rock
WolfTeam
Wonderking
World of Warcraft & Series


All times are GMT -8. The time now is 09:43 AM.

vBulletin Optimisation by vB Optimise.