Scripts / lua lines

Author
Message
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 2nd Jan 2021 05:16 Edited at: 2nd Jan 2021 05:19
Well, not ley lines... the scripting kind...

Any reason I can't write code like this;


Seems to glitch out, notepad++ shows a bracket [-] above this code
pointing at a;
[-] SetRotation line -- which doesn't begin or end if/ then/ end
|
|
|

BTW-- no error code, just unexpected results....
PM
Bored of the Rings
GameGuru Master
19
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 2nd Jan 2021 06:53
You need to use block commenting --[[ --]]
Professional Programmer: Languages- SAS (Statistical Analysis Software) , C++ VS2019, SQL, PL-SQL, JavaScript, HTML, Three.js, others
Hardware: ULTRA FAST Quad Core Gaming PC Tower WIFI & 16GB 1TB HDD & Win 10 (x64), Geforce GTX1060(3GB). Dell Mixed Reality VR headset, Aerodrums 3D
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 2nd Jan 2021 09:37
if ( a > b or c < d ) and e > f and g < h then



Been there, done that, got all the T-Shirts!
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 2nd Jan 2021 10:27
yes you can use multiple lines as long as they're valid - as amen pointed out your 'if' statement doesn't make sense though so you need to group the conditions that should be met together or break it up into multiple 'if' statements
judging by your comment i assume you want something more like
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 2nd Jan 2021 11:48
Btw, for better readability you should indent the component parts of an if statement, so assuming the logic smallg showed is what your were after:
Been there, done that, got all the T-Shirts!
PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 2nd Jan 2021 18:08
Brackets sounds like a good idea. Thanks.
PM
Nevin
8
Years of Service
User Offline
Joined: 19th May 2015
Location: U.S.A
Posted: 4th Jan 2021 07:42 Edited at: 4th Jan 2021 07:48
You could use elseif

if a > b then
things_happen_one
elseif c < d and e < f and g < h then
things_happen_two
end

and if you needed something to happen if all these things are not happening you could use else

if a > b then
things_happen_one
elseif c < d and e < f and g < h then
things_happen_two
end
else
things_happen_three
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 4th Jan 2021 10:44
Quote: "You could use elseif

if a > b then
things_happen_one
elseif c < d and e < f and g < h then
things_happen_two
end

and if you needed something to happen if all these things are not happening you could use else

if a > b then
things_happen_one
elseif c < d and e < f and g < h then
things_happen_two
end
else
things_happen_three"

the original code/question would be checking for either condition being true and executing the same code if so in 1 branch - but doing it with 'elseif' or 'else' would require you to put the same code in both branches so both conditions execute the same code... while possible it's not really a good way as you're just creating more work for yourself
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Nevin
8
Years of Service
User Offline
Joined: 19th May 2015
Location: U.S.A
Posted: 26th Jan 2021 12:03
Okay. This really helped me.

Login to post a reply

Server time is: 2024-04-24 21:29:23
Your offset time is: 2024-04-24 21:29:23