president vankk
Web Developer & AuraOT Owner
- Joined
- Jul 10, 2009
- Messages
- 5,719
- Solutions
- 9
- Reaction score
- 339
I don't know if this is the correct section or not, but I would like some tutorials to learn Lua.. Anyone have anything? 
Google.
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Oliver" floorchange="0" walkinterval="0">
<health now="150" max="150"/>
<look type="128" head="77" body="65" legs="59" feet="116" addons="1"/>
<interaction range="3" idletime="30">
<interact keywords="hi" focus="1">
<!--These are the keywords will trigger this interaction-->
<keywords>hello</keywords>
<keywords>greet</keywords>
<keywords>hei</keywords>
<response>
<action name="script">
selfSay('Hello there, I {sell} and {buy} wheat and flour in packs. (1 pack = 5 units).', cid)
</action>
</response>
</interact>
<!-- Manual buying shop system -->
<interact keywords="buy">
<keywords>shop</keywords>
<response>
<action name="script">
local wheat = getStorage(50020)
local flour = getStorage(50021)
local wheat1 = (wheat / 5)
local flour1 = (flour / 5)
if wheat == -1 then
doSetStorage(50020, 25)
end
if flour == -1 then
doSetStorage(50021, 25)
end
selfSay("I have "..math.floor(wheat1).." {wheat} packs available (40gp each pack) and "..math.floor(flour1).." {flour} packs available (75gp each pack).", cid)
</action>
<action name="topic" value="2"/>
</response>
</interact>
<interact keywords="wheat" topic="2">
<keywords>crop</keywords>
<response>
<action name="script">
local wheat = getStorage(50020)
if wheat > 4 then
if doPlayerRemoveMoney(cid, 40) == true then
doPlayerAddItem(cid, 2694,5)
doSetStorage(50020, getStorage(50020)-5)
selfSay('Thank you! Here is your wheat!', cid)
else
selfSay('Sorry, this pack costs 40gp. ', cid)
end
else
selfSay('Sorry, I am out of wheat. I need to refill my supplies.', cid)
end
</action>
</response>
</interact>
<interact keywords="flour" topic="2">
<keywords>mel</keywords>
<response>
<action name="script">
local flour = getStorage(50021)
if flour > 4 then
if doPlayerRemoveMoney(cid, 75) == true then
doPlayerAddItem(cid, 2692,5)
doSetStorage(50021, getStorage(50021)-5)
selfSay('Thank you! Here is your flour!', cid)
else
selfSay('Sorry, this pack costs 75gp. ', cid)
end
else
selfSay('Sorry, I am out of flour. I need to refill my supplies.', cid)
end
</action>
</response>
</interact>
<!-- End normal trade system -->
<!-- Manual selling shop system -->
<interact keywords="sell">
<response>
<action name="script">
local wheat = getStorage(50020)
local flour = getStorage(50021)
if flour > 20 and wheat > 20 then
selfSay("All my stocks are full. Perhaps later.", cid)
else
if flour > 20 then
selfSay("I would like to buy some {wheat} (30gp). I might be interested in buying flour later.", cid)
else
if wheat > 20 then
selfSay("I would like to buy some {flour} (45gp). I might be interested in buying wheat later.", cid)
else
selfSay("I would like to buy {flour} (45gp) and {wheat} (30gp)!", cid)
end
end
end
</action>
<action name="topic" value="3"/>
</response>
</interact>
<interact keywords="wheat" topic="3">
<keywords>crop</keywords>
<response>
<action name="script">
local wheat = getStorage(50020)
if wheat > 20 then
selfSay("My wheat stock is full, perhaps I will buy some later.", cid)
else
if doPlayerRemoveItem(cid, 2694,5) == true then
doPlayerAddMoney(cid, 30)
doSetStorage(50020, getStorage(50020)+5)
selfSay('Thanks you, here is your 30gp. Please come back again.', cid)
else
selfSay('Looks like you dont have enough wheat on you. I trade things in a pack of 5x units.', cid)
end
end
</action>
</response>
</interact>
<interact keywords="flour" topic="3">
<keywords>mel</keywords>
<response>
<action name="script">
local flour = getStorage(50021)
if flour > 20 then
selfSay("My flour stock is full, perhaps I will buy some later.", cid)
else
if doPlayerRemoveItem(cid, 2692,5) == true then
doPlayerAddMoney(cid, 45)
doSetStorage(50021, getStorage(50021)+5)
selfSay('Thanks you, here is your 45gp. Please come back again.', cid)
else
selfSay('Looks like you dont have enough flour on you. I trade things in a pack of 5x units.', cid)
end
end
</action>
</response>
</interact>
<!-- End normal selling trade system -->
<interact keywords="bye" focus="0">
<keywords>farewell</keywords>
<response>
<action name="script">
selfSay('Farewell! Good luck to you!', cid)
</action>
</response>
</interact>
</interaction>
</npc>