Help me in my Radio Mod

User avatar
Mihobre
Member
 
Posts: 101
Joined: Tue Oct 30, 2012 08:45

Help me in my Radio Mod

by Mihobre » Sun Apr 14, 2013 11:27

Someone please help me, Radio mod is my first mod, its basically edited Noteblock from Mesecons. I already finished the init.lua file and tried to run Minetest-0.4.5 but it says:
ModError: Failed to load and run C:\Users\Oceanic Skipjack\Desktop\Howie\games\minetest-0.4.5\bin\..\mods\minetest\radio\init.lua

and debug says:
19:15:02: ERROR[main]: ========== ERROR FROM LUA ===========
19:15:02: ERROR[main]: Failed to load and run script from
19:15:02: ERROR[main]: C:\Users\Oceanic Skipjack\Desktop\Howie\games\minetest-0.4.5\bin\..\mods\minetest\radio\init.lua:
19:15:02: ERROR[main]: ...k\Desktop\Howie\games\minetest-0.4.5\bin\..\mods\minetest\radio\init.lua:14: unexpected symbol near '}'
19:15:02: ERROR[main]: =======END OF ERROR FROM LUA ========
19:15:02: ERROR[main]: Server: Failed to load and run C:\Users\Oceanic Skipjack\Desktop\Howie\games\minetest-0.4.5\bin\..\mods\minetest\radio\init.lua
19:15:02: ERROR[main]: ModError: Failed to load and run C:\Users\Oceanic Skipjack\Desktop\Howie\games\minetest-0.4.5\bin\..\mods\minetest\radio\init.lua

init.lua:
minetest.register_node("radio:radio", {
description = "Radio",
tiles = {"radio_front"},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
drawtype = "signlike",
paramtype="light",
after_place_node = function(pos)
minetest.env:add_node(pos, {name="radio:radio", param2=0})
end,
on_punch = function (pos, node) -- change sound when punched
local param2 = node.param2+1
if param2==16 then param2=0 end
minetest.env:add_node(pos, {name = node.name, param2 = param2})
})
})

minetest.register_craft({
output = '"radio_radio" 1',
recipe = {
{"default:sign", "default:sign", "default:sign"},
{"default:sign", "default:mese_crystal", "default:sign"},
{"default:sign", "default:sign", "default:sign"},
}
})

radio.radio_play = function (pos, param2)
local soundname
if param2==0 then
soundname="cuintha"
elseif param2==1 then
soundname="demons_rebirth"
elseif param2==2 then
soundname="divine_knights"
elseif param2==3 then
soundname="endings_and_beginnings"
elseif param2==4 then
soundname="floating_island_githrau"
elseif param2==5 then
soundname="flying_moon_creature"
elseif param2==6 then
soundname="fortuna_plains"
elseif param2==7 then
soundname="ghost_wolf_thirio"
elseif param2==8 then
soundname="lake_of_viridia"
elseif param2==9 then
soundname="mecha_soul_4000"
elseif param2==10 then
soundname="of_epic_proportions"
elseif param2==11 then
soundname="quest_for_immortality_1"
elseif param2==12 then
soundname="quest_for_immortality_2"
elseif param2==13 then
soundname="quest_for_immortality_3"
elseif param2==14 then
soundname="the_raining_cave"
elseif param2==15 then
soundname="tornado"
end


So someone please help me. PM me if you found a solution as much as possible. Thank you in advance. I will give credit for the person who helps me.
Last edited by Mihobre on Sun Apr 14, 2013 11:29, edited 1 time in total.
I wanna fly!!!
I wanna have feathery wings of silver, blue, and white!!!
I wanna soar high and touch the sky!!!
I wanna fly!!!
 

User avatar
BlockMen
Member
 
Posts: 768
Joined: Fri Mar 01, 2013 17:24
GitHub: BlockMen

by BlockMen » Sun Apr 14, 2013 11:48

Mihobre wrote:Someone please help me, Radio mod is my first mod, its basically edited Noteblock from Mesecons. I already finished the init.lua file and tried to run Minetest-0.4.5 but it says:

So someone please help me. PM me if you found a solution as much as possible. Thank you in advance. I will give credit for the person who helps me.


