Tuesday, September 1, 2015

Dota 2 Workshop Tools modding tutorial part 2. (starting scripting)

This part of the tutorial is about how to actually edit the script of your Dota 2 mod/addon


1. Getting an editor

We'll need a decent editor - I would recommend using the program Sublime Text.


This is the tutorial I used to install Sublime Text:

https://moddota.com/forums/discussion/135/beginners-guide-to-dota-scripting



2. Opening addon_game_mode.lua

When we built the map in the previous tutorial it created 2 directories for our project.

C:\Program Files (x86)\Steam\steamapps\common\dota 2 beta\game\dota_addons\d2tutorial\
and
C:\Program Files (x86)\Steam\steamapps\common\dota 2 beta\content\dota_addons\d2tutorial\

We're going to use the game directory because this is where you edit the scripts

The file we're going to edit is addon_game_mode.lua. (was created automatically)

it should be located in
...\dota 2 beta\game\dota_addons\d2tutorial\scripts\vscripts


3. Actually scripting guys!
3.1
This is what you should see:

3.2
Delete this part (useless for us)



3.3
Add this line





What this line does is checking with the game when a player picked an hero .

this part ("dota_player_pick_hero") is the specific event, Dota has many events you can use to build your mod .

List of the events
https://developer.valvesoftware.com/wiki/Dota_2_Workshop_Tools/Scripting/Built-In_Engine_Events

this part (CAddonTemplateGameMode, "OnNPCSpawned") determins the name of the function that will run when the event happens

3.4
Lets add the function that level up the hero when he spawns


















Save the file ...

4. Lets see how it works!

In the Asset Browser open the console. (or press ~)


to re load the scrip we just wrote type in the console:
script_reload

and then to load the map we built before type:
dota_launch_custom_game d2tutorial d2map



Now it should load the map in the game. start the game like a normal lobby and pick a hero.



to see the console type ~ 


No comments:

Post a Comment