Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local rms_is_present = {}
- local rms_skybox = {
- "stars.png",
- "stars.png",
- "rms.png",
- "stars.png",
- "stars.png",
- "stars.png",
- }
- -- When a player runs /rms it should change the sky, send a chat message, and start playing the song
- -- When they do /rms again I want it to set the sky back, send a chat message, and stop the song for
- -- That person only. Having rms_sound be local in the register_chatcommand function breaks it too.
- local function summon_rms(player_name)
- rms_is_present[player_name] = true
- minetest.get_player_by_name(player_name):set_sky({}, "skybox", rms_skybox)
- -- Starts here
- local rms_sound = minetest.sound_play("rms", {
- to_player = player_name,
- gain = 2.0
- })
- end
- local function dismiss_rms(player_name)
- rms_is_present[player_name] = false
- minetest.get_player_by_name(player_name):set_sky({}, "regular", {})
- -- Crash happens here
- minetest.sound_stop(rms_sound)
- end
- minetest.register_on_joinplayer(function(player)
- rms_is_present[player:get_player_name()] = false
- end
- )
- minetest.register_chatcommand("rms", {
- func = function(name, param)
- -- Summon RMS if he isn't already present
- if rms_is_present[name] == false then
- minetest.chat_send_player(name, "*You feel the sudden urge to install Gentoo...*")
- summon_rms(name)
- minetest.after(146, function()
- dismiss_rms(name)
- end
- )
- -- Dismiss RMS if he is present
- else
- minetest.chat_send_player(name, "OH NO! Your proprietary software scared RMS away!")
- dismiss_rms(name)
- end
- end
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement