How do I change the color of the sky, the moon, and the sun?

Post Reply
CC10
Member
Posts: 19
Joined: Sun Aug 28, 2016 21:25
GitHub: CC10MAGIC
In-game: CC10

How do I change the color of the sky, the moon, and the sun?

by CC10 » Post

I am trying to make a texture pack/subgame in which I would like to modify the color of the sky. I understand that the color of the sky is part of code of the game and not a texture. I would like to know where is the code to modify the sky and how I can integrate it into my texture pack/subgame. I would also like to know whether the sun and the moon have a texture. If they do, where can I find the default textures to modify them, and if they don't, what part of the code are they in?
Thanks in advance.
Check out my emerald mod: viewtopic.php?f=11&t=15485

CC10
Member
Posts: 19
Joined: Sun Aug 28, 2016 21:25
GitHub: CC10MAGIC
In-game: CC10

Re: How do I change the color of the sky, the moon, and the

by CC10 » Post

I have found that there is a function 'player:set_sky' that allows you to change how the player see the sky. I have tried using it to change the color of the sky depending on the time of the day in the following code in my init.lua file.

minetest.after(0)
get time_of_day,
if time_of_day = 0,
player:set_sky({r=0, g=0, b=0}, plain),
end

However, when I try to launch a world with the mod that contains this code enabled, it outputs the following error:
2017-09-02 11:14:32: WARNING[Main]: BanManager: creating /home/cc10/.minetest/worlds/TestBlack&White/ipban.txt
2017-09-02 11:14:32: WARNING[Main]: NodeDefManager: Ignoring CONTENT_IGNORE redefinition
2017-09-02 11:14:32: ERROR[Main]: ModError: Failed to load and run script from /usr/share/minetest/games/black&white/mods/blackwhite/init.lua:
2017-09-02 11:14:32: ERROR[Main]: ...hare/minetest/games/black&white/mods/blackwhite/init.lua:2: '=' expected near 'time_of_day'
2017-09-02 11:14:32: ERROR[Main]: Check debug.txt for details.

What did I do wrong and how can I rewrite my code so that it does what I mentioned above?
Check out my emerald mod: viewtopic.php?f=11&t=15485

User avatar
srifqi
Member
Posts: 570
Joined: Sat Jun 28, 2014 04:31
GitHub: srifqi
IRC: srifqi
In-game: srifqi
Location: Indonesia

Re: How do I change the color of the sky, the moon, and the

by srifqi » Post

Your syntaxes are not correct. Note that Minetest uses lua as Modding API language.
Saya dari Indonesia! · Terjemahkan Minetest! · my mods · My nickname in IPA: /es.rif.qi/

CC10
Member
Posts: 19
Joined: Sun Aug 28, 2016 21:25
GitHub: CC10MAGIC
In-game: CC10

Re: How do I change the color of the sky, the moon, and the

by CC10 » Post

srifqi wrote:Your syntaxes are not correct. Note that Minetest uses lua as Modding API language.
I know Minetest uses lua as Modding API, but I was experimenting with code. I am no pro programmer, this is the first time I try to make something happen when the game starts. Searching around and experimenting, I managed to make this piece of code which works:
minetest.register_on_joinplayer(function(player)
player:set_sky(000000, "plain", {})
end)
Right now, it turns the sky black and I can still see the clouds. Is there a way to change the color of the sky depending on the time of the day? Also, how do I make the sun and moon show up in my custom sky? I can't see them anymore.
Check out my emerald mod: viewtopic.php?f=11&t=15485

CC10
Member
Posts: 19
Joined: Sun Aug 28, 2016 21:25
GitHub: CC10MAGIC
In-game: CC10

Re: How do I change the color of the sky, the moon, and the

by CC10 » Post

To all future replies: Although I have not succeeded in accomplishing what I was trying to do, I am satisfied with my current results (a black sky with the clouds still showing). So case closed. However, during my search for how do this I have learned that it is not easy to edit the sky while keeping the sun and the moon. And there is no accessible "default" sun and moon textures. I hope in the future both of these issues will be solved and/or added to the API so that it's easier to make a textures pack in which you edit the sky.
Check out my emerald mod: viewtopic.php?f=11&t=15485

User avatar
Wuzzy
Member
Posts: 4804
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: How do I change the color of the sky, the moon, and the

by Wuzzy » Post

Actually, you can change the appearance of sun and moon. It just happens that the default sun and moon are generated from code alone and not from an image.

To change sun and moon, you just have to add textures with the correct file names.

See also: https://github.com/minetest/minetest/bl ... _packs.txt

User avatar
sirrobzeroone
Member
Posts: 593
Joined: Mon Jul 16, 2018 07:56
GitHub: sirrobzeroone
Contact:

Re: How do I change the color of the sky, the moon, and the sun?

by sirrobzeroone » Post

I got a hit on this topic when hunting for the same info and after trawlling for a bit found the relevant section in the api. I know this is an old topic but someone else might also stumble on this topic and need the info:

You want the below as I know edits to the api doc will make the direct link I've included wrong over time, do a find on the git page for the below.

Code: Select all

set_sky(sky_parameters)
https://github.com/minetest/minetest/bl ... .txt#L6599

pretty sure you need these settings inside a "minetest.register_on_joinplayer()"....other than that I'll try and post back with a working example once I have one...

Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests