[Change] Improved music handling.
This commit is contained in:
parent
82f724eb04
commit
d5b80c1522
@ -7,7 +7,7 @@
|
|||||||
-- combat - Player just got a hostile on screen.
|
-- combat - Player just got a hostile on screen.
|
||||||
-- idle - Current playing music ran out.
|
-- idle - Current playing music ran out.
|
||||||
--]]--
|
--]]--
|
||||||
|
last = "idle"
|
||||||
function choose(str)
|
function choose(str)
|
||||||
if str == "load" then
|
if str == "load" then
|
||||||
music.load("machina")
|
music.load("machina")
|
||||||
@ -25,10 +25,12 @@ function choose(str)
|
|||||||
music.load("galacticbattle")
|
music.load("galacticbattle")
|
||||||
music.play()
|
music.play()
|
||||||
|
|
||||||
elseif str == "idle" then
|
elseif str == "idle" and last ~= "idle" then
|
||||||
choose(last) -- This should be smarter in the future.
|
choose(last) -- This should be smarter in the future.
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if last ~= "idle" then
|
||||||
last = str -- Save the last string so we can use it.
|
last = str -- Save the last string so we can use it.
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
@ -371,6 +371,8 @@ static int music_luaInit(void) {
|
|||||||
|
|
||||||
music_lua = luaL_newstate();
|
music_lua = luaL_newstate();
|
||||||
|
|
||||||
|
luaL_openlibs(music_lua);
|
||||||
|
|
||||||
lua_loadSpace(music_lua, 1); // Space and time are readonly.
|
lua_loadSpace(music_lua, 1); // Space and time are readonly.
|
||||||
lua_loadTime(music_lua, 1);
|
lua_loadTime(music_lua, 1);
|
||||||
lua_loadRnd(music_lua);
|
lua_loadRnd(music_lua);
|
||||||
|
Loading…
Reference in New Issue
Block a user