There are 3 things:
1.) use "end" instead of "})" to end function "on_punch"


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_node("radio:radio", {
    description = "Radio",
    tiles = {"radio_front"},
    groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
    drawtype = "signlike",
    paramtype="light",
    after_place_node = function(pos)
        minetest.env:add_node(pos, {name="radio:radio", param2=0})
    end,
    on_punch = function (pos, node) -- change sound when punched
        local param2 = node.param2+1
        if param2==16 then param2=0 end
        minetest.env:add_node(pos, {name = node.name, param2 = param2})
     end
})


2.) define functions like 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
function radio_play (pos, param2)


3.) end the function with "end"


Complete 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_node("radio:radio", {
    description = "Radio",
    tiles = {"radio_front"},
    groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
    drawtype = "signlike",
    paramtype="light",
    after_place_node = function(pos)
        minetest.env:add_node(pos, {name="radio:radio", param2=0})
    end,
    on_punch = function (pos, node) -- change sound when punched
        local param2 = node.param2+1
        if param2==16 then param2=0 end
        minetest.env:add_node(pos, {name = node.name, param2 = param2})
     end
})

minetest.register_craft({
    output = '"radio_radio" 1',
    recipe = {
        {"default:sign", "default:sign", "default:sign"},
        {"default:sign", "default:mese_crystal", "default:sign"},
        {"default:sign", "default:sign", "default:sign"},
     }
})

function radio_play (pos, param2)
    local soundname
    if param2==0 then
            soundname="cuintha"
    elseif param2==1 then
        soundname="demons_rebirth"
    elseif param2==2 then
        soundname="divine_knights"
    elseif param2==3 then
        soundname="endings_and_beginnings"
    elseif param2==4 then
        soundname="floating_island_githrau"
    elseif param2==5 then
        soundname="flying_moon_creature"
    elseif param2==6 then
        soundname="fortuna_plains"
    elseif param2==7 then
        soundname="ghost_wolf_thirio"
    elseif param2==8 then
        soundname="lake_of_viridia"
    elseif param2==9 then
        soundname="mecha_soul_4000"
    elseif param2==10 then
        soundname="of_epic_proportions"
    elseif param2==11 then
        soundname="quest_for_immortality_1"
    elseif param2==12 then
        soundname="quest_for_immortality_2"
    elseif param2==13 then
        soundname="quest_for_immortality_3"
    elseif param2==14 then
        soundname="the_raining_cave"
    elseif param2==15 then
        soundname="tornado"
    end
end
Last edited by BlockMen on Sun Apr 14, 2013 11:49, edited 1 time in total.
 

User avatar
Evergreen
Member
 
Posts: 2131
Joined: Sun Jan 06, 2013 01:22
GitHub: 4Evergreen4
IRC: EvergreenTree
In-game: Evergreen

by Evergreen » Sun Apr 14, 2013 11:50

One thing, if this is a good mod, you should make it a 3d model of a radio.
"Help! I searched for a mod but I couldn't find it!"
http://krock-works.16mb.com/MTstuff/modSearch.php
 

User avatar
Mihobre
Member
 
Posts: 101
Joined: Tue Oct 30, 2012 08:45

by Mihobre » Mon Apr 15, 2013 12:43

BlockMen wrote:
Mihobre wrote:Someone please help me, Radio mod is my first mod, its basically edited Noteblock from Mesecons. I already finished the init.lua file and tried to run Minetest-0.4.5 but it says:

So someone please help me. PM me if you found a solution as much as possible. Thank you in advance. I will give credit for the person who helps me.


There are 3 things:
1.) use "end" instead of "})" to end function "on_punch"


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_node("radio:radio", {
    description = "Radio",
    tiles = {"radio_front"},
    groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
    drawtype = "signlike",
    paramtype="light",
    after_place_node = function(pos)
        minetest.env:add_node(pos, {name="radio:radio", param2=0})
    end,
    on_punch = function (pos, node) -- change sound when punched
        local param2 = node.param2+1
        if param2==16 then param2=0 end
        minetest.env:add_node(pos, {name = node.name, param2 = param2})
     end
})


2.) define functions like 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
function radio_play (pos, param2)


3.) end the function with "end"


Complete 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_node("radio:radio", {
    description = "Radio",
    tiles = {"radio_front"},
    groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
    drawtype = "signlike",
    paramtype="light",
    after_place_node = function(pos)
        minetest.env:add_node(pos, {name="radio:radio", param2=0})
    end,
    on_punch = function (pos, node) -- change sound when punched
        local param2 = node.param2+1
        if param2==16 then param2=0 end
        minetest.env:add_node(pos, {name = node.name, param2 = param2})
     end
})

