Hi everyone!
I am looking for someone who could do a tutorial about lua scripting.
I really need to learn to make my script shorter and some how better :/
If there are a tutorial like this one as I request, please could you link it for me?
Some examples which (I have hard to make short):
For the first example, I think u will understand what this script does after seeing through it.
This script transform a stone to a lever and add a stone below the lever. (this script isn't just for one lever, but 6 levers)
Another example I would like to have a tutorial is:
A script that creates/transform multiply objects by just using a lever.
These are the examples I can give you that you could use for the tutorial.
If you don't understand what I request please post a reply
Another thing that I would like to know (I know there is a tutorial somewhere), is about how to reset everything back again. Don't remember what it's called.
I think I am a bit unclear, so I will type an example:
As you see in my scripts abow they don't return to thier default pos. Like the bridge will always exist, untill someone use the lever again. and I would like to that the bridge should return to lava again after a while (like 2 minutes).
I thanks in advance! and ++rep for the one who could do this and(AGAIN ) I think this tutorial will help many to make their scripts shorter and more professional.
I am looking for someone who could do a tutorial about lua scripting.
I really need to learn to make my script shorter and some how better :/
If there are a tutorial like this one as I request, please could you link it for me?
Some examples which (I have hard to make short):
For the first example, I think u will understand what this script does after seeing through it.
This script transform a stone to a lever and add a stone below the lever. (this script isn't just for one lever, but 6 levers)
Code:
function onUse(cid, item, frompos, item2, topos)
--Lever 1--
stonepos1 = {x=10198, y=10272, z=9, stackpos=1}
stonepos11 = {x=10197, y=10231, z=9, stackpos=1}
--Lever 2--
stonepos2 = {x=10225, y=10272, z=9, stackpos=1}
stonepos21 = {x=10224, y=10272, z=9, stackpos=1}
--Lever 3--
stonepos3 = {x=10227, y=10211, z=9, stackpos=1}
stonepos31 ={x=10227, y=10212, z=9, stackpos=1}
stonepos4 = {x=10228, y=10211, z=9, stackpos=1}
stonepos41 ={x=10228, y=10210, z=9, stackpos=1}
--Lever 4--
stonepos5 = {x=10257, y=10231, z=9, stackpos=1}
stonepos51 = {x=10256, y=10231, z=9, stackpos=1}
--Lever 5--
stonepos6 = {x=10231, y=10272, z=9, stackpos=1}
stonepos61 = {x=10232, y=10272, z=9, stackpos=1}
--Lever 6--
stonepos7 = {x=10227, y=10230, z=9, stackpos=1}
stonepos71 = {x=10226, y=10229, z=9, stackpos=1}
stonepos8 = {x=10228, y=10230, z=9, stackpos=1}
stonepos81 = {x=10229, y=10229, z=9, stackpos=1}
--Gethingfrom stone1--
stone1 = getThingfromPos(stonepos1)
stone11 = getThingfromPos(stonepos11)
--Gethingfrom stone2--
stone2 = getThingfromPos(stonepos2)
stone21 = getThingfromPos(stonepos21)
--Gethingfrom stone3--
stone3 = getThingfromPos(stonepos3)
stone31 = getThingfromPos(stonepos31)
stone4 = getThingfromPos(stonepos4)
stone41 = getThingfromPos(stonepos41)
--Gethingfrom stone4--
stone5 = getThingfromPos(stonepos5)
stone51 = getThingfromPos(stonepos51)
--Gethingfrom stone5--
stone6 = getThingfromPos(stonepos6)
stone61 = getThingfromPos(stonepos61)
--Gethingfrom stone6--
stone7 = getThingfromPos(stonepos7)
stone71 = getThingfromPos(stonepos71)
stone8 = getThingfromPos(stonepos8)
stone81 = getThingfromPos(stonepos81)
-- Do not config unless you have a diffrent item.uid--
--Stone 1--
if item.itemid == 1945 and item.uid == 1008 then
doTransformItem(1009, 1945)
doCreateItem(1304, 1, stonepos11)
doTransformItem(item.uid, 1946)
elseif item.itemid == 1946 and item.uid == 1008 then
doTransformitem(1009, 1304)
doRemoveItem(stone11.uid,1304)
doTransformItem(item.uid, 1945)
--Stone 1 end--
--Stone 2--
elseif item.itemid == 1945 and item.uid == 1009 then
doTransformItem(1010 ,1945)
doCreateItem(1304, 1, stonepos21)
doTransformItem(item.uid, 1946)
elseif item.itemid == 1946 and item.uid == 1009 then
doTransformItem(1010, 1304)
doRemoveItem(stone21.uid, 1304)
doTransformItem(item.uid, 1945)
--Stone 2 end--
--Stone 3--
elseif item.itemid == 1945 and item.uid == 1010 then
doRemoveItem(stone3.uid,1304)
doRemoveItem(stone4.uid,1304)
doCreateItem(1304, 1, stonepos31)
doCreateItem(1304, 1, stonepos41)
doTransformItem(item.uid, 1946)
elseif item.itemid == 1946 and item.uid == 1010 then
doCreateItem(1304, 1, stonepos3)
doCreateItem(1304, 1, stonepos4)
doRemoveItem(stone31.uid, 1304)
doRemoveItem(stone41.uid, 1304)
doTransformItem(item.uid, 1945)
--Stone 3 end--
--Stone 4--
elseif item.itemid == 1945 and item.uid == 1011 then
doTransformItem(1012, 1945)
doCreateItem(1304, 1, stonepos51)
doTransformItem(item.uid, 1946)
elseif item.itemid == 1946 and item.uid == 1011 then
doTransformItem(1012, 1304)
doRemoveItem(stone51.uid, 1304)
doTransformItem(item.uid, 1945)
--Stone 4 End --
--Stone 5--
elseif item.itemid == 1945 and item.uid == 1012 then
doTransformItem(1013, 1945)
doCreateItem(1304, 1, stonepos61)
doTransformItem(item.uid, 1946)
elseif item.itemid == 1946 and item.uid == 1012 then
doTransformItem(1013, 1304)
doRemoveItem(stone61.uid, 1304)
doTransformItem(item.uid, 1945)
--Stone 5 End--
--Stone 6--
elseif item.itemid == 1945 and item.uid == 1013 then
doRemoveItem(stone7.uid,1304)
doRemoveItem(stone8.uid,1304)
doCreateItem(1304, 1, stonepos71)
doCreateItem(1304, 1, stonepos81)
doTransformItem(item.uid, 1946)
elseif item.itemid == 1946 and item.uid == 1013 then
doCreateItem(1304, 1, stonepos7)
doCreateItem(1304, 1, stonepos8)
doRemoveItem(stone71.uid, 1304)
doRemoveItem(stone81.uid, 1304)
doTransformItem(item.uid, 1945)
end
--Stone 6 End--
return 1
end
Another example I would like to have a tutorial is:
A script that creates/transform multiply objects by just using a lever.
Code:
function onUse(cid, item, frompos, item2, topos)
-- Lever 1 (stone + Bridge)
stone1n = {x=9841, y=9875, z=11}
-- Bridge --
b1 = {x=9848, y=9849, z=11}
b2 = {x=9848, y=9849, z=11}
b3 = {x=9848, y=9849, z=11}
b4 = {x=9848, y=9849, z=11}
b5 = {x=9848, y=9849, z=11}
b6 = {x=9848, y=9849, z=11}
-- End of config
----------------------------------------------------------------------------
-- Lever 1 --
if item.itemid == 1945 and item.uid == 1015 then
--Stone1 --
doCreateItem(1304, 1, stone1n)
doTransformItem(item.uid, 1946)
doTransformItem(1016, 1945)
--Stone1 end--
--Bridge--
doRemoveItem(getTileItemById(b1, 598).uid)
doRemoveItem(getTileItemById(b2, 598).uid)
doRemoveItem(getTileItemById(b3, 598).uid)
doRemoveItem(getTileItemById(b4, 598).uid)
doRemoveItem(getTileItemById(b5, 598).uid)
doRemoveItem(getTileItemById(b6, 598).uid)
doCreateItem(1284, 1, b1)
doCreateItem(1284, 1, b2)
doCreateItem(1284, 1, b3)
doCreateItem(1284, 1, b4)
doCreateItem(1284, 1, b5)
doCreateItem(1284, 1, b6)
--Bridge end--
elseif item.itemid == 1945 and item.uid == 1015 then
doRemoveItem(getTileItemById(stone1n, 1304).uid)
doTransformItem(item.uid, 1945)
doTransformItem(1016, 1304)
--Bridge--
doRemoveItem(getTileItemById(b1, 1284).uid)
doRemoveItem(getTileItemById(b2, 1284).uid)
doRemoveItem(getTileItemById(b3, 1284).uid)
doRemoveItem(getTileItemById(b4, 1284).uid)
doRemoveItem(getTileItemById(b5, 1284).uid)
doRemoveItem(getTileItemById(b6, 1284).uid)
doCreateItem(598, 1, b1)
doCreateItem(598, 1, b2)
doCreateItem(598, 1, b3)
doCreateItem(598, 1, b4)
doCreateItem(598, 1, b5)
doCreateItem(598, 1, b6)
end
--Bridge end--
--Lever 1 End--
return 1
end
These are the examples I can give you that you could use for the tutorial.
If you don't understand what I request please post a reply
Another thing that I would like to know (I know there is a tutorial somewhere), is about how to reset everything back again. Don't remember what it's called.
I think I am a bit unclear, so I will type an example:
As you see in my scripts abow they don't return to thier default pos. Like the bridge will always exist, untill someone use the lever again. and I would like to that the bridge should return to lava again after a while (like 2 minutes).
I thanks in advance! and ++rep for the one who could do this and(AGAIN ) I think this tutorial will help many to make their scripts shorter and more professional.