Skip to content

Commit cdbe04a

Browse files
committed
Turn image to code
1 parent 9d7b3b8 commit cdbe04a

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

_articles/scripting-introduction.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,25 @@ In every single gamemode, a file named addon_game_mode.lua must be present. Whil
5959
- `Precache`, when the game starts and players pick their heroes, the engine will try to load the associated models/particles/sounds to those heroes. If we're dynamically using a resource in Lua before preloading it won't be displayed properly.
6060
- `Activate`, creates the base game mode entity and calls the initialize function.
6161

62-
![img](/images/external/g2pUC-ca4413cc48.png) <br /> Precache function was folded in sublime
62+
```lua
63+
--[[
64+
Basic Barebones
65+
]]
66+
67+
-- Required files to be visible from anywhere
68+
require( 'timers' )
69+
require( 'barebones' )
70+
71+
function Precache( context )
72+
-- Precache things here
73+
end
74+
75+
-- Create the game mode when we activate
76+
function Activate()
77+
GameRules.GameMode = GameMode()
78+
GameRules.GameMode:InitGameMode()
79+
end
80+
```
6381

6482
Using our barebones, you don't need to touch this file apart from very specific situations, and all the core game logic will be coded in gamemode.lua (for older versions it's barebones.lua), which has been already required. We'll call this your *main lua file* from now on.
6583

-13.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)