Lua Scripting Guide

gorgaboll

New Member
Joined
Apr 3, 2009
Messages
155
Best answers
0
Reaction score
1
very usefull man.
Btw is there any toturials on how to get the scripts into the server or something?? im a totally newbie in this area :D
 

Shinmaru

エロルアー Scripter!
Joined
Aug 20, 2007
Messages
1,988
Best answers
0
Reaction score
87
Location
Puerto Rico
To the MODs, I demand this to be sticky'd, this tutorial is very helpful for newbies at LUA scripting, so this deserves(even on its current stage) to be sticky.
Thank you!
 

dusieqq

mam hajsu jak lodu
Joined
Aug 15, 2010
Messages
1,782
Best answers
0
Reaction score
122
nice one, rep+ stick it!
 

SE000

New Member
Joined
Nov 19, 2010
Messages
43
Best answers
0
Reaction score
1
How do I know what "local" to use?

You used gain, I had no clue.

I would try with

local addCreatureMana = 750

or

local addMana = 750

So how do I know what to use in the "local"?
 

Fallen

Freelancer
Joined
Aug 21, 2009
Messages
3,713
Best answers
0
Reaction score
247
Location
Egypt
What is the right function do do this:
If you hit an egg with a weapon (on use), than the egg will be destroyed and a monster will spawn in the middle. It's a quest also :p.
doRemoveItem, doCreateMonster/doSummonCreature
 

Znote

<?php echo $title; ?>
Staff member
Global Moderator
Premium User
Joined
Feb 14, 2008
Messages
6,667
Best answers
202
Reaction score
1,375
Location
Norway, Oslo
Looking forward for the upcoming parts! <3<3<3

By the way: http://lualand.net/
Awesome site for 0.4 functions.

Your loops samples, they loop at the glimpse of an eye right? What about making 1 second exhaust between a loop, how to do so?
So instead of
execute script:
1,2,3,4,5,6,7,8,9,10 (in 0.001 seconds).
1 (1 sec)
2 (1 sec)
3 (1 sec)
and up to 10 with 1 sec interval. That way you can imitate a clock, a ticking bomb etc. :D
etc...


How do I know what "local" to use?

You used gain, I had no clue.

I would try with

local addCreatureMana = 750

or

local addMana = 750

So how do I know what to use in the "local"?
local SOMETHINGWEIRDNAMELOL
Is a local storage where you store a value. You can then use the value later.

Lua:
local LOLWTF = 200
--- local storage LOLWTF has value 200
--- you can make as many local storage as you want.
--- you can choose whatever name you want for your storage.
--- you can choose whatever value the storage have. 

if getCreatureMana(cid) < 100 then
--- If creature have LESS mana than 100 then:

doCreatureAddMana(cid, LOLWTF)
--- add mana, value is fetched from our local storage. 
--- If you want to choose another value, choose another storage or edit the value of LOLWTF

else
--- If you have more than 100 mana.

doPlayerSendCancel(cid, "Sorry this mana pool is only for people who are low on mana!")
end
 
Last edited:

Jerry White

New Member
Joined
Dec 27, 2010
Messages
5
Best answers
0
Reaction score
1
I red this tutorial, knew some basics before, but if I hadn't it would be really hard to understand anything, really. There are some mistakes, but only graphical. Last 3 parts were missing examples for me, I didn't get them. Thanks for the tutorial, anyways, helped a bit :).
 

Dexftw

Total Boss
Joined
Jan 30, 2011
Messages
317
Best answers
0
Reaction score
7
I found myself learning what was happening this tutorial helped me so much, had no idea how to do any scripting before this
 

Cypher

TwinkSoft Owner
Joined
Mar 21, 2011
Messages
826
Best answers
0
Reaction score
15
Continuee??
It helps a lot the new commers, rep+.
 

EdwardHl

Member
Joined
Jun 15, 2010
Messages
165
Best answers
0
Reaction score
9
Well im trying to learn Lua, but i need help, can someone made this script for me? then i can study it and made other by myself.
Script:
When a player step on a tile (x = 95, y = 117, z = 7) him will gain 10,000 exp.
And i need to know where to put the script.
 
Top