-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.lua
76 lines (60 loc) · 2.84 KB
/
init.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
dofile_once("mods/akanechan_voice/files/scripts/lib/utilities.lua")
dofile_once("mods/akanechan_voice/files/scripts/global_values.lua")
dofile_once("mods/akanechan_voice/files/scripts/biome_visit_record.lua")
print("akanechan_voice load")
local registered_entity_id = nil
local is_player_dead = false
function OnModInit()
-- 音声ファイルロード
dofile("mods/akanechan_voice/files/scripts/load_extends_voice.lua")
end
function OnPlayerSpawned(player_entity_id)
registered_entity_id = player_entity_id
is_player_dead = false
SoundPlayer:destroySoundPlayer(player_entity_id, AKANECHAN.SOUND_PLAYER_NAME)
AkanechanVoice = SoundPlayer:create(player_entity_id, AKANECHAN.SOUND_PLAYER_NAME, AKANECHAN:SOUND_FILE_STORAGE_NAME())
local loaded = getInternalVariableValue(player_entity_id, "akanechan_voice.loaded?", "value_bool") or false
if not loaded then
-- spawn時にアクションを行いたいため、xml拡張ではなくentityに対しての代入となっている
EntityLoadToEntity("mods/akanechan_voice/files/entities/extends/extend_player_voices.xml", player_entity_id)
addNewInternalVariable(player_entity_id, "akanechan_voice.loaded?", "value_bool", true)
addNewInternalVariable(player_entity_id, AKANECHAN.CURRENT_LOCATION, "value_string", AKANECHAN.BIOME_LOCATIONS.START_POINT)
InitVisitedBiomes()
RegisterEnterNewBiome(AkanechanVoice)
end
end
function OnWorldPreUpdate()
if is_player_dead then
return
end
local current_player_entity = GetPlayerEntity()
local is_transformed_player = current_player_entity ~= registered_entity_id and current_player_entity ~= nil
if is_transformed_player then
ReregisterSoundPlayer(current_player_entity)
RegisterEnterNewBiome(AkanechanVoice)
addNewInternalVariable(current_player_entity, AKANECHAN.CURRENT_LOCATION, "value_string", BiomeMapGetName())
if FindSheepPlayer() then
dofile('mods/akanechan_voice/files/scripts/player/sheep.lua')
end
end
if AkanechanVoice ~= nil then
setInternalVariableValue(current_player_entity, AKANECHAN.CURRENT_LOCATION, "value_string", BiomeMapGetName())
SoundPlayer:playSound(AkanechanVoice)
end
end
function OnPlayerDied()
is_player_dead = true
end
function ReregisterSoundPlayer(current_player_entity)
SoundPlayer:destroySoundPlayer(current_player_entity, AKANECHAN.SOUND_PLAYER_NAME)
SoundPlayer:destroySoundPlayer(registered_entity_id, AKANECHAN.SOUND_PLAYER_NAME)
AkanechanVoice = SoundPlayer:create(current_player_entity, AKANECHAN.SOUND_PLAYER_NAME, AKANECHAN:SOUND_FILE_STORAGE_NAME())
registered_entity_id = GetPlayerEntity()
end
function RegisterEnterNewBiome(entity_id)
EntityAddComponent2(entity_id, "LuaComponent", {
script_source_file = "mods/akanechan_voice/files/scripts/player/enter_new_biome.lua",
execute_every_n_frame = 60,
})
end
print("akanechan_voice loaded")