minetest.register_craft({
    output = '"radio_radio" 1',
    recipe = {
        {"default:sign", "default:sign", "default:sign"},
        {"default:sign", "default:mese_crystal", "default:sign"},
        {"default:sign", "default:sign", "default:sign"},
     }
})

function radio_play (pos, param2)
    local soundname
    if param2==0 then
            soundname="cuintha"
    elseif param2==1 then
        soundname="demons_rebirth"
    elseif param2==2 then
        soundname="divine_knights"
    elseif param2==3 then
        soundname="endings_and_beginnings"
    elseif param2==4 then
        soundname="floating_island_githrau"
    elseif param2==5 then
        soundname="flying_moon_creature"
    elseif param2==6 then
        soundname="fortuna_plains"
    elseif param2==7 then
        soundname="ghost_wolf_thirio"
    elseif param2==8 then
        soundname="lake_of_viridia"
    elseif param2==9 then
        soundname="mecha_soul_4000"
    elseif param2==10 then
        soundname="of_epic_proportions"
    elseif param2==11 then
        soundname="quest_for_immortality_1"
    elseif param2==12 then
        soundname="quest_for_immortality_2"
    elseif param2==13 then
        soundname="quest_for_immortality_3"
    elseif param2==14 then
        soundname="the_raining_cave"
    elseif param2==15 then
        soundname="tornado"
    end
end

by complete code do you mean, edited and works properly?
I wanna fly!!!
I wanna have feathery wings of silver, blue, and white!!!
I wanna soar high and touch the sky!!!
I wanna fly!!!
 

User avatar
BlockMen
Member
 
Posts: 768
Joined: Fri Mar 01, 2013 17:24
GitHub: BlockMen

by BlockMen » Mon Apr 15, 2013 15:02

Mihobre wrote:by complete code do you mean, edited and works properly?


yes
 

User avatar
Mihobre
Member
 
Posts: 101
Joined: Tue Oct 30, 2012 08:45

by Mihobre » Wed Apr 17, 2013 05:37

BlockMen wrote:
Mihobre wrote:by complete code do you mean, edited and works properly?


yes

Thank you, Thank you very much! I appreciate it alot! :D
I wanna fly!!!
I wanna have feathery wings of silver, blue, and white!!!
I wanna soar high and touch the sky!!!
I wanna fly!!!
 

User avatar
Mihobre
Member
 
Posts: 101
Joined: Tue Oct 30, 2012 08:45

by Mihobre » Fri Apr 19, 2013 15:16

new problem: when placed, turns to nothing but a flat plane with random color
I wanna fly!!!
I wanna have feathery wings of silver, blue, and white!!!
I wanna soar high and touch the sky!!!
I wanna fly!!!
 

User avatar
Zeg9
Member
 
Posts: 608
Joined: Fri Sep 21, 2012 11:02

by Zeg9 » Fri Apr 19, 2013 17:53

I think:
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
tiles = {"radio_front"},

Should be:
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
tiles = {"radio_front.png"},
I made a few (a lot of?) mods for minetest: here is a list.
See also the MT-Faithful texture pack (work in progress).
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Fri Apr 19, 2013 18:57

Zeg9 wrote:I think:
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
tiles = {"radio_front"},

Should be:
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
tiles = {"radio_front.png"},

lua-api.txt says that both should work. However, the stripped out file extention is broken.
 

User avatar
Mihobre
Member
 
Posts: 101
Joined: Tue Oct 30, 2012 08:45

by Mihobre » Sat Apr 20, 2013 14:11

Zeg9 wrote:I think:
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
tiles = {"radio_front"},

Should be:
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
tiles = {"radio_front.png"},

thank pics work, but when I place it it appears at top then i left click it it moves to another position in a box, and oh, because you mentioned file extensions, i am also writing file extensions to the sounds because sounds don't play, and i might try to change it to nodebox first
I wanna fly!!!
I wanna have feathery wings of silver, blue, and white!!!
I wanna soar high and touch the sky!!!
I wanna fly!!!
 

User avatar
BlockMen
Member
 
Posts: 768
Joined: Fri Mar 01, 2013 17:24
GitHub: BlockMen

by BlockMen » Sat Apr 20, 2013 15:37

