Scripts / Why error ?

Author
Message
RvD
10
Years of Service
User Offline
Joined: 17th Feb 2016
Location:
Posted: 25th Feb 2016 21:34
I was practicing a guide on steam and i wrote a script i first got entity which is a big house i renamed it in properties to Construction , it's entity number is 2 .. so i wrote a script with N++


Function Construction2_init(e)
end

Function Construction2_main(e)
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 100 then
Prompt(“You Have Arrived”)
end
end

I named it with construction.lua
and i attached it i keep getting an error upon lunching the game
Syntx error near construction.init
what did i do wrong ?
PM
PartTimeCoder
11
Years of Service
User Offline
Joined: 9th Mar 2015
Location:
Posted: 25th Feb 2016 21:38
your function declaration must match your script name, for a function name "Construction2" you must name your script "Construction2.lua"
PM
Belidos
3D Media Maker
10
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 25th Feb 2016 21:58
The _int(e) and _main(e) have to be the same as the name of the file

So if your file is called construction.lua then those lines should be ...

Function construction_init(e)

and

Function construction_main(e)
i7, NV960 4GB, 16GB memory, 2x 4TB Hybrid, Win10.
i5 , AMD 6770 1GB, 8GB memory, 512GB Generic SATAIII + 2TB Seagate Baracuda SATAIII, Win7.
i3, Radeon integrated graphics, 4GB memory, 512gB Generic SATAII, Win8.1.
Q6600, Intel integrated graphics, 2GB memory, 180GB Generic SATAII, WinXP.
RvD
10
Years of Service
User Offline
Joined: 17th Feb 2016
Location:
Posted: 25th Feb 2016 22:02
I did so it worked with no errors but the message don't appear, did i miss any thing ?
PM
Pirate Myke
Forum Support
16
Years of Service
User Offline
Joined: 31st May 2010
Location: El Dorado, California
Posted: 25th Feb 2016 22:17
No capital letters can be used in the script name or the function names.
Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit, Screen resolution 1680 x 1050.

HarryWever
3D Media Maker
16
Years of Service
User Offline
Joined: 14th Jan 2010
Location: below Sea level
Posted: 25th Feb 2016 22:20 Edited at: 25th Feb 2016 22:23
Did you set the building to dynamic.?
scripts can only be used if the entity is dynamic
check the fpe file of the building and change defaultstatic = 1 to defaultstatic = 0
The distance check is meassured i think with the pivot point location of the entity. mostly in the center.
so maybe a greater distance check, if it is a large building.


Harry
Harry
When nothing goes right, go left
PM
RvD
10
Years of Service
User Offline
Joined: 17th Feb 2016
Location:
Posted: 25th Feb 2016 23:26
I used the acid barrel it's set to Not static , how do i change the other thing ?
PM
perelect
11
Years of Service
User Offline
Joined: 27th Mar 2015
Location: Australia
Posted: 26th Feb 2016 00:28 Edited at: 26th Feb 2016 00:30
Like the other have said match the script name with the function names, and use lowercase letters.

You have used Function, it should be function , lowercase letter f

Desktop: Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz (8 CPUs), ~3.6GHz, Windows 8.1 64-bit, 16 GB Ram, NVIDIA GeForce GTX 750 Ti, Display Memory: 4018 MB. Resolution 1360x768, Passmark 3528.
Laptop: Pavilion dv6 Notebook, Intel(R) Core(TM) i5-2410M CPU @ 2.30 GHz, Win 7 64 bit, 16 GB Ram, Radeon (TM) HD 6490M, 2336 MB Memory. Resolution 1366x768, Intel(R) HD Graphics 3000. (WEI 5.8)

Login to post a reply

Server time is: 2026-06-09 02:48:44
Your offset time is: 2026-06-09 02:48:44