function save(var,text) var = text endBut, it will save the text to "var" and not the variable that the user provided.
Also, need a good tutorial on using _G
- What is it?
- how to use it
- when to use it
- why to use it
Posted 30 September 2013 - 08:15 PM
function save(var,text) var = text endBut, it will save the text to "var" and not the variable that the user provided.
Posted 30 September 2013 - 09:50 PM
function func (_table) print (_table) endand I do the following:
local myTable = { 1, 2, 3, 4, 5 }
print (myTable)
func (myTable)
I'll get the SAME value printed out which is simply the address of the table. Therefore, if you want to copy tables, you'll have to do it using what's called recursion or just going through the table and copying the non-table values if the table is simple enough (not really any tables within the table).var = textwithout a function or, superfluously:
local var = nil function save (text) var = text endor even
local var = nil
function save (text)
return text
end
var = save ("Test.")
All of the which are unnecessary except for the first example without any functions.-- term.write ("Test.")
_G["term"]["write"] ("Test.")
_G["index"] = ...
-- or even (if you know exactly what you want the index to be)
_G.totallyAwesomeTable = {}
Posted 01 October 2013 - 04:52 PM
local var = textBut I thought that there was a way to take whatever is in the variable "text", and save it as whatever text in the variable "var".
Posted 01 October 2013 - 05:28 PM
Posted 01 October 2013 - 06:52 PM
wojbie, on 01 October 2013 - 05:28 PM, said:
local x, y function replacement.up() ... end function replacement.down() ... end function replacement.forward() ... end ...
Posted 01 October 2013 - 07:12 PM
Yevano, on 01 October 2013 - 06:52 PM, said:
wojbie, on 01 October 2013 - 05:28 PM, said:
local x, y function replacement.up() ... end function replacement.down() ... end function replacement.forward() ... end ...
Posted 02 October 2013 - 11:25 PM
function save(text)
return text
end
a = save("Hello world")
--# a is now "Hello world"
Posted 03 October 2013 - 03:17 PM
jay5476, on 02 October 2013 - 11:25 PM, said:
function save(text)
return text
end
a = save("Hello world")
--# a is now "Hello world"
0 members, 2 guests, 0 anonymous users