This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
hasunwoo's profile picture

Help With Several Stuff

Started by hasunwoo, 28 July 2013 - 09:49 AM
hasunwoo #1
Posted 28 July 2013 - 11:49 AM
i accidentally start this post so how do i delete this topic??
there is no delete button
LBPHacker #2
Posted 28 July 2013 - 12:53 PM
Question #1: WHAT? Sorry, the question makes no sense.

Question #2: getfenv and string indices:

local a = 8

local function debug()
    local varname = read() -- type "a"
    print(tostring(getfenv(2)[varname])) -- will print 8
end

Question #3: IF statement doesn't work like that - it works like this:
if expression then
    -- do something if expression was true
else
    -- do something if expression was false
end
nil and false in the expression evaluate false, anything apart from those evaluates true.
hasunwoo #3
Posted 28 July 2013 - 06:36 PM
Question #1: WHAT? Sorry, the question makes no sense.

Question #2: getfenv and string indices:

local a = 8

local function debug()
    local varname = read() -- type "a"
    print(tostring(getfenv(2)[varname])) -- will print 8
end

Question #3: IF statement doesn't work like that - it works like this:
if expression then
    -- do something if expression was true
else
    -- do something if expression was false
end
nil and false in the expression evaluate false, anything apart from those evaluates true.
I think so if statement is my fault and i will change question how do i call function from string with setfenv
Yevano #4
Posted 28 July 2013 - 06:43 PM
I think so if statement is my fault and i will change question how do i call function from string with setfenv

Not trying to be rude, but use Google Translate. It will help us help you.
prodigy901 #5
Posted 28 July 2013 - 08:00 PM
I'm completely new to lua and I'm trying to have my mining turtle chop a tree down for me. The code is

function tree()
turtle.detectUp()
turtle.digUp()
turtle.up()
end

The turtle won't even move or mine a block. Can someone help?
Yevano #6
Posted 28 July 2013 - 08:30 PM
You need to supply it fuel unless you are in creative. Put fuel in its inventory and run refuel <amount>.
LBPHacker #7
Posted 29 July 2013 - 06:09 AM
You need to supply it fuel unless you are in creative. Put fuel in its inventory and run refuel <amount>.
Don't post a new question on a topic. The 3-post-thresold is not there for nothing.
There is a topic called New members needing to ask questions, please read.

I think so if statement is my fault and i will change question how do i call function from string with setfenv
As I've already mentioned:
local fenv = getfenv() -- gets the function environment table

local function debug()
	local name = read()
	print(fenv[name])
end