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

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 » Fri Sep 01, 2017 23:54

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.
 

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 » Sat Sep 02, 2017 17:17

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?
 

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

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

by srifqi » Sun Sep 03, 2017 00:57

Your syntaxes are not correct. Note that Minetest uses lua as Modding API language.
I'm from Indonesia! Saya dari Indonesia!
Terjemahkan Minetest!
Mods by me. Modifikasi oleh saya.

Pronounce my nick as in: es-rifqi (IPA: /es rifˈki/)
 

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 » Sun Sep 03, 2017 16:43

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.
 

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 » Sun Sep 03, 2017 19:11

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.
 

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

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

by Wuzzy » Mon Sep 04, 2017 12:55

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
My creations. I gladly accept bitcoins: 17fsUywHxeMHKG41UFfu34F1rAxZcrVoqH
 


Return to Modding Discussion



Who is online

Users browsing this forum: No registered users and 1 guest