Sun and Moon Feature.

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

by Krock » Sat Mar 08, 2014 19:18

nfsprodriver wrote:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.after(0,set_sky(nil,skybox,{"a.png","b.png","c.png","d.png","e.png","f.png"}))

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_on_joinplayer(function(player)
    minetest.after(0, function()
        player:set_sky(bgcolor, type, {texture names})
    end)
end)

That's how I understood the lua API of minetest
Last edited by Krock on Sat Mar 08, 2014 19:18, edited 1 time in total.
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
nfsprodriver
Member
 
Posts: 41
Joined: Sun Nov 10, 2013 18:25

by nfsprodriver » Sat Mar 08, 2014 19:27

Sounds good! Now I allways got that problem:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
20:22:35: ERROR[main]: ServerError: E:\minetest-0.4.9-dev-win64\bin\..\mods\skybox\init.lua:3: bad argument #2 to 'set_sky' (string expected, got nil)
20:22:35: ERROR[main]: stack traceback:
20:22:35: ERROR[main]:     [C]: in function 'set_sky'
20:22:35: ERROR[main]:     E:\minetest-0.4.9-dev-win64\bin\..\mods\skybox\init.lua:3: in function 'func'
20:22:35: ERROR[main]:     E:\minetest-0.4.9-dev-win64\bin\..\builtin/misc.lua:17: in function <E:\minetest-0.4.9-dev-win64\bin\..\builtin/misc.lua:9>
20:22:35: ERROR[main]:     ...inetest-0.4.9-dev-win64\bin\..\builtin/misc_register.lua:348: in function <...inetest-0.4.9-dev-win64\bin\..\builtin/misc_register.lua:336>

So, what do I have fo enter in the set_sky section?
Last edited by nfsprodriver on Sat Mar 08, 2014 19:33, edited 1 time in total.
 

User avatar
RealBadAngel
Member
 
Posts: 556
Joined: Wed Jul 18, 2012 16:30

by RealBadAngel » Sun Mar 09, 2014 07:27

nfsprodriver wrote:Sounds good! Now I allways got that problem:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
20:22:35: ERROR[main]: ServerError: E:\minetest-0.4.9-dev-win64\bin\..\mods\skybox\init.lua:3: bad argument #2 to 'set_sky' (string expected, got nil)
20:22:35: ERROR[main]: stack traceback:
20:22:35: ERROR[main]:     [C]: in function 'set_sky'
20:22:35: ERROR[main]:     E:\minetest-0.4.9-dev-win64\bin\..\mods\skybox\init.lua:3: in function 'func'
20:22:35: ERROR[main]:     E:\minetest-0.4.9-dev-win64\bin\..\builtin/misc.lua:17: in function <E:\minetest-0.4.9-dev-win64\bin\..\builtin/misc.lua:9>
20:22:35: ERROR[main]:     ...inetest-0.4.9-dev-win64\bin\..\builtin/misc_register.lua:348: in function <...inetest-0.4.9-dev-win64\bin\..\builtin/misc_register.lua:336>

So, what do I have fo enter in the set_sky section?


Heres the code:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_on_joinplayer(function(player)
    minetest.after(0, function()
        textures ={
        "pink_planet_pos_y.png",
        "pink_planet_neg_y.png",
        "pink_planet_pos_z.png",
        "pink_planet_neg_z.png",   
        "pink_planet_neg_x.png",
        "pink_planet_pos_x.png",
        }
       
        player:set_sky({r=0, g=0, b=0, a=0},"skybox", textures)
    end)
end)
 

User avatar
nfsprodriver
Member
 
Posts: 41
Joined: Sun Nov 10, 2013 18:25

by nfsprodriver » Sun Mar 09, 2014 16:55

Thank you very much!!! For now it works. Perfect. How do you create mods depending by time, so, I want to have more skies for day, dawn, night, etc.? So, how can I define time-borrows?

I allready got this:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local timer = 0
minetest.register_globalstep(function(dtime)
if timer<5 then
        timer = timer+dtime
        return
    end
    timer = 0
if minetest.get_timeofday() > 0.3 and minetest.get_timeofday() < 0.7 then
minetest.register_on_joinplayer(function(noon)
    minetest.after(0, function()
        textures ={
        "sky1.png",
        "sky2.png",
        "sky3.png",
        "sky4.png",   
        "sky5.png",
        "sky6.png",
        }
        noon:set_sky({r=0, g=0, b=0, a=0},"skybox", textures)
    end)
end)

elseif minetest.get_timeofday() < 0.3 or minetest.get_timeofday() > 0.7 then
minetest.register_on_joinplayer(function(afternoon)
    minetest.after(0, function()
        textures ={
        "sky2.png",
        "sky1.png",
        "sky3.png",
        "sky4.png",   
        "sky5.png",
        "sky6.png",
        }
        afternoon:set_sky({r=0, g=0, b=0, a=0},"skybox", textures)
    end)
end)
end
end)

But there's no difference between the times of the day. What do I make wrong?
Last edited by nfsprodriver on Sun Mar 09, 2014 22:24, edited 1 time in total.
 

User avatar
RealBadAngel
Member
 
Posts: 556
Joined: Wed Jul 18, 2012 16:30

by RealBadAngel » Mon Mar 10, 2014 07:16

You are using minetest.register_on_joinplayer function which is called only when a player joins the server,,,,
Also it is unlikely that objects noon or afternoon will join it ;)

You shall iterate over all connected players on skybox change event and set it for everyone.
Also you shall have flag which skybox is being active.
if it is night and daytime skybox is active then trigger the change to nightime one, and vice versa.
Otherwise it will be setting skyboxes all time.
Last edited by RealBadAngel on Mon Mar 10, 2014 07:25, edited 1 time in total.
 

User avatar
nfsprodriver
Member
 
Posts: 41
Joined: Sun Nov 10, 2013 18:25

by nfsprodriver » Mon Mar 10, 2014 18:29

That really makes sense. Do you think of
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.env:somefunction(somearguments)

?
Or should I rewrite the globalstep to my specific functions? And do I really need the after-code?

I'm sorry about all these for you simple questions, but I'm just a beginner about mods, because this is "my" first and I only have some Greenfoot knowledge from my half-year-informatic lessons. I'm still trying understanding the minetest lua commands.

Thanks for all of your help and patience!!!
 

Previous

Return to Minetest Features

Who is online

Users browsing this forum: No registered users and 14 guests

cron