More than 2 .gsc?
Moderator: Core Staff
More than 2 .gsc?
Is it possible to have more than 1 .gsc files in the map? I tried setting one as teleporter.gsc and mp_[mapname].gsc. The teleporter.gsc doesn't work. When I tried switching them, the teleporter it started to work, but the other script didn't. So do I have to put it as one .gsc file? I am putting 10 teleporters and one rotate brushmodel in my map. Could someone give me the script? :S
Nvm, I just didn't add this line to my .gsc file.
maps\mp\teleport::main();
-.-'
Nvm, I just didn't add this line to my .gsc file.
maps\mp\teleport::main();
-.-'
Re: More than 2 .gsc?
Try this:
thread maps\mp\teleport1::main();
thread maps\mp\teleport2::main();
thread maps\mp\teleport1::main();
thread maps\mp\teleport2::main();
-
- Core Staff
- Posts: 2030
- Joined: July 24th, 2006, 11:21 am
- Location: Cramped in a small cubicle/making another jump map
Re: More than 2 .gsc?
You can use multiple .gsc files. It depends on what you want to do with the code in the .gsc. My general practice is this:
- If you have code that is dependant on your map(say, a mini game that uses entities you placed in Radiant), you call the main function using:
For example:
- If your functions are more general(eg. you create a new HUD element for a player), you can actually include the .gsc before doing anything else:
This tells the engine to include everything from that .gsc file in the .gsc you called it in. Again, this is my way of doing things, it could be the wrong way but I haven't run into any problems with either method.
- If you have code that is dependant on your map(say, a mini game that uses entities you placed in Radiant), you call the main function using:
Code: Select all
.iwd_path\.gsc_name::main_thread(optional_parameters);
Code: Select all
maps\mp\gametypes\_misc::foo();
Code: Select all
#include maps\mp\_utility; /*called before main()*/
This will work for most people, and is the best way of doing things if you don't have any complex code.I just have all my scripting in one file anyway - less can go wrong.
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.
-
- Core Staff
- Posts: 13313
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
Re: More than 2 .gsc?
This should only be used if you are calling the same functions repetitively.Rezil wrote:This tells the engine to include everything from that .gsc file in the .gsc you called it in. Again, this is my way of doing things, it could be the wrong way but I haven't run into any problems with either method.Code: Select all
#include maps\mp\_utility; /*called before main()*/
Usually used for maths functions that dont exist in the engine and functions that create things (such as FX, HUD, etc)
The simplest example is databases.
It is quicker to return an entire array of information from a database in one search than it is to repeatably search for the same information many times.
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010
Re: More than 2 .gsc?
Nah, it is optimized@compile time.Drofder2004 wrote:This should only be used if you are calling the same functions repetitively.Rezil wrote:This tells the engine to include everything from that .gsc file in the .gsc you called it in. Again, this is my way of doing things, it could be the wrong way but I haven't run into any problems with either method.Code: Select all
#include maps\mp\_utility; /*called before main()*/
Usually used for maths functions that dont exist in the engine and functions that create things (such as FX, HUD, etc)
The simplest example is databases.
It is quicker to return an entire array of information from a database in one search than it is to repeatably search for the same information many times.
btw, OP stated that he solved the problem, even before the first reply...
-
- Core Staff
- Posts: 13313
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
Re: More than 2 .gsc?
So, there are no benefits or issues with using an #include instead of a direct call 'maps/mp/etc'?IzNoGoD wrote:Nah, it is optimized@compile time.
btw, OP stated that he solved the problem, even before the first reply...
If that is the case, why do we not simply include everything else in every file and never use a direct call again?
Surely the "include" is not just for a small amount of character saving convenience?
Also, jsut because the OP found a solution, does not mean the OP knew about all the possible solutions.
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010
Who is online
Users browsing this forum: No registered users and 32 guests