Eliminating Scripting & Console Errors
Moderator: Moderators
Eliminating Scripting & Console Errors
One of the most irritating things for me as a mapper (and detailed oriented person) is how many errors appear in the console when I run a map. I cannot seem to pinpoint the cause of the errors. I need help finding the cause of an error that claims that my script was not loaded properly. Does the script need to be in a certain folder? One of the problems with using many different applications to build a map is that you have to setup everything to work in harmony. MBuilder (which I use to compile my maps) outputs (I believe) 2 bsp files, one in the "source" folder and another in the "game" directory, which is determined by the type of game (single, mp, etc.). Can someone please give some guidance as to why my script is not running. It does not have any errors because I copied it from this site in the section that talks about Spawning Enemy soldiers.
-
$oldier Of Ra
- Lieutenant Colonel
- Posts: 404
- Joined: Sun Oct 16, 2005 7:16 pm
- Location: Belgium
- Contact:
The mapscript must have the same name as the bsp file, only with a .scr file extension. I have a file somewhere which fixes most of the annoying errors in the console, like precache errors.
Post your script here if necessary so I can debug it.
Post your script here if necessary so I can debug it.
Our official website: http://www.mohaairborne.co.cc
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)
For all your bot needs!!!!
$oldier Of Ra.
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)
For all your bot needs!!!!
$oldier Of Ra.
I do have the same name as the map. Here's "my" script, which is just a copy of the one on this site . . .
Code: Select all
exec global/ai.scr // enables the game ai
exec global/loadout.scr maps/test_xx.scr // enables the script
level waittill prespawn // wait till loaded before spawning level
exec global/ambient.scr test_xx // enables ambient sound
level waittill spawn
$player item weapons/colt45.tik // gives you a gun
fadein 2 0 0 0 1 // fades in the level
wait 2 // wait
level.script = "maps/test_xx.scr"
thread objectives // this adds your objectives defined below
thread music1 // see below
end
/////////////////
objectives:
waitthread global/objectives.scr::add_objectives 1 2 "walk through the door and beyond." $obj1.origin // you will find this in
// map
set_objective_pos $obj1 // sets position for compass by
// targeting script_origin in your .map
end
/////////////////
music1:
// the following music will be played the files are in pk3 to open
// use winzip
$player stufftext "tmstart sound/music/mus_04f_suspense.mp3"
end
//////////////////
objective1:
goto levelend // called by the key given to our triggermultiple in
//.map
end
/////////////////
levelend:
waitthread global/objectives.scr::add_objectives 1 3 "walk through the door and beyond." $obj1.origin
waitthread global/objectives.scr::current_objectives 0 // clears
// objectives
exec global/missioncomplete.scr test_xx 1 // on completion load
// this map
end
Code: Select all
exec global/ai.scr // enables the game ai
exec global/loadout.scr maps/test_xx.scr // enables the script
level waittill prespawn // wait till loaded before spawning level
exec global/ambient.scr test_xx // enables ambient sound
level waittill spawn
$player item weapons/colt45.tik // gives you a gun
fadein 2 0 0 0 1 // fades in the level
wait 2 // wait
level.script = "maps/test_xx.scr"
thread objective1
thread objectives // this adds your objectives defined below
thread music1 // see below
end
/////////////////
objectives:
waitthread global/objectives.scr::add_objectives 1 2 "walk through the door and beyond." $obj1.origin // you will find this in
// map
set_objective_pos $obj1 // sets position for compass by
// targeting script_origin in your .map
end
/////////////////
music1:
// the following music will be played the files are in pk3 to open
// use winzip
$player stufftext "tmstart sound/music/mus_04f_suspense.mp3"
end
//////////////////
objective1:
$objective_trigger waittill trigger
goto levelend // called by the key given to our triggermultiple in
//.map
end
/////////////////
levelend:
waitthread global/objectives.scr::add_objectives 1 3 "walk through the door and beyond." $obj1.origin
waitthread global/objectives.scr::current_objectives 0 // clears
// objectives
exec global/missioncomplete.scr test_xx 1 // on completion load
// this map
end $objective_trigger is trigger multiple with targetname objective_trigger.
Hmm. Well, something is working now, but here's what's happening. When the level starts . . . it ends? And starts again? A continous loop. It's like the objective is completed without doing anything. Very weird. Would it help if I gave you my .map file and you could just let me know what changes you've made?
-
$oldier Of Ra
- Lieutenant Colonel
- Posts: 404
- Joined: Sun Oct 16, 2005 7:16 pm
- Location: Belgium
- Contact:
This means either you spawn on the $objective_trigger which is a trigger_multiple and directly refers you to the end of the level. Or $objective_trigger doesn't exist, so the waittill trigger is ignored and the end of the level is immediately initiated because Aprop's script immediately activates this thread:
Copying a script from a tutorial/source certainly does not guarantee it will work. You must follow and complete all steps stated in that tutorial before it might work. Did you do this and what tutorial or where did you get it?
Code: Select all
objective1:
$objective_trigger waittill trigger //doesn't exist so causes console error and gets skipped
goto levelend // called by the key given to our triggermultiple in
//.map
end Our official website: http://www.mohaairborne.co.cc
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)
For all your bot needs!!!!
$oldier Of Ra.
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)
For all your bot needs!!!!
$oldier Of Ra.
I completely agree about following the tutorial. I have overcome the restarting of the map. Don't know what I changed in the script, but it worked. Hope I'm not giving you the impression that I'm just lazy and just randomly deleted code. Not the case. In fact this code looks eerily similar to batch code. I'm referring to things like "goto", which helped a lot. I ran down the script and began to figure out how things are working. It's very exiting to have learned code when I was younger. It gives you so much of a head start on any language. But, I digress. I've now got down the first objective and successfully tested it. My next question is, how do you "clear" or "x" out an objective? what code am I going to need for this? Something like -- waittill objective_done or something?
P.S. Hopefully you've noticed I write good subject lines when I ask questions in this forum. I'd like to power up my learning curve and at the same time benefit this site by creating more of these well named subjects and possibly develop these threads into full tutorials. This way we'd be killing 2 birds (the EPA will now be after me) with one stone, benefiting the site and helping me create not just good maps, but error-less and well-planned ones. The kind that you play over and over again.
P.S. Hopefully you've noticed I write good subject lines when I ask questions in this forum. I'd like to power up my learning curve and at the same time benefit this site by creating more of these well named subjects and possibly develop these threads into full tutorials. This way we'd be killing 2 birds (the EPA will now be after me) with one stone, benefiting the site and helping me create not just good maps, but error-less and well-planned ones. The kind that you play over and over again.
-
$oldier Of Ra
- Lieutenant Colonel
- Posts: 404
- Joined: Sun Oct 16, 2005 7:16 pm
- Location: Belgium
- Contact:
Scripting isn't hard if you think logical. I mentioned the cause of the level restart here above. 
Hmm...the "goto" command; I always remember other scripters telling me to avoid using goto for a reason that slipped my mind.
How to check an objective off? Well I never used the global/objectives.scr script, but the answer lies within
, the header will probably supply you with enough information.
Hmm...the "goto" command; I always remember other scripters telling me to avoid using goto for a reason that slipped my mind.
How to check an objective off? Well I never used the global/objectives.scr script, but the answer lies within
Our official website: http://www.mohaairborne.co.cc
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)
For all your bot needs!!!!
$oldier Of Ra.
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)
For all your bot needs!!!!
$oldier Of Ra.