|
| 03 Mar 2015 11:51 AM |
local enabled = false
if enabled then print("enabled") else print("disabled") end
While going over the Roblox Wiki Lua tutorial -maybe I'm over thinking it- I ran into an issue or means for concern. Would "disabled" be printed on the screen since enabled is rendered false, causing the compiler to overlook or skip the first function and printing the second (After, of course, it changes the high-level language into a low-level machine language)? Or am I just out of my mind..? |
|
|
| Report Abuse |
|
|
HailMario
|
  |
| Joined: 05 Oct 2012 |
| Total Posts: 17741 |
|
|
| 03 Mar 2015 11:55 AM |
i think i know the answer.....
you have to leave friendpai
jk idk |
|
|
| Report Abuse |
|
|
iAndreas
|
  |
| Joined: 05 Feb 2015 |
| Total Posts: 667 |
|
|
| 03 Mar 2015 11:56 AM |
Local: "Enabled" is false (not enabled) so when it is enabled, it will display "Enabled" but if it's not (which it isn't at the start of the script) then it will display "Disabled."
iAndreas | The Providence |
|
|
| Report Abuse |
|
|
|
| 03 Mar 2015 11:57 AM |
you need local function enabled = false
lol |
|
|
| Report Abuse |
|
|
|
| 03 Mar 2015 11:59 AM |
So it would print "Disabled", I see. In order to enable it and have it print "Enable", I'd have to make the statement true, yes?
local enabled = true
if enabled then print("enabled") else print("disabled") end |
|
|
| Report Abuse |
|
|
|
| 03 Mar 2015 11:59 AM |
| local enabled isn't setting a function |
|
|
| Report Abuse |
|
|
|
| 03 Mar 2015 12:00 PM |
and you didn't set if enabled is what so
local function enabled = false
if enabled = true then print("enabled") else print("disabled") end
|
|
|
| Report Abuse |
|
|
|
| 03 Mar 2015 12:03 PM |
nvm ignore me
local function enabled() enabled = false
if enabled = true then print("enabled") else print("disabled") end
|
|
|
| Report Abuse |
|
|
|
| 03 Mar 2015 12:04 PM |
| So I'd have to use the "function" command to set or offset enable-ability and make it print either strings? If that's the case, what did the previous script I asked about do exactly? |
|
|
| Report Abuse |
|
|
| |
|
iAndreas
|
  |
| Joined: 05 Feb 2015 |
| Total Posts: 667 |
|
|
| 03 Mar 2015 12:13 PM |
The first you posted made a function called enabled and made the value false, and if the value was true post enabled, unless it was false, it'd display disabled.
iAndreas | The Providence |
|
|
| Report Abuse |
|
|
iAndreas
|
  |
| Joined: 05 Feb 2015 |
| Total Posts: 667 |
|
|
| 03 Mar 2015 12:14 PM |
Sorry, wrong, you made a function called enabled, and made the value false, and you said if the function you made then "enabled", meaning your script doesn't exactly work.
iAndreas | The Providence |
|
|
| Report Abuse |
|
|
|
| 03 Mar 2015 12:14 PM |
| Okay, so I had it right the first go round. Cool was somewhat confusing me. :( |
|
|
| Report Abuse |
|
|
|
| 03 Mar 2015 12:15 PM |
| My brain can't take much more of these wishy-washy explanations. :( |
|
|
| Report Abuse |
|
|
iAndreas
|
  |
| Joined: 05 Feb 2015 |
| Total Posts: 667 |
|
|
| 03 Mar 2015 12:19 PM |
OK I'll break it down. (I'm not an expert at scripting, but I edit them, so I may not be 100% accurate.)
local enabled = false <-- You've got the local function "enabled" and you've made the value false.
if enabled then <-- Then you're saying, if the local function "enabled" then print "enabled.", so you're saying if the function exists or somewhat, then print enabled. print("enabled") else print("disabled") <-- But if it doesn't exist, post disabled. end
iAndreas | The Providence |
|
|
| Report Abuse |
|
|
iAndreas
|
  |
| Joined: 05 Feb 2015 |
| Total Posts: 667 |
|
|
| 03 Mar 2015 12:20 PM |
This will work.
local function enabled() <-- There it's getting the function "enabled." enabled = false <-- Making it false.
if enabled = true then <-- If it's not false (true) then print enabled. print("enabled") else print("disabled") <-- If it's false then print disabled. end
iAndreas | The Providence |
|
|
| Report Abuse |
|
|
|
| 03 Mar 2015 03:25 PM |
| if you haven't set enabled as a function already your code won't work and mine will |
|
|
| Report Abuse |
|
|
|
| 03 Mar 2015 03:34 PM |
enabled = true
if enabled == true then print("enabled") else print("enabled is false") end
-- you need to use == when you check for a value and = when you set a value |
|
|
| Report Abuse |
|
|
|
| 03 Mar 2015 03:35 PM |
function???
wtf??? that's not what he was asking for |
|
|
| Report Abuse |
|
|
|
| 03 Mar 2015 03:36 PM |
| i wonder if these people are trolling or just putting random stuff |
|
|
| Report Abuse |
|
|
|
| 03 Mar 2015 03:39 PM |
enabled is a variable and not a function
>_>
its a bool variable that has a true or false value |
|
|
| Report Abuse |
|
|
|
| 03 Mar 2015 03:45 PM |
oh i was getting variables and functions confused
cos he used local enable |
|
|
| Report Abuse |
|
|
RobuxLife
|
  |
| Joined: 19 Sep 2012 |
| Total Posts: 13336 |
|
|
| 03 Mar 2015 03:47 PM |
local enabled = false -- you made a local variable named enabled
if enabled then -- if enabled = true or exists or whatever then print("enabled") -- print enabled else -- if it's not true then print("disabled") -- print disabled end
|
|
|
| Report Abuse |
|
|
|
| 03 Mar 2015 03:56 PM |
| Ya, I'm in the boolean tutorial. |
|
|
| Report Abuse |
|
|