Posts
86
Respect
34Add +1
Forum Rank
Rotting Walker
Primary Group
Community Mapper
Login Issues
Forgot password?Activate Issues
Account activation email not received? Wrong account activation email used?Other Problems?
Contact Support - Help Center Get help on the UGX Discord. Join it now!Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager. |
function my_function_name_here()notice the parts:
{
}
#using scripts\codescripts\struct;You should see:
#using scripts\shared\array_shared;
#using scripts\shared\callbacks_shared;
#using scripts\shared\clientfield_shared;
#using scripts\shared\compass;
#using scripts\shared\exploder_shared;
#using scripts\shared\flag_shared;
#using scripts\shared\laststand_shared;
#using scripts\shared\math_shared;
#using scripts\shared\scene_shared;
#using scripts\shared\util_shared;
#insert scripts\shared\shared.gsh;
#insert scripts\shared\version.gsh;
#insert scripts\zm\_zm_utility.gsh;
#using scripts\zm\_load;
#using scripts\zm\_zm;
#using scripts\zm\_zm_audio;
#using scripts\zm\_zm_powerups;
#using scripts\zm\_zm_utility;
#using scripts\zm\_zm_weapons;
#using scripts\zm\_zm_zonemgr;
#using scripts\shared\ai\zombie_utility;
//Perks
#using scripts\zm\_zm_pack_a_punch;
#using scripts\zm\_zm_pack_a_punch_util;
#using scripts\zm\_zm_perk_additionalprimaryweapon;
#using scripts\zm\_zm_perk_doubletap2;
#using scripts\zm\_zm_perk_deadshot;
#using scripts\zm\_zm_perk_juggernaut;
#using scripts\zm\_zm_perk_quick_revive;
#using scripts\zm\_zm_perk_sleight_of_hand;
#using scripts\zm\_zm_perk_staminup;
//Powerups
#using scripts\zm\_zm_powerup_double_points;
#using scripts\zm\_zm_powerup_carpenter;
#using scripts\zm\_zm_powerup_fire_sale;
#using scripts\zm\_zm_powerup_free_perk;
#using scripts\zm\_zm_powerup_full_ammo;
#using scripts\zm\_zm_powerup_insta_kill;
#using scripts\zm\_zm_powerup_nuke;
//#using scripts\zm\_zm_powerup_weapon_minigun;
//Traps
#using scripts\zm\_zm_trap_electric;
#using scripts\zm\zm_usermap;
//*****************************************************************************
// MAIN
//*****************************************************************************
function main()
{
zm_usermap::main();
level._zombie_custom_add_weapons =&custom_add_weapons;
//Setup the levels Zombie Zone Volumes
level.zones = ;
level.zone_manager_init_func =&usermap_test_zone_init;
init_zones[0] = "start_zone";
level thread zm_zonemgr::manage_zones( init_zones );
level.pathdist_type = PATHDIST_ORIGINAL;
}
function usermap_test_zone_init()
{
level flag::init( "always_on" );
level flag::set( "always_on" );
}
function custom_add_weapons()
{
zm_weapons::load_weapon_spec_from_table("gamedata/weapons/zm/zm_levelcommon_weapons.csv", 1);
}
//*****************************************************************************Before we even get to calling it, let's give it something simple it can actually do, since currently it does nothing. Let's use a very common Engine Function which we can call from anywhere. The engine function I'm talking about is IPrintLnBold():
// MAIN
//*****************************************************************************
function main()
{
zm_usermap::main();
level._zombie_custom_add_weapons =&custom_add_weapons;
//Setup the levels Zombie Zone Volumes
level.zones = ;
level.zone_manager_init_func =&usermap_test_zone_init;
init_zones[0] = "start_zone";
level thread zm_zonemgr::manage_zones( init_zones );
level.pathdist_type = PATHDIST_ORIGINAL;
}
function my_awesome_function()
{
}
function usermap_test_zone_init()
{
level flag::init( "always_on" );
level flag::set( "always_on" );
}
function custom_add_weapons()
{
zm_weapons::load_weapon_spec_from_table("gamedata/weapons/zm/zm_levelcommon_weapons.csv", 1);
}
void IPrintLnBold()You can find all the Engine functions in the Modme ScriptDocs. These can be used anywhere. The IPrintLnBold() is simple. It takes one argument: a string of text, and when the line is read by the computer it will print that text to the screen in-game. This is very useful for testing scripts, as it let's us see where the computer is reading lines and where it isn't.
function my_awesome_function()notice:
{
IPrintLnBold("Hello Everybody");
}
********************************************************************************You see, when computers read .gsc code, they ignore spaces and newlines. That way I can have as many spaces and newlines to make myself comfortable. However this means we must manually define where the line ends using a ; or launcher will keep reading everything as one line and get confused.
UNRECOVERABLE ERROR:
^1SCRIPT ERROR: No generated data for 'scripts/zm/zm_yourmapname.gsc'
ERR(0) scripts/zm/zm_yourmapname.gsc (76,1) in "my_awesome_function()" : syntax error, unexpected TOKEN_RIGHT_CURLY : }
Linker will now terminate.
********************************************************************************
my_awesome_function();if we place this line inside a function that we know will be run before the start of the game, we can effectively call it:
function main()There's another way to call a function though, and that's called threading. Bascially if we do the same thing except type the word thread before it, we can thread the function:
{
zm_usermap::main();
level._zombie_custom_add_weapons =&custom_add_weapons;
//Setup the levels Zombie Zone Volumes
level.zones = ;
level.zone_manager_init_func =&usermap_test_zone_init;
init_zones[0] = "start_zone";
level thread zm_zonemgr::manage_zones( init_zones );
level.pathdist_type = PATHDIST_ORIGINAL;
my_awesome_function();
}
function my_awesome_function()
{
IPrintLnBold("Hello Everybody");
}
thread my_awesome_function();but what does it mean to thread? This can be a difficult concept to understand immediately. Basically when we thread, we split the computer up into two instances: one which will jump to and start reading the function we threaded; and the other which will keep on reading the lines below it as normal. if we don't thread however, then the computer will see the function call, jump to the function, finish reading that function, then jump back to where it was it the other function it was in and keep reading as normal.
level waittill("all_players_connected");notice:
function main()We're almost ready to run the code and see the results. One more thing though.
{
zm_usermap::main();
level._zombie_custom_add_weapons =&custom_add_weapons;
//Setup the levels Zombie Zone Volumes
level.zones = ;
level.zone_manager_init_func =&usermap_test_zone_init;
init_zones[0] = "start_zone";
level thread zm_zonemgr::manage_zones( init_zones );
level.pathdist_type = PATHDIST_ORIGINAL;
level waittill("all_players_connected");
thread my_awesome_function();
}
function my_awesome_function()
{
IPrintLnBold("Hello Everybody");
}
wait(10);notice:
function main()Now if we save, link in launcher, and run the map, we should see our line print to the screen shortly after starting the game!
{
zm_usermap::main();
level._zombie_custom_add_weapons =&custom_add_weapons;
//Setup the levels Zombie Zone Volumes
level.zones = ;
level.zone_manager_init_func =&usermap_test_zone_init;
init_zones[0] = "start_zone";
level thread zm_zonemgr::manage_zones( init_zones );
level.pathdist_type = PATHDIST_ORIGINAL;
level waittill("all_players_connected");
wait(10);
thread my_awesome_function();
}
function my_awesome_function()
{
IPrintLnBold("Hello Everybody");
}