Mihobre wrote:thank pics work, but when I place it it appears at top then i left click it it moves to another position in a box, and oh, because you mentioned file extensions, i am also writing file extensions to the sounds because sounds don't play, and i might try to change it to nodebox first


1.) If you not want it look like a sign you should change 'drawtype = "signlike"' to nodebox

2.) you shouldnt use param2 of the node for your songs index. use "node metadata" instead (http://dev.minetest.net/NodeMetaRef)

3.) for playing sounds put *.ogg-files in a "sounds" folder in your mod. then you can easily play them by using minetest.sound_play()
 

User avatar
Mihobre
Member
 
Posts: 101
Joined: Tue Oct 30, 2012 08:45

by Mihobre » Wed May 08, 2013 12:24

BlockMen wrote:
Mihobre wrote:thank pics work, but when I place it it appears at top then i left click it it moves to another position in a box, and oh, because you mentioned file extensions, i am also writing file extensions to the sounds because sounds don't play, and i might try to change it to nodebox first


1.) If you not want it look like a sign you should change 'drawtype = "signlike"' to nodebox

2.) you shouldnt use param2 of the node for your songs index. use "node metadata" instead (http://dev.minetest.net/NodeMetaRef)

3.) for playing sounds put *.ogg-files in a "sounds" folder in your mod. then you can easily play them by using minetest.sound_play()

I am to stupid and inexperienced to do something like that, if someone can pleae help me, or i will cancel mod and some other guy will continue. (I hope someone do this and like when it is clicked, it shows screen with buttons like 1-some number and an on/off button)
I wanna fly!!!
I wanna have feathery wings of silver, blue, and white!!!
I wanna soar high and touch the sky!!!
I wanna fly!!!
 

User avatar
Mihobre
Member
 
Posts: 101
Joined: Tue Oct 30, 2012 08:45

by Mihobre » Wed May 08, 2013 12:29

BlockMen wrote:
Mihobre wrote:thank pics work, but when I place it it appears at top then i left click it it moves to another position in a box, and oh, because you mentioned file extensions, i am also writing file extensions to the sounds because sounds don't play, and i might try to change it to nodebox first


1.) If you not want it look like a sign you should change 'drawtype = "signlike"' to nodebox

2.) you shouldnt use param2 of the node for your songs index. use "node metadata" instead (http://dev.minetest.net/NodeMetaRef)

3.) for playing sounds put *.ogg-files in a "sounds" folder in your mod. then you can easily play them by using minetest.sound_play()

I am to stupid and inexperienced to do something like that, if someone can pleae help me, or i will cancel mod and some other guy will continue. (I hope someone do this and like when it is clicked, it shows screen with buttons like 1-some number and an on/off button)
I wanna fly!!!
I wanna have feathery wings of silver, blue, and white!!!
I wanna soar high and touch the sky!!!
I wanna fly!!!
 

User avatar
Inocudom
Member
 
Posts: 2889
Joined: Sat Sep 29, 2012 01:14
IRC: Inocudom
In-game: Inocudom

by Inocudom » Wed May 08, 2013 15:35

What is it you intend this mod to do? What is the end goal for this mod?
 

User avatar
Mihobre
Member
 
Posts: 101
Joined: Tue Oct 30, 2012 08:45

by Mihobre » Sat May 18, 2013 02:45

