Does anybody know lua code?



Does anybody know LUA coding?

If so, reply and use the poll.

If not, do the same.

  • Yes, I do know lua. :smile:

  • No, sorry. :pensive:


Because I need help with something I'm making for



I don't know what it is but I'd love it if you told me!


Are you planning to transfer something you made in Lua into a Hopscotch project? Like @JumpyJose said, it would be great if you could tell us :smiley:


@JumpyJose Lua is a type of coding. Like html, javascript, python, and the one with the bad name.

@t1_hopscotch This might sound derpy, but I plan on making a lua script for my open url block topic. We are thinking about having it share other projects only, like If someone said yes i know, here's what i'd tell them:

    Great! So this is the Lua I typed in:

    function myFunction()

    donut = {"gorwsgt","xcw2nfyuz"}
    print ("")
    print (donut)


So where did I mess up?

yeah i know it stinks. Sorry!

no seriously sorry :pensive: :cold_sweat: :grin:


Also I'm pretty sure @BuildASnowman knows Lua.


So: A few pointers on your code.
You are defining your function right, but you are forgetting to call it. When you define a function (It's like an ability in hopscotch) you have to call it, so after your code put:


You also are defining a table called donut which you never reference, but that doesn't mess up your code, just is some extra work for the compiler.

When you do


It will print some weird thing like:

table: 0x34t5

Which is the memory adres of the table. If you want to print the things in the table, use a for loop and cycle through each of the elements like so:

for k,v in pairs(donut) do

And then the main thing you are working on, your first print:

print ("")

Will just print out the text

Lua doesn't actually have a built in ur/website api, which means you can't use lua for what you are doing. You can, however, use python. A tutorial for urls with python would be a bit too long for here, so what I will do is edit your open url post with a script for it.


So should I put:

function myFunction()
donut = {"gorwsgt","xcw2nfyuz"}
print ("")
for k,v in pairs(donut) do

By the way when I try to call that global table an error occurs :confused: @BuildASnowman Please reply.


What I'm saying is that you can't actually use lua for this, because you can't connect to urls using lua.


Just wondering, what does Lua specialize in? As in, HTML is text such as websites, JavaScript is usually for design, etc.


@BuildASnowman I'm not trying to connect to a website, I'm just trying to make it display the text, or



Oh! In that case just use this code:


You don't need functions or anything like that


No, I mean it could say that, but it could possibly also be


Sorry for the late response!
So, what you are saying is you want it to sometimes say and sometimes say


Yes! And no worries on the late response :blush:


The best way is using "tables", which is the name for lists in lua.
The way you define a table in lua is this:

list = {"item1,"item2"}

And then when you want to reference an item in that table:


Would print out the second element in the list.
So, first we define a table of the things we want it to say:


Then all we have to do is get a random item in this table.
Well, to do this we need something called math.random. It allows us to generate random numbers.

print(math.random(1,10)) would print a random number between one and ten. But what will our range be for this?
There is an operator in lua which is "#". It just means length, so #urls would be how many items are in the table.
So, this code:


Would print a random number between one and the amount of items in the table urls.
Then, we just have to actually put it in a reference:


And that will give us a random item in the list and print it out!
So our final code for that:



Thanks @BuildASnowman!! Do I need anything before


I'm learning LUA so I can mod Unitale! :D

@BuildASnowman, I need to install LUA. Did you use the .gz file?


Installing Lua is harder than it seems xD. Windows, mac, or something else?



I saw two files that both install it; LuaDist and the .gz of the current version. What do I do now :stuck_out_tongue_winking_eye:


You downloaded the binary of it, and compiling a binary in windows is gonna be very difficult (Believe me: 6 years of programming experience and I gave up on it after 7 hours)
I would say your best bet is to use LuaRocks. Here is a link to download:

And here is a link to installation instructions for windows:

If you have any questions I'll try my best to help out, although the journey ahead of you depends a lot on luck, patience, and deciphering weird, vague messages (That's a good metaphor for life, too xD)