UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

[Tutorial] Debugging Scripts

HOTPINNED
broken avatar :(
Created 10 years ago
by SparkyMcSparks
0 Members and 1 Guest are viewing this topic.
22,316 views
broken avatar :(
×
broken avatar :(
Former Treyarch Developer
Location: usSherman Oaks, CA
Date Registered: 23 May 2014
Last active: 2 years ago
Posts
37
Respect
Forum Rank
Legless Crawler
Primary Group
UGX V.I.P.
My Groups
More
My Contact & Social Links
More
Personal Quote
VR Enthusiast
×
SparkyMcSparks's Groups
UGX V.I.P.
UGX V.I.P.
Looking at the WaW Scripting Support forum section, it seems like a lot of problems can be solved quite easily without much help if doing some debugging. This tutorial is easy enough that you don't need much scripting knowledge, if anything, it'll let you post valuable information when seeking help for people to better assist you.

I'll try to keep this thing updated over time (and cross-posted between UGX and ZM forums) if I see more common issues arise in the support section or someone has a specific debugging question or technique they want to know about.

Running The Game In Developer Mode

First off, you want to run some dvars when working on your map / mod. These are the ones I recommend ALWAYS using when developing your content:

set developer 2  set developer_script 1  set thereisacow "1337"  set logfile 2  devmap <mapname>

Zombies Debugging

In addition to running the game in developer mode, you can use for zombie related development tools:

set zombie_cheat <1-5>

1     Start all players with 100000 points
2     Start all players with 100000 points   don’t spawn any zombies
3     Start all players with 100000 points   turn on the power after 5 seconds
4     Points   no zombies   power after 5 seconds
5     Same as 4   the ability to re-buy the same perk over and over. Useful for testing animations, sounds, etc.

Checking Logfile

Everything that is printed to the console is printed to the console.log file which goes in the main folder by default. If you're running a mod, the console.log will be in your mod folder within the installation directory.

If you're posting an error on the forum or for someone to fix, it's generally a good idea to attach this file since it'll contain all the console information of what went wrong like a callstack.

Script Runtime Errors

When running your map in developer mode, if you encounter a Script Runtime Error (SRE) the game will end the map if it's fatal or bring up a pop-up window if it's non-fatal.

If you have a SRE you should ALWAYS address them to get a proper fix in -- don't assume since people playing your map won't be running developer mode the issue goes away. It is still happening in the background and can cause really bad issues like hitching, unexpected script results, or even crashing your map.

They usually look like this:
Quote
******* script runtime error *******
undefined is not an array, string, or vector: (file 'maps/mp/_load.gsc', line 113)
if (!isdefined(level._effect["lantern_light"]))
*
called from:
(file 'maps/mp/_load.gsc', line 12)
lanterns thread lanterns();
*
called from:
(file 'maps/mp/mp_houses22.gsc', line 2)
mapsmp\_load::main();
*
started from:
(file 'maps/mp/mp_houses22.gsc', line 1)
main() {
*
************************************

The way it's displayed is the bottom is the origin of the script routine, and the very top is where the SRE was encountered.

In the above example, the map main() function calls the _load.gsc main() function which calls the _load.gsc lanterns() function which has an error on line 113 with the lantern FX.

Note: The formatting is off in how the forum shows this, but the asterisk (*) will always be under the variable / function with the error. It'll display properly in-game to give you a better idea what part of the line is problematic.

Assertions

Asserts are a development feature that check if a condition is true and if not, stops the game. This is useful for when you as a designer want to validate your assumptions about what the state of the game should be whenever possible.

Example:
Code Snippet
Plaintext
AssertEx( IsDefined( ai_maxis), "Maxis AI did not spawn." );

These have no impact in non-developer mode, so people playing your map will never trigger them... but they may run into a SRE. In that case, you should avoid defensive coding to get around the issue and instead fix the issue; if something shouldn't happen, then an assertion is the right thing to use.

Here are the various Assert API you have at your disposal:
Assert( <value> );     Assert that the given statement is correct. The function will throw a script error if this is false.
AssertEx( <value>, <message> );     Assert that the given statement is correct. The function will throw a script error if this is false, with the given message.
AssertMsg( <message> );     Throws a script error with the given message.

Dev Blocks

If you want certain script snippets to only execute when in developer mode, you can wrap in /#    #/

This is useful if you want to kick off developer functions or do prints to the screen of information you want to see from script. People playing your map won't see these.

Example:
Code Snippet
Plaintext
	while ( true )
{
trig waittill( "trigger", who );
{
/#
IPrintLnBold( "Player who purchased perk: "   who.playername );
#/
}
}

Common SREs

Quote
could not find script <script_name_here>
You don't have the script in a FastFile or IWD that is being loaded by the map.

Quote
   must be applied to an int (applied to undefined)
You'tr trying to do a mathematical operation on a variable that isn't defined before the operation. You can't initiate a variable while doing the mathematical operation, you need to define it earlier even if it's just a zero.

Quote
undefined is not an array, string, or vector
Variable you're trying to reference is empty.

Quote
cannot set field of removed entity
Entity has left / deleted from the game or the entity variable it was stored in has been reset / undefined.

Quote
cannot cast undefined to <variable_type_here>
You're trying to reference a variable that is empty.

Quote
potential infinite loop in script
Your while or for loop doesn't have a wait in it. Every loop needs a wait, whether it be a timed wait of 0.05 seconds or waiting for a notify.
Last Edit: May 23, 2014, 11:22:32 pm by SparkyMcSparks
broken avatar :(
×
broken avatar :(
Former UGX Lead Asset Creator
Location: ca
Date Registered: 17 August 2012
Last active: 5 years ago
Posts
1,932
Respect
Forum Rank
Zombie Destroyer
Primary Group
UGX V.I.P.
My Groups
More
My Contact & Social Links
More
Personal Quote
Eh?
Signature

(Click to enter portfolio)
×
SajeOne's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
UGX V.I.P.
UGX V.I.P.
Great tutorial sparky, glad you're sharing your knowledge with the community. We actually have a section specifically for scripting tutorials so I have moved this topic there.
broken avatar :(
×
broken avatar :(
[UGX] Documentation Writer & Programmer
Location: usLos Angeles, CA
Date Registered: 23 August 2013
Last active: 6 months ago
Posts
1,322
Respect
Forum Rank
Zombie Colossus
Primary Group
UGX Team Member
My Groups
More
My Contact & Social Links
More
Personal Quote
(ง º ω º )ง u wont sum m8y?
Signature
Do not take life too seriously. You will never get out of it alive.
×
DidUknowiPwn's Groups
UGX Team Member
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
+rep
:3
broken avatar :(
×
broken avatar :(
Location: usbuffalo
Date Registered: 16 August 2013
Last active: 11 months ago
Posts
927
Respect
Forum Rank
The Decider
Primary Group
Community Mapper
My Groups
More
My Contact & Social Links
More
Personal Quote
Giggity.
Signature
maps:
Undead Town
http://ugx-mods.com/forum/index.php?topic=2294.0 (Release)
Origins 1922
http://ugx-mods.com/forum/index.php?topic=2659.0
[WIP] mapping 39%, weapons 85%, scripts 65%
[/url]
×
RamboBadass's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
RamboBadass's Contact & Social LinksAsk merambobadassRamboDaGreat
amazing!
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 8 years ago
Posts
2,790
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
Signature
Let's keep this thread on topic from here on in. -DBZ

+1 to off-topic reply -DBZ

lmao. Too funny.

Goliath Script Placer: http://ugx-mods.com/forum/index.php/topic,11234.msg125257/topicseen.html#new

"...Christ, people. Learn C, instead of just stringing random characters
together until it compiles (with warnings)..."

-Linus Torvalds
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
Amazing tutorial dude! +1
broken avatar :(
×
broken avatar :(
The King of Zombies
Location: usLouisiana
Date Registered: 24 June 2013
Last active: 4 years ago
Posts
2,148
Respect
Forum Rank
King of the Zombies
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Signature
Donate to me if you enjoy my work. https://www.paypal.me/thezombiekilla6
×
Dust's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Dust's Contact & Social LinksMrZ0mbiesFanaticdust103194MrZ0mbiesFanatic
nice! this will come in handy
broken avatar :(
×
broken avatar :(
[UGX] Founder
Location: usBay Area, California
Date Registered: 24 June 2011
Last active: 8 months ago
Posts
5,551
Respect
6,691Add +1
Forum Rank
Immortal
Primary Group
UGX Administrator
My Groups
More
My Contact & Social Links
More
Signature
If Java had true garbage collection, most programs would delete themselves upon execution.
×
treminaor's Groups
UGX Administrator
UGX Team Member
UGX Site Moderator Has the ability to issue warnings to users, edit and remove posts from the forum and to move topics to other boards. Upholds the rules of the forum. Moderates Chat Rooms.
Use all of this daily already, but this saves me the time of writing it up in a wiki guide :D Nice formatting, lots of good info, +1. Stickied.
broken avatar :(
  • DeletedUser
  • Deleted Member
×
broken avatar :(
DeletedUser
This user is deleted :(
Holy shet, never thought dev's lives could be that easier!
broken avatar :(
×
broken avatar :(
[UGX] Founder
Location: usBay Area, California
Date Registered: 24 June 2011
Last active: 8 months ago
Posts
5,551
Respect
6,691Add +1
Forum Rank
Immortal
Primary Group
UGX Administrator
My Groups
More
My Contact & Social Links
More
×
treminaor's Groups
UGX Administrator
UGX Team Member
UGX Site Moderator Has the ability to issue warnings to users, edit and remove posts from the forum and to move topics to other boards. Upholds the rules of the forum. Moderates Chat Rooms.
Bear in mind the developer 1/2 command and developer_script do not have full effect unless you turn them on BEFORE you boot your map. Meaning if you cant  boot your map with those turned on, you need to fix all of the errors. I did this for UGX Mod v1.1 and also for the UGX Modtools Patch already.
broken avatar :(
×
broken avatar :(
Location: usbuffalo
Date Registered: 16 August 2013
Last active: 11 months ago
Posts
927
Respect
Forum Rank
The Decider
Primary Group
Community Mapper
My Groups
More
My Contact & Social Links
More
Personal Quote
Giggity.
×
RamboBadass's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
RamboBadass's Contact & Social LinksAsk merambobadassRamboDaGreat
Hello SparkyMcSparks,
I don't have this issue anymore thanks to Trem and DualVII, but Im curious to know if there's a way to locate were a potential infinite loop is in the script...or even say way script?
There's a @13275 after the SRE but I am unsure if this is even related to the error.

broken avatar :(
×
broken avatar :(
Location: de
Date Registered: 18 October 2013
Last active: 14 days ago
Posts
652
Respect
Forum Rank
Zombie Enslaver
Primary Group
Donator ♥
My Groups
More
×
InFInIX's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Oil Rig Beta Access
Oil Rig Beta Access
InFInIX's Contact & Social Links
Never thought treyarch shares stuff for a 6 year old game :O
broken avatar :(
×
broken avatar :(
Former Treyarch Developer
Location: usSherman Oaks, CA
Date Registered: 23 May 2014
Last active: 2 years ago
Posts
37
Respect
Forum Rank
Legless Crawler
Primary Group
UGX V.I.P.
My Groups
More
My Contact & Social Links
More
Personal Quote
VR Enthusiast
×
SparkyMcSparks's Groups
UGX V.I.P.
UGX V.I.P.
Hello SparkyMcSparks,
I don't have this issue anymore thanks to Trem and DualVII, but Im curious to know if there's a way to locate were a potential infinite loop is in the script...or even say way script?
There's a @13275 after the SRE but I am unsure if this is even related to the error.
(Image removed from quote.)

No, at least not with the public EXEs of the game. Just have to hope that it's a result of SREs that you can trace back, or that you remember any for / while loops you made that might be missing a wait.

Someone had similar infinite loop at the beginning of the map and every time he threw a grenade, ended up being he didn't have the special coop characters setup so the voice overs were bugging out creating an infinite loop.
broken avatar :(
×
broken avatar :(
Location: usbuffalo
Date Registered: 16 August 2013
Last active: 11 months ago
Posts
927
Respect
Forum Rank
The Decider
Primary Group
Community Mapper
My Groups
More
My Contact & Social Links
More
Personal Quote
Giggity.
×
RamboBadass's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
RamboBadass's Contact & Social LinksAsk merambobadassRamboDaGreat
Thanks for the reply
+1 for you  ;)
broken avatar :(
×
broken avatar :(
[UGX] Maintainer (Admin & Programmer)
Location: deFriedrichshafen, Baden-Württemberg, Germany
Date Registered: 29 August 2012
Last active: 3 hours ago
Posts
435
Respect
Forum Rank
Perk Hacker
Primary Group
UGX Administrator
My Groups
More
My Contact & Social Links
More
Personal Quote
Dolphin!
Signature
changed one line of code, bug is fixed


Coming to work on monday morning.
When a bug mysteriously disappears.


:ugxmods: Developer ;)
×
Delta's Groups
UGX Administrator
UGX Team Member
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
UGX V.I.P.
UGX V.I.P.
UGX Chat Moderator Has the ability to mute, kick, or ban chat members for being abusive or breaking the rules of the forum.
UGX Site Moderator Has the ability to issue warnings to users, edit and remove posts from the forum and to move topics to other boards. Upholds the rules of the forum. Moderates Chat Rooms.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
Delta's Contact & Social Linksthe-deltaugxDeltaItsDeltaigDelta igdeltaigdeltaUGX_DeltaDelta#6147Personal Site
And whats the magic line to make the console actually useable?

You know... get rid of the **** spam in the log file.


I also wish there would have been a better dev mode introduced with more info ( especially zones ) - but seems like it's up to a scripter again to make it right :(

Oh and any better insights into fx / image loading would by highly appreciated by anyone here <3 <3 <3


// hope we can put this on the wiki if you are OK with it
broken avatar :(
×
broken avatar :(
Former Treyarch Developer
Location: usSherman Oaks, CA
Date Registered: 23 May 2014
Last active: 2 years ago
Posts
37
Respect
Forum Rank
Legless Crawler
Primary Group
UGX V.I.P.
My Groups
More
My Contact & Social Links
More
Personal Quote
VR Enthusiast
×
SparkyMcSparks's Groups
UGX V.I.P.
UGX V.I.P.
And whats the magic line to make the console actually useable?

You know... get rid of the **** spam in the log file.
What do you mean, certain console information you don't want to see like audio errors?

You can hide/show console channels using the CMDs con_showchannel, con_hidechannel, con_visiblechannellist, and con_channellist

It's pretty intuitive but if you think that would be helpful to have a tutorial mention on I can quickly write it up.

I also wish there would have been a better dev mode introduced with more info ( especially zones ) - but seems like it's up to a scripter again to make it right :(
There is, at least introduced in Black Ops 1 I believe (definitely in Black Ops 2). You can just get a hold of the BO1 or BO2 scripts and port the functionality over, search for zombiemode_debug_zones. I started porting BO2 scripts into WaW but gave up since it was more of a headache despite all the new useful features such as zone debug or only using one zombie spawner for the whole map, working on another zombie mod with less stress.

When you enable it, on top left it should list all the zones and their states. It takes up too many HUD elements though and they all won't show (it uses NewDebugHudElem() which is unlimited but not available in public EXE, can switch it to normal hud element). I suppose someone can just think of a smart way to merge the hud elements but still somehow convey the info.


 
Loading ...