For those who want to help... here is the new code(edited code of jukebox mod(with permission from BlockMen))

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_node("radio:radio", {
    description = "Radio",
    drawtype = "nodebox",
    tiles = {"jukebox_top.png", "default_wood.png", "jukebox_side.png",
        "jukebox_side.png", "jukebox_front.png", "jukebox_front.png"},
    paramtype = "light",
    paramtype2 = "facedir",
    stack_max = 1,
    groups = {choppy=2,oddly_breakable_by_hand=2,flammable=2},
    sounds = default.node_sound_wood_defaults(),
    node_box = {
        type = "fixed",
        fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
    },
    selection_box = {
        type = "fixed",
        fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
               
    },
    on_rightclick = function(pos, node, clicker, itemstack)
       
        local meta = minetest.env:get_meta(pos)
        local inv = meta:get_inventory()
        if inv:is_empty("main") then
            if clicker:get_wielded_item():get_name() == "radio:cuintha" then
                inv:set_stack("main",1, itemstack:take_item())
                meta:set_string("hwnd",minetest.sound_play("cuintha", {gain = 0.5, max_hear_distance = 25}))
            elseif clicker:get_wielded_item():get_name() == "radio:demons_rebirth" then
                inv:set_stack("main",1, itemstack:take_item())
                meta:set_string("hwnd",minetest.sound_play("demons_rebirth", {gain = 0.5, max_hear_distance = 25}))
            elseif clicker:get_wielded_item():get_name() == "radio:divine_knights" then
                inv:set_stack("main",1, itemstack:take_item())
                meta:set_string("hwnd",minetest.sound_play("divine_knights", {gain = 0.5, max_hear_distance = 25}))
            elseif clicker:get_wielded_item():get_name() == "radio:endings_and_beginnings" then
                inv:set_stack("main",1, itemstack:take_item())
                meta:set_string("hwnd",minetest.sound_play("endings_and_beginnings", {gain = 0.5, max_hear_distance = 25}))
            elseif clicker:get_wielded_item():get_name() == "radio:floating_island_githrau" then
                inv:set_stack("main",1, itemstack:take_item())
                meta:set_string("hwnd",minetest.sound_play("floating_island_githrau", {gain = 0.5, max_hear_distance = 25}))
            elseif clicker:get_wielded_item():get_name() == "radiox:flying_moon_creature" then
                inv:set_stack("main",1, itemstack:take_item())
                meta:set_string("hwnd",minetest.sound_play("flying_moon_creature", {gain = 0.5, max_hear_distance = 25}))
            elseif clicker:get_wielded_item():get_name() == "radio:fortuna_plains" then
                inv:set_stack("main",1, itemstack:take_item())
                meta:set_string("hwnd",minetest.sound_play("fortuna_plains", {gain = 0.5, max_hear_distance = 25}))
            elseif clicker:get_wielded_item():get_name() == "radio:ghost_wolf_thirio" then
                inv:set_stack("main",1, itemstack:take_item())
                meta:set_string("hwnd",minetest.sound_play("ghost_wolf_thirio", {gain = 0.5, max_hear_distance = 25}))
            elseif clicker:get_wielded_item():get_name() == "radio:lake_of_viridia" then
                inv:set_stack("main",1, itemstack:take_item())
                meta:set_string("hwnd",minetest.sound_play("lake_of_viridia", {gain = 0.5, max_hear_distance = 25}))
            elseif clicker:get_wielded_item():get_name() == "radio:mecha_soul_4000" then
                inv:set_stack("main",1, itemstack:take_item())
                meta:set_string("hwnd",minetest.sound_play("mecha_soul_4000", {gain = 0.5, max_hear_distance = 25}))
            elseif clicker:get_wielded_item():get_name() == "radio:of_epic_proportions" then
                inv:set_stack("main",1, itemstack:take_item())
                meta:set_string("hwnd",minetest.sound_play("of_epic_proportions", {gain = 0.5, max_hear_distance = 25}))
            elseif clicker:get_wielded_item():get_name() == "radio:quest_for_immortality_1" then
                inv:set_stack("main",1, itemstack:take_item())
                meta:set_string("hwnd",minetest.sound_play("quest_for_immortality_1", {gain = 0.5, max_hear_distance = 25}))
            elseif clicker:get_wielded_item():get_name() == "radio:quest_for_immortality_2" then
                inv:set_stack("main",1, itemstack:take_item())
                meta:set_string("hwnd",minetest.sound_play("quest_for_immortality_2", {gain = 0.5, max_hear_distance = 25}))
            elseif clicker:get_wielded_item():get_name() == "radio:quest_for_immortality_3" then
                inv:set_stack("main",1, itemstack:take_item())
                meta:set_string("hwnd",minetest.sound_play("quest_for_immortality_3", {gain = 0.5, max_hear_distance = 25}))
            elseif clicker:get_wielded_item():get_name() == "radio:the_raining_cave" then
                inv:set_stack("main",1, itemstack:take_item())
                meta:set_string("hwnd",minetest.sound_play("the_raining_cave", {gain = 0.5, max_hear_distance = 25}))
            elseif clicker:get_wielded_item():get_name() == "radio:tornado" then
                inv:set_stack("main",1, itemstack:take_item())
                meta:set_string("hwnd",minetest.sound_play("tornado", {gain = 0.5, max_hear_distance = 25}))
            end
        else
            local drop_pos = minetest.env:find_node_near(pos, 1, "air")
            if drop_pos == nil then drop_pos = {x=pos.x, y=pos.y+1,z=pos.z} end
            minetest.env:add_item(drop_pos, inv:get_stack("main",1))
            if meta:get_string("hwnd") then minetest.sound_stop(meta:get_string("hwnd")) end
            inv:remove_item("main",inv:get_stack("main",1))
        end

    end,
    on_construct = function(pos)
        local meta = minetest.env:get_meta(pos)
        local inv = meta:get_inventory()
        inv:set_size("main", 1)
    end,   
    on_destruct = function(pos)
        local meta = minetest.env:get_meta(pos)
        local inv = meta:get_inventory()
        if not inv:is_empty("main") then
            local drop_pos = minetest.env:find_node_near(pos, 1, "air")
            if drop_pos == nil then drop_pos = {x=pos.x, y=pos.y+1,z=pos.z} end
            minetest.env:add_item(drop_pos, inv:get_stack("main",1))
            if meta:get_string("hwnd") then minetest.sound_stop(meta:get_string("hwnd")) end
        end
    end,
})


