Scripts / No Prompt and "if" is syntax error.

Author
Message
Mortt
7
Years of Service
User Offline
Joined: 16th May 2016
Location:
Posted: 9th Jan 2022 16:25 Edited at: 12th Jan 2022 16:12
Any ideas on this?
GG Classic..
Prompt not showing.
and
A line like "if PlayerDist < 300 then"
Error message says (Syntax Error near if).

Problems just started around 14.00 UK time.
Cant sus this one out.

All scripts were working perfectly until 14.00
Tried writing new scripts and just same problems.
Tried using default scripts and same problems.

Very strange.

UPDATE
THIS IS NOT A SCRIPT PROBLEM.

The default.lua script held in scriptbank is not read by GG Classic.
It is a BUG.
(Custom) Intel i7 3.3 Mhz. 16 GB fast ram. EVGA Nvidia 1050 Ti 4GB. Dell US27 2560 x 1440. Dell 24 1920 x 1080. Awesome.
Next G. Card EVGA GeForce GTX 970 Superclocked ACX 2.0 Gaming 4GB GDDR5 PCIe3.0 Graphics Card.
Would Like EVGA NVIDIA GeForce GTX 1080 8GB GDDR5X PCIe3.0 Graphics Card
PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 10th Jan 2022 07:04
I was up late scripting... so looked in.
It's best to show a few more lines of your script, especially before the line in question.
I would check for out of place syntax @ end of line above the one you posted.
PM
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 10th Jan 2022 09:50 Edited at: 10th Jan 2022 12:10
Quote: "A line like "if PlayerDist < 300 then""


LUA uses double symbols, just like C#...

In LUA a single symbol means you are telling the code that something is something, so "PlayerDist < 300" is telling the code that PLayerDist is less than 300 and because it's inside an if statement it's confusing itself.

To compare variables you need two symbols, so it would be "if PlayerDist =< 299 then" asking it if it is equal to or less than 299.
Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Primary Laptop:
i5, NV1050 4GB, 8GB memory, 1x 1TB HDD, Win10.

Secondary Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.


smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 10th Jan 2022 10:22 Edited at: 10th Jan 2022 10:24
Quote: "LUA uses double symbols, just like C#...

In LUA a single symbol means you are telling the code that something is something, so "PlayerDist < 300" is telling the code that PLayerDist is less than 300 and because it's inside an if statement it's confusing itself.

To compare variables you need two symbols, so it would be "if PlayerDist =< 300 then" asking it if it is equal to or less than 300."


that's not true, "if variable1 < variable2 then" is perfectly fine (and i would hope it's perfectly fine in any language as you will want cases where it is not equal to 300 but still less than 300 etc)

it is however the case in most languages when writing equals as that is a declaring statement, hence why you normally need something like == in a check so that it knows you're not setting the value there.

if x < 300 then -> true for x up to 299 (inclusive)
if x <= 300 then -> true for x up to 300 (inclusive)
if x == 300 then -> true only for when x is 300
if x = 300 then -> not valid syntax in lua
x < 300 -> not valid syntax in lua


@mortt restart your computer and try again, if still broken try verify GG via steam, then check your IDE of choice for any problems (i.e. if you use notepad++ try just using notepad in case the IDE has changed settings somehow)
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 10th Jan 2022 12:10
Quote: "that's not true, "if variable1 < variable2 then" is perfectly fine (and i would hope it's perfectly fine in any language as you will want cases where it is not equal to 300 but still less than 300 etc)"


Fair enough, i was just reporting what i was told years ago on here when i was wiring a script and had the same issue, i wanted it less than 10 and < 10 wouldn't work, i was told =< 9 would work and it worked.
Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Primary Laptop:
i5, NV1050 4GB, 8GB memory, 1x 1TB HDD, Win10.

Secondary Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.


GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 10th Jan 2022 16:57
If the restart doesn't work then someone somehow just accidentally tapped in a character somewhere unexpected before the line @ Mortt posted. Look closely and make sure that didn't happen or you don't have some hidden characters in there.

But if you didn't touch those scripts, then it's strange. GG engine @ script does need a refresh occasionally.

PM
Mortt
7
Years of Service
User Offline
Joined: 16th May 2016
Location:
Posted: 11th Jan 2022 13:47 Edited at: 11th Jan 2022 14:30
UPDATE
Using the default.lua script.

Quote: "
default_main(e)
PlayerDist=GetPlayerDistance(e)
if PlayerDist < 300 then
Prompt( " It works. " )
End
End
"


Only problem is that it does not work.

Have been using Notpad++ v 8.5 then went back to v8.1.9.3, Still the same result.
I can save it as v01_default.lua and this works.

I made a new default.lua script as above, but with MS notpad. and saved in another folder in the scriptbank. It works perfectly.
Will now try other scripts in root of scriptbank.

Further UPDATE
If I move the file into a folder then it works.
Just cant figure this out. Other scripts in scriptbank like the ai scripts, ammo.lua, bookcase.lua, coverzone.lua, door.lua and more, all seem to be working ok, except default.lua.
(Custom) Intel i7 3.3 Mhz. 16 GB fast ram. EVGA Nvidia 1050 Ti 4GB. Dell US27 2560 x 1440. Dell 24 1920 x 1080. Awesome.
Next G. Card EVGA GeForce GTX 970 Superclocked ACX 2.0 Gaming 4GB GDDR5 PCIe3.0 Graphics Card.
Would Like EVGA NVIDIA GeForce GTX 1080 8GB GDDR5X PCIe3.0 Graphics Card
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 11th Jan 2022 17:51
default.lua is a special case, GG doesn't call it!

It is handy for when you no longer want your entity to call a script, you just change it to default.lua with:
SwitchScript( e, 'default.lua' )
(or in MAX: SwitchScript( e, 'no_behavior.lua' ) and no I have no idea why Lee changed it!)
Been there, done that, got all the T-Shirts!
PM

Login to post a reply

Server time is: 2024-04-19 22:04:23
Your offset time is: 2024-04-19 22:04:23