• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Scripting Guide

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
 
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!
 
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"?
 
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
 
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:
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 :).
 
I found myself learning what was happening this tutorial helped me so much, had no idea how to do any scripting before this
 
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.
 
Back
Top