Skip to content

Commit a73b772

Browse files
committed
Add new examples
1 parent 9fdcd58 commit a73b772

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

models/example-module.lua

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,24 @@ local players_data
1212
local ABS = math.abs
1313
--#endregion
1414

15+
function say_hello()
16+
game.print("Hello")
17+
end
1518

1619
--#region Functions of events
1720

1821
local function on_player_created(event)
1922
local player = game.get_player(event.player_index)
2023
if not (player and player.valid) then return end
2124

22-
player.print("Events of example mod works fine")
25+
global.message_for_new_player = "Events of example mod works fine"
26+
player.print(global.message_for_new_player)
27+
28+
if player.admin then
29+
player.print("\nYou can access to mods by their \"name\" as a prefix for commands. For example: __example-mod__ global.test = 1")
30+
player.print("\nYou can use global functions from mods via console during the game.\nType it in console to try it: /c say_hello()")
31+
player.print("\nAlso, you can read and change mod global data via console during the game.\nType it in console: /c __example-mod__ game.print(serpent.block(global))")
32+
end
2333
end
2434

2535
--#endregion

scenarios/example/models/example-module.lua

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,24 @@ local players_data
1212
local ABS = math.abs
1313
--#endregion
1414

15+
function say_hi()
16+
game.print("Hi")
17+
end
18+
1519

1620
--#region Functions of events
1721

1822
local function on_player_created(event)
1923
local player = game.get_player(event.player_index)
2024
if not (player and player.valid) then return end
2125

22-
player.print("Events of example scenario works fine. Also, scripts of example mod has been disabled!")
26+
global.message_for_new_player = "Events of example scenario works fine. Also, scripts of example mod has been disabled!"
27+
player.print(global.message_for_new_player)
28+
29+
if player.admin then
30+
player.print("\nYou can use global functions from scenarions via console during the game.\nType it in console to try it: /c say_hi()")
31+
player.print("\nAlso, you can read and change global data via console during the game.\nType it in console: /c game.print(serpent.block(global))")
32+
end
2333
end
2434

2535
local function on_game_created_from_scenario(event)

0 commit comments

Comments
 (0)