Heres the code:
Code: Select all
player = "CoolJar10"
if player == "stix"
then
print("Hiya Stix :P")
end
if player == "CoolJar10"
then
print("uh-oh...")
end
Code: Select all
player = "CoolJar10"
if player == "stix"
then
print("Hiya Stix :P")
end
if player == "CoolJar10"
then
print("uh-oh...")
end
Code: Select all
if player = "stix"
I`ve noticed some errors in your code. It should be rewritten so:Stix wrote:Hi! i have just written some simple code from scratch when i realized: how am i gonna test it? So got any ideas?
Heres the code:(player can be changed manually to CoolJar10 to get different msg)Code: Select all
player = "stix" if player = "stix" then print("Hiya Stix :P") if player = "CoolJar10" then print("uh-oh...")
Code: Select all
mes1 = "Hiya Stix :P"
mes2 = "uh-oh..."
if player == "stix" then
print(mes1)
elseif player == "CoolJar10" then
print(mes2)
Oh god, please no. At least use proper indentation.Andrey01 wrote:I`ve noticed some errors in your code. It should be rewritten so:Stix wrote:Hi! i have just written some simple code from scratch when i realized: how am i gonna test it? So got any ideas?
Heres the code:(player can be changed manually to CoolJar10 to get different msg)Code: Select all
player = "stix" if player = "stix" then print("Hiya Stix :P") if player = "CoolJar10" then print("uh-oh...")
Code: Select all
mes1 = "Hiya Stix :P" mes2 = "uh-oh..." if player == "stix" then print(mes1) elseif player == "CoolJar10" then print(mes2)
ideone is another online-ide that supports lua and many other programming-languages.sofar wrote:lua sandbox can be used in a webbrowser from https://www.lua.org/cgi-bin/demo
I prefer repl.it (not ad infested): https://repl.it/languages/luahajo wrote:ideone is another online-ide that supports lua and many other programming-languages.sofar wrote:lua sandbox can be used in a webbrowser from https://www.lua.org/cgi-bin/demo
*ifconfig; i know how to find ip's :PGreenDimond wrote:Open Minetest, select a world with your mod enabled, tick "host server" and log in as "stix". Open a terminal and type "ipconfig" (windows I think) or "ifconfic" (Linux). Find your IP (should be something like 192.168.1.###). Open a second client and connect to a server with the name "CoolJar10" using your IP as the address and leave the port at 30000.
Whoops. #TyposFTW.Stix wrote: *ifconfig
What`s an indentation?Linuxdirk wrote:Oh god, please no. At least use proper indentation.Andrey01 wrote:I`ve noticed some errors in your code. It should be rewritten so:Stix wrote:Hi! i have just written some simple code from scratch when i realized: how am i gonna test it? So got any ideas?
Heres the code:(player can be changed manually to CoolJar10 to get different msg)Code: Select all
player = "stix" if player = "stix" then print("Hiya Stix :P") if player = "CoolJar10" then print("uh-oh...")
Code: Select all
mes1 = "Hiya Stix :P" mes2 = "uh-oh..." if player == "stix" then print(mes1) elseif player == "CoolJar10" then print(mes2)
It's about treating code with care and avoiding mistakes by "working cleanly".Andrey01 wrote:What`s an indentation?
Code: Select all
if bar ==3 then print ("banana")
end
Code: Select all
if bar == 3 then
print("banana")
end
That is i wrote the code wrong? Really are indentations so important? I looked through many times a code that people had written and i saw they wrote as me now without those indentations.sofar wrote:It's about treating code with care and avoiding mistakes by "working cleanly".Andrey01 wrote:What`s an indentation?
You don't write:
Instead, you write:Code: Select all
if bar ==3 then print ("banana") end
Code: Select all
if bar == 3 then print("banana") end
how is my code wrong? either way should work.Andrey01 wrote:I`ve noticed some errors in your code. It should be rewritten so:Stix wrote:Hi! i have just written some simple code from scratch when i realized: how am i gonna test it? So got any ideas?
Heres the code:(player can be changed manually to CoolJar10 to get different msg)Code: Select all
player = "stix" if player = "stix" then print("Hiya Stix :P") if player = "CoolJar10" then print("uh-oh...")
Code: Select all
mes1 = "Hiya Stix :P" mes2 = "uh-oh..." if player == "stix" then print(mes1) elseif player == "CoolJar10" then print(mes2)
You made an error in that line "if player = "stix"". Here you are trying to set a value for player variable. But you need to compare value of variable player and "stix". Here is your error.Stix wrote:how is my code wrong? either way should work.Andrey01 wrote:I`ve noticed some errors in your code. It should be rewritten so:Stix wrote:Hi! i have just written some simple code from scratch when i realized: how am i gonna test it? So got any ideas?
Heres the code:(player can be changed manually to CoolJar10 to get different msg)Code: Select all
player = "stix" if player = "stix" then print("Hiya Stix :P") if player = "CoolJar10" then print("uh-oh...")
Code: Select all
mes1 = "Hiya Stix :P" mes2 = "uh-oh..." if player == "stix" then print(mes1) elseif player == "CoolJar10" then print(mes2)
Since Lua does not use indentation as syntax element (like Python for example) technically indentation is not important. But over time some conventions took place.Andrey01 wrote:Really are indentations so important?
I'd probably lose my job if I coded without indentation. I'm not joking, it's just unacceptable in a professional environment to be lazy and not properly format, clean, and make your code presentable.Andrey01 wrote:That is i wrote the code wrong? Really are indentations so important? I looked through many times a code that people had written and i saw they wrote as me now without those indentations.
omg how did i miss that! (will fix asap)sofar wrote:I'm somewhat shocked nobody has pointed out the missing `end` yet, btw. :D
Video game developers have to bow to these vowels and syllables too, I am sure. This is especially true for employees of Nintendo.sofar wrote:I'd probably lose my job if I coded without indentation. I'm not joking, it's just unacceptable in a professional environment to be lazy and not properly format, clean, and make your code presentable.Andrey01 wrote:That is i wrote the code wrong? Really are indentations so important? I looked through many times a code that people had written and i saw they wrote as me now without those indentations.
For those who are just starting out programming: Keeping your code clean helps you, and others, later to understand what you are writing, and shows that you took care to make it presentable. This is critical if it ever needs to be changed, or worse, if it needs fixing. Would you feel comfortable living next to a nuclear reactor that was half-painted and had all sorts of mismatched colors and half finished roofs? How about driving a car where each seat has a different material, the steering wheel is "roughly on the left" and the right front wheel is half the size as the others? Awkward? Then you should also expect code to be decent and organized, debugged and presentable :). If not then you're either living in a former USSR state or too dangerous to be near anyone I care about :).
Code: Select all
minetest.register_on_joinplayer(function(player)
local name = player:get_player_name()
local msg
if name == "stix" then
msg = "Hiya Stix :P"
elseif name == "CoolJar10" then
msg = "uh-oh..."
end
If msg then
minetest.after(1, minetest.chat_send_all, msg)
end
end)
CoolJar10 is evil...Xrafede wrote:lol poor CoolJar10
Users browsing this forum: No registered users and 40 guests