17 posts
Posted 22 January 2014 - 01:33 PM
Hello ,
was wondering if and how the code below could work, without having to change the m(x) to m("x"). Had a look around, but couldn't find anything.
function m(a)
if a == "x" then
print("Thanks")
end
end
m(x)
Edited on 22 January 2014 - 12:34 PM
60 posts
Posted 22 January 2014 - 01:51 PM
AFAIK, not unless x actually contains "x".
17 posts
Posted 22 January 2014 - 01:55 PM
Already kinda feared this, guess i have to do it differently then. Thanks for the help :)/>.
1281 posts
Posted 22 January 2014 - 02:29 PM
Tell us why you need this, im sure there's a good way to Solve it.
189 posts
Posted 22 January 2014 - 03:15 PM
As stated by Bab this would be what your describing.
function m(a)
if a == "x" then
print("Thanks")
end
end
local x = "x"
m(x)
17 posts
Posted 22 January 2014 - 03:55 PM
Tell us why you need this, im sure there's a good way to Solve it.
Basicly a way to put in waypoints for turtles. It would be easier to make it work with a interface and also look a lot neater.
As stated by Bab this would be what your describing.
function m(a)
if a == "x" then
print("Thanks")
end
end
local x = "x"
m(x)
Cheers that works thanks a lot :)/>
1281 posts
Posted 22 January 2014 - 04:08 PM
im so lost right now, why not just use m"x"?
17 posts
Posted 22 January 2014 - 04:43 PM
I want it to be possible to add the waypoints via a computercraft computer. I ll tell it what axis, length and what movement type (move,dig,suck,etc).
It's a lot easier and prettier to do it without """".
1281 posts
Posted 22 January 2014 - 05:03 PM
this seems just plain silly to me, if you're making a user interface, chances are the data they input will be a string already. If it's an API, people would have to call apiname.x to get the string, rather than just "x". But it's your code i guess, so here's how i would do it, cause i love tables!
m = {
["x"] = function()
print"Thanks"
end
}
m.x() would then print thanks
17 posts
Posted 22 January 2014 - 05:10 PM
Probably is silly lol. At the moment i only put them in a as a simple list and figured how i could enter it using a sort of terminal.
Not done though. Thanks for the input might give it a try as it does look much simpler.