minetest.register_craftitem("radio:cuintha", {
    description = "Music Disc",
    inventory_image = "jukebox_disc.png",
    liquids_pointable = false,
    stack_max = 1
})
minetest.register_craftitem("radio:demons_rebirth", {
    description = "Music Disc",
    inventory_image = "jukebox_disc.png",
    liquids_pointable = false,
    stack_max = 1
})
minetest.register_craftitem("radio:divine_knights", {
    description = "Music Disc",
    inventory_image = "jukebox_disc.png",
    liquids_pointable = false,
    stack_max = 1
})
minetest.register_craftitem("radio:endings_and_beginnings", {
    description = "Music Disc",
    inventory_image = "jukebox_disc.png",
    liquids_pointable = false,
    stack_max = 1
})
minetest.register_craftitem("radio:floating_island_githrau", {
    description = "Music Disc",
    inventory_image = "jukebox_disc.png",
    liquids_pointable = false,
    stack_max = 1
})
minetest.register_craftitem("radio:flying_moon_creature", {
    description = "Music Disc",
    inventory_image = "jukebox_disc.png",
    liquids_pointable = false,
    stack_max = 1
})
minetest.register_craftitem("radio:fortuna_plains", {
    description = "Music Disc",
    inventory_image = "jukebox_disc.png",
    liquids_pointable = false,
    stack_max = 1
})
minetest.register_craftitem("radio:ghost_wolf_thirio", {
    description = "Music Disc",
    inventory_image = "jukebox_disc.png",
    liquids_pointable = false,
    stack_max = 1
})
minetest.register_craftitem("radio:lake_of_viridia", {
    description = "Music Disc",
    inventory_image = "jukebox_disc.png",
    liquids_pointable = false,
    stack_max = 1
})
minetest.register_craftitem("radio:mecha_soul_4000", {
    description = "Music Disc",
    inventory_image = "jukebox_disc.png",
    liquids_pointable = false,
    stack_max = 1
})
minetest.register_craftitem("radio:of_epic_proportions", {
    description = "Music Disc",
    inventory_image = "jukebox_disc.png",
    liquids_pointable = false,
    stack_max = 1
})
minetest.register_craftitem("radio:quest_for_immortality_1", {
    description = "Music Disc",
    inventory_image = "jukebox_disc.png",
    liquids_pointable = false,
    stack_max = 1
})
minetest.register_craftitem("radio:Quest_for_immortality_2", {
    description = "Music Disc",
    inventory_image = "jukebox_disc.png",
    liquids_pointable = false,
    stack_max = 1
})
minetest.register_craftitem("radio:quest_for_immortality_3", {
    description = "Music Disc",
    inventory_image = "jukebox_disc.png",
    liquids_pointable = false,
    stack_max = 1
})
minetest.register_craftitem("radio:the_raining_cave", {
    description = "Music Disc",
    inventory_image = "jukebox_disc.png",
    liquids_pointable = false,
    stack_max = 1
})
minetest.register_craftitem("radio:tornado", {
    description = "Music Disc",
    inventory_image = "jukebox_disc.png",
    liquids_pointable = false,
    stack_max = 1
})


