print ("Hello, World!")Ressources = { { id = 2553, qtt = 1, lot = 1, prix = 1000000}, -- Gros Boulet { id = 2551, qtt = 1, lot = 1, prix = 1000000}, -- Oreille de Foufayteur { id = 429, qtt = 2, lot = 1, prix = 1000000}, -- Misericorde du Chafer d'Elite { id = 399, qtt = 1, lot = 1, prix = 1000000}, -- Huile de sésame { id = 1002, qtt = 1, lot = 1, prix = 1000000}, -- Tronc de Kokoko { id = 8759, qtt = 1, lot = 1, prix = 1000000}, -- Coffre Maudit du Flib { id = 2618, qtt = 1, lot = 1, prix = 1000000}, -- Kokopaille { id = 2617, qtt = 1, lot = 1, prix = 1000000}, -- Tranche de Nodkoko } function PnjOtomai() if map:currentMapId() == 95420420 then npc:npc(925, 3) npc:reply(-1) global:delay(5000) npc:reply(-1) global:delay(5000) npc:reply(-1) npc:npc(925, 3) npc:reply(-1) global:delay(5000) global:leaveDialog() global:delay(5000) npc:npc(925, 3) npc:reply(-1) elseif map:currentMapId() == 26217472 then npc:npc(925, 3) npc:reply(-1) elseif map:currentMapId() == 153090 then npc:npc(925, 3) npc:reply(-1) global:delay(5000) npc:reply(-1) global:delay(5000) npc:reply(-1) global:delay(5000) npc:npc(925, 3) npc:reply(-1) global:delay(5000) npc:reply(-1) global:delay(5000) npc:reply(-1) global:delay(5000) global:leaveDialog() global:delay(15000) npc:npc(925, 3) npc:reply(-1) end end function Achats(List) npc:npc(219,5) for i, v in ipairs(List) do v.prix = sale:getPriceItem(v.id, v.lot) end global:leaveDialog() PodsLibre = inventory:podsMax()-inventory:pods() if PodsLibre > 508 then npc:npc(219,6) for i, v in ipairs(List) do while inventory:itemCount(v.id) < v.qtt do if character:kamas() > v.prix then sale:buyItem(v.id, 1, v.prix*2) else global:printError("[ERREUR] Vous ne disposez pas des Kamas necessaires pour acheter les ressources de la quête de l'île d'Otomaï") global:printError("Veuillez obtenir les kamas necessaires et relancer le script depuis l'hdv ressource de Brakmar") global:finishScript() end end end else global:printError("[ERREUR] Vous ne disposez pas des Pods necessaires pour acheter les ressources necessaires à la quête de l'île d'Otomaï") global:printError("Veuillez supprimer des objets et relancer le script depuis l'hdv ressource de Brakmar") global:finishScript() end global:leaveDialog() for i, v in ipairs(List) do if inventory:itemCount(v.id) >= v.qtt then global:printSuccess("x"..v.qtt.." "..inventory:itemNameId(v.id).." acheté avec succès") else global:printError("[ERREUR] L'achat de x"..v.qtt.." "..inventory:itemNameId(v.id).." ne s'est pas deroulé correctement") global:printError("Veuillez relancer le script depuis l'hdv ressource de Brakmar") global:finishScript() end end end function HDV_Ressources() Achats(Ressources) end function move () if inventory:itemCount(429) > 1 then return Etape2 else return Etape1 end end function Etape1() return { { map = map:currentMap(), path = "havenbag" }, { map = "162791424", path = "zaap(212861955)"}, { map = "162793472", path = "zaap(212861955)"}, { map = "212861955", path = "zaapi(212861952)"}, { map = "212861952", custom = HDV_Ressources, path = "havenbag"}, } end function Etape2() return { { { map = "162791424", path = "zaap(95422468)"}, { map = "162793472", path = "zaap(95422468)"}, { map = "95422468", path = "zaapi(90703364)"}, { map = "13,29", path = "right"}, { map = "14,29", path = "top"}, { map = "14,28", path = "right"}, { map = "95420420", custom = PnjOtomai}, { map = "26214400", forcefight = true}, { map = "26215424", forcefight = true}, { map = "26216448", forcefight = true}, { map = "26217472", custom = PnjOtomai}, { map = "153090", custom = PnjOtomai}, { map = "-44,21", path = "left"}, { map = "-45,21", path = "top"}, { map = "-45,20", path = "top"}, { map = "-45,19", path = "top"}, { map = "-45,18", path = "left"}, { map = "154642", custom = SaveZaap, path = "left"}, } end
Write, Run & Share Lua code online using OneCompiler's Lua online compiler for free. It's one of the robust, feature-rich online compilers for Lua language, running the latest Lua version 5.4. Getting started with the OneCompiler's Lua editor is easy and fast. The editor shows sample boilerplate code when you choose language as Lua and start coding.
OneCompiler's Lua online editor supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample Lua program which takes name as input and prints hello message with your name.
name = io.read("*a")
print ("Hello ", name)
Lua is a light weight embeddable scripting language which is built on top of C. It is used in almost all kind of applications like games, web applications, mobile applications, image processing etc. It's a very powerful, fast, easy to learn, open-source scripting language.
-- global variables
a = 10
-- local variables
local x = 30
Value Type | Description |
---|---|
number | Represents numbers |
string | Represents text |
nil | Differentiates values whether it has data or not |
boolean | Value can be either true or false |
function | Represents a sub-routine |
userdata | Represents arbitary C data |
thread | Represents independent threads of execution. |
table | Can hold any value except nil |
While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.
while(condition)
do
--code
end
Repeat-Until is also used to iterate a set of statements based on a condition. It is very similar to Do-While, it is mostly used when you need to execute the statements atleast once.
repeat
--code
until( condition )
For loop is used to iterate a set of statements based on a condition.
for init,max/min value, increment
do
--code
end
Function is a sub-routine which contains set of statements. Usually functions are written when multiple calls are required to same set of statements which increase re-usuability and modularity.
optional_function_scope function function_name( argument1, argument2, argument3........, argumentn)
--code
return params with comma seperated
end