Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
|
| 30 May 2014 05:51 PM |
if keyboard.isDown("left") then pos = pos + left elseif keyboard.isDown("right") then pos = pos + right end
...OR...
if keyboard.isDown("left") then pos = pos + left end if keyboard.isDown("right") then pos = pos + right end
Assume these work. What kind of a scripter are you? #1 or #2? |
|
|
| Report Abuse |
|
|
badfitz99
|
  |
| Joined: 01 May 2010 |
| Total Posts: 5854 |
|
|
| 30 May 2014 06:05 PM |
I suppose #2
Anything you can do, a Asian kid half your age can do better! 'I am the greatest script in the realm. You can only hope to be as powerful of a script as I am, processing the world, bit by bit.' - Oysi 2014 |
|
|
| Report Abuse |
|
|
bohdan77
|
  |
| Joined: 10 Aug 2008 |
| Total Posts: 7944 |
|
| |
|
|
| 30 May 2014 06:21 PM |
| #2, although I would prefer just taking the most recently pressed and executing that part of the code. |
|
|
| Report Abuse |
|
|
|
| 30 May 2014 06:27 PM |
| In this case, #2. Self-cancellation seems nice to me, personally. |
|
|
| Report Abuse |
|
|
booing
|
  |
| Joined: 04 May 2009 |
| Total Posts: 6594 |
|
| |
|
|
| 30 May 2014 06:57 PM |
| I have a strong, possibly irrational, aversion to elseif's. |
|
|
| Report Abuse |
|
|
|
| 30 May 2014 07:51 PM |
| I like to do both just to make sure pos is what I want it to be and to confuse future readers of my code :) |
|
|
| Report Abuse |
|
|
xSIXx
|
  |
| Joined: 06 Aug 2010 |
| Total Posts: 9202 |
|
| |
|
|
| 30 May 2014 09:14 PM |
As bohdan implied, two could work better for this situation as the first and second if statements are not mutually exclusive. Option one weights the situation to "left." Unless, of course, you are trying to get some idea of how many scripters here would chose the unweighted option as opposed to differentiating between if-if and if-elseif users. I prefer using if-elseif in most situations but adopt as convenience dictates.
-God Bless- |
|
|
| Report Abuse |
|
|
LuaSir
|
  |
| Joined: 30 Mar 2014 |
| Total Posts: 40 |
|
|
| 30 May 2014 09:32 PM |
When using things that are not mutually exclusive, I hate the way the second looks, so I style it like
if condition then --stuff end if other condition then --other stuff end
It has the exact same width as
if condition then --stuff elseif other condition then --other stuff end
So it is visually pleasing. |
|
|
| Report Abuse |
|
|
| |
|
Insoul
|
  |
| Joined: 04 May 2014 |
| Total Posts: 66 |
|
|
| 30 May 2014 10:38 PM |
Id have to go with one just cause it's much more 'ok'
herro Im syKo |
|
|
| Report Abuse |
|
|
| |
|
Tflipz
|
  |
| Joined: 04 Nov 2013 |
| Total Posts: 4159 |
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 31 May 2014 03:29 AM |
In most situations, #1. Why run useless checks... |
|
|
| Report Abuse |
|
|
|
| 31 May 2014 03:48 AM |
KEES = {}
ypos = 0 xpos = 0
Mouse = game.Players.LocalPlayer:getMouse()
Mouse.KeyDown:connect( function(key) KEES[key] = true end )
Mouse.KeyUp:connect( function(key) KEES[key] = false end )
game:getService("RunService").RenderStepped:connect( function() if KEES.w then ypos = ypos + 1 elseif KEES.s then ypos = ypos - 1 end if KEES.a then xpos = xpos - 1 elseif KEES.d then xpos = xpos + 1 end
[insert character var].Position = UDim2.new(0, xpos, 0, ypos) end ) |
|
|
| Report Abuse |
|
|
|
| 31 May 2014 04:23 AM |
#2 because #1 prefers left to right...
oh wait that's a good thing, never mind, #1
lefties unite!1!!! |
|
|
| Report Abuse |
|
|
As8D
|
  |
| Joined: 24 Dec 2009 |
| Total Posts: 2907 |
|
|
| 31 May 2014 11:18 AM |
#1 cuz I don't read the whole OP before I answer, and looking at comments, I assume that people choosing #2 are right-handed.
lefties unite!1!!! - As |
|
|
| Report Abuse |
|
|
|
| 31 May 2014 11:29 AM |
Answer 2 for 2 reasons.
First, it allows you to press 2 keys at once, and have the effect nullilified, It makes the game more interesting that way.
Second, the values can be different, which makes an interesting gameplay, such as holding down both left and right and decrease your normal speed in a certain direction, instead of going the same way linearly.
Alt. of Jetta765214 |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
Maradar
|
  |
| Joined: 06 Mar 2012 |
| Total Posts: 4478 |
|
|
| 31 May 2014 03:14 PM |
neither. usually i do this
pootis = true pootis2 = true
function choice3() if pootis == true then wait(1) else error("hi") then wait(1) if pootis2 == false then wait(1) else error("darn") then wait(1) end |
|
|
| Report Abuse |
|
|
oseday
|
  |
| Joined: 27 Aug 2008 |
| Total Posts: 1308 |
|
|
| 31 May 2014 03:27 PM |
2nd because both might be pressed at once. but in most situations I use 1st. |
|
|
| Report Abuse |
|
|