minetest.register_craft({
    output = "radio:radio",
    recipe = {
        {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot", },
        {"default:steel_ingot", "default:chest", "default:steel_ingot", },
        {"default:stick", "", "default:stick", }
    }
})
minetest.register_craft({
    output = "radio:cuintha",
    recipe = {
        {"", "default:clay_lump", "", },
        {"default:clay_lump", "default:mese_crystal_fragment", "default:clay_lump", },
        {"", "default:clay_lump", "", }
    }
})
minetest.register_craft({
    output = "radio:cuintha",
    recipe = {
        {"", "", "", },
        {"", "radio:tornado", "", },
        {"", "", "", }
    }
})
minetest.register_craft({
    output = "radio:demons_rebirth",
    recipe = {
        {"", "", "", },
        {"", "radio:cuintha", "", },
        {"", "", "", }
    }
})
minetest.register_craft({
    output = "radio:divine_knights",
    recipe = {
        {"", "", "", },
        {"", "radio:demons_rebirth", "", },
        {"", "", "", }
    }
})
minetest.register_craft({
    output = "radio:endings_and_beginnings",
    recipe = {
        {"", "", "", },
        {"", "divine_knights", "", },
        {"", "", "", }
    }
})
minetest.register_craft({
    output = "radio:floating_island_githrau",
    recipe = {
        {"", "", "", },
        {"", "radio:endings_and_beginnings", "", },
        {"", "", "", }
    }
})
minetest.register_craft({
    output = "radio:flying_moon_creature",
    recipe = {
        {"", "", "", },
        {"", "radio:floating_island_githrau", "", },
        {"", "", "", }
    }
})
minetest.register_craft({
    output = "radio:fortuna_plains",
    recipe = {
        {"", "", "", },
        {"", "radio:flying_moon_creature", "", },
        {"", "", "", }
    }
})
minetest.register_craft({
    output = "radio:ghost_wolf_thirio",
    recipe = {
        {"", "", "", },
        {"", "radio:fortuna_plains", "", },
        {"", "", "", }
    }
})
minetest.register_craft({
    output = "radio:lake_of_viridia",
    recipe = {
        {"", "", "", },
        {"", "radio:ghost_wolf_thirio", "", },
        {"", "", "", }
    }
})
minetest.register_craft({
    output = "mecha_soul_4000",
    recipe = {
        {"", "", "", },
        {"", "radio:lake_of_viridia", "", },
        {"", "", "", }
    }
})
minetest.register_craft({
    output = "radio:of_epic_proportions",
    recipe = {
        {"", "", "", },
        {"", "radio:mecha_soul_4000", "", },
        {"", "", "", }
    }
})
minetest.register_craft({
    output = "radio:quest_for_immortality_1",
    recipe = {
        {"", "", "", },
        {"", "radio:of_epic_proportions", "", },
        {"", "", "", }
    }
})
minetest.register_craft({
    output = "radio:quest_for_immortality_2",
    recipe = {
        {"", "", "", },
        {"", "radio:quest_for_immortality_1", "", },
        {"", "", "", }
    }
})
minetest.register_craft({
    output = "radio:quest_for_immortality_3",
    recipe = {
        {"", "", "", },
        {"", "radio:quest_for_immortality_2", "", },
        {"", "", "", }
    }
})
minetest.register_craft({
    output = "radio:the_raining_cave",
    recipe = {
        {"", "", "", },
        {"", "radio:quest_for_immortality_3", "", },
        {"", "", "", }
    }
})
minetest.register_craft({
    output = "radio:tornado",
    recipe = {
        {"", "", "", },
        {"", "radio:the_raining_cave", "", },
        {"", "", "", }
    }
})
I wanna fly!!!
I wanna have feathery wings of silver, blue, and white!!!
I wanna soar high and touch the sky!!!
I wanna fly!!!
 

User avatar
BlockMen
Member
 
Posts: 768
Joined: Fri Mar 01, 2013 17:24
GitHub: BlockMen

by BlockMen » Sun May 19, 2013 12:16

Mihobre wrote:For those who want to help... here is the new code(edited code of jukebox mod(with permission from BlockMen))

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
-code-


Well, you want to create a radio, so i wont make discs for that. I have changed to a random playing of songs (like in radio) when clicking on.

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 songs = {}
songs[0] = "devine_knights"
songs[1] = "cuintha"
--...

minetest.register_node("radio:radio", {
    description = "Radio",
    drawtype = "nodebox",
    tiles = {"jukebox_top.png", "default_wood.png", "jukebox_side.png",
        "jukebox_side.png", "jukebox_front.png", "jukebox_front.png"},
    paramtype = "light",
    paramtype2 = "facedir",
    stack_max = 1,
    groups = {choppy=2,oddly_breakable_by_hand=2,flammable=2},
    sounds = default.node_sound_wood_defaults(),
    node_box = {
        type = "fixed",
        fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
    },
    selection_box = {
        type = "fixed",
        fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
               
    },
    on_rightclick = function(pos, node, clicker, itemstack)
    local meta = minetest.env:get_meta(pos)
    if string.len(meta:get_string("hwnd")) > 0 then
        minetest.sound_stop(meta:get_string("hwnd"))
        meta:set_string("hwnd",nil)
    else
        meta:set_string("hwnd",minetest.sound_play("radio_" .. songs[math.random(0,table.getn(songs))], {gain = 0.5, max_hear_distance = 25}))
    end
    end,
    on_destruct = function(pos)
    local meta = minetest.env:get_meta(pos)
    if string.len(meta:get_string("hwnd")) > 0 then minetest.sound_stop(meta:get_string("hwnd")) end
    end,
})


minetest.register_craft({
    output = "radio:radio",
    recipe = {
        {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot", },
        {"default:steel_ingot", "default:chest", "default:steel_ingot", },
        {"default:stick", "", "default:stick", }
    }
})


All you have to do now is to complete the list at the top songs[2] = #songname# and rename all songs in "sounds" folder to "radio_#songname#" to prevent conflicts with other mods.
 

User avatar
Mihobre
Member
 
Posts: 101
Joined: Tue Oct 30, 2012 08:45

by Mihobre » Mon May 20, 2013 07:10

BlockMen wrote:
Mihobre wrote:For those who want to help... here is the new code(edited code of jukebox mod(with permission from BlockMen))

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
-code-


Well, you want to create a radio, so i wont make discs for that. I have changed to a random playing of songs (like in radio) when clicking on.

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 songs = {}
songs[0] = "devine_knights"
songs[1] = "cuintha"
--...

minetest.register_node("radio:radio", {
    description = "Radio",
    drawtype = "nodebox",
    tiles = {"jukebox_top.png", "default_wood.png", "jukebox_side.png",
        "jukebox_side.png", "jukebox_front.png", "jukebox_front.png"},
    paramtype = "light",
    paramtype2 = "facedir",
    stack_max = 1,
    groups = {choppy=2,oddly_breakable_by_hand=2,flammable=2},
    sounds = default.node_sound_wood_defaults(),
    node_box = {
        type = "fixed",
        fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
    },
    selection_box = {
        type = "fixed",
        fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
               
    },
    on_rightclick = function(pos, node, clicker, itemstack)
    local meta = minetest.env:get_meta(pos)
    if string.len(meta:get_string("hwnd")) > 0 then
        minetest.sound_stop(meta:get_string("hwnd"))
        meta:set_string("hwnd",nil)
    else
        meta:set_string("hwnd",minetest.sound_play("radio_" .. songs[math.random(0,table.getn(songs))], {gain = 0.5, max_hear_distance = 25}))
    end
    end,
    on_destruct = function(pos)
    local meta = minetest.env:get_meta(pos)
    if string.len(meta:get_string("hwnd")) > 0 then minetest.sound_stop(meta:get_string("hwnd")) end
    end,
})


minetest.register_craft({
    output = "radio:radio",
    recipe = {
        {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot", },
        {"default:steel_ingot", "default:chest", "default:steel_ingot", },
        {"default:stick", "", "default:stick", }
    }
})


All you have to do now is to complete the list at the top songs[2] = #songname# and rename all songs in "sounds" folder to "radio_#songname#" to prevent conflicts with other mods.

Thank you so much!!! Gonna edit init.lua now...
I wanna fly!!!
I wanna have feathery wings of silver, blue, and white!!!
I wanna soar high and touch the sky!!!
I wanna fly!!!
 

User avatar
Mihobre
Member
 
Posts: 101
Joined: Tue Oct 30, 2012 08:45

by Mihobre » Wed May 22, 2013 12:47

Woot!!! It works!!! Woot!!! And Super Big Credits to BlockMen for all the coding help and emotional support!!! I am 11 and I am VICTORiOUS!!!
I wanna fly!!!
I wanna have feathery wings of silver, blue, and white!!!
I wanna soar high and touch the sky!!!
I wanna fly!!!
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 15 guests