Questions topic

User avatar
Chinchow
Member
 
Posts: 683
Joined: Tue Sep 18, 2012 21:37

Questions topic

by Chinchow » Thu Oct 25, 2012 21:05

Title says it all pretty much.

Edit:now all of my questions will be posted here.
Last edited by Chinchow on Sun Nov 04, 2012 00:34, edited 1 time in total.
Sometimes, it's harder to think up a mod than it is to create it.
Mods: Orichalcum Stonebricks Extra Chests
 

User avatar
GloopMaster
Member
 
Posts: 213
Joined: Wed Aug 01, 2012 18:03

by GloopMaster » Thu Oct 25, 2012 22:37

STOP. MAKING. NEW. TOPICS. FOR. EACH. AND. EVERY. ONE. OF. YOUR. QUESTIONS.

But aside from that, I would like to know what the heck the question means. Stone doesnt spawn, it's just there.
Meow.

That is all.
 

User avatar
Chinchow
Member
 
Posts: 683
Joined: Tue Sep 18, 2012 21:37

by Chinchow » Thu Oct 25, 2012 23:03

Sorry I'll just put questions here from now on and what I mean is how do I get something to just be there like stone so I can use it as a natural source in a mod.
Sometimes, it's harder to think up a mod than it is to create it.
Mods: Orichalcum Stonebricks Extra Chests
 

User avatar
Topywo
Member
 
Posts: 1718
Joined: Fri May 18, 2012 20:27

by Topywo » Thu Oct 25, 2012 23:37

I'll give it a shot.

I think you can only do that by changing an map-generated node into the one you want it to be, which should mean that you'll loose the 'old' node. If you don't want that, you need to change an amount of a certain node (for example stone) into the desired node (like the moreores mod does). But then it doesn't spawn 'naturally' as I think you want it to.

Hopefully this will be constructively corrected when I'm wrong :-)
 

User avatar
Chinchow
Member
 
Posts: 683
Joined: Tue Sep 18, 2012 21:37

by Chinchow » Mon Oct 29, 2012 21:17

Thank you for all answers to questions and a new ones would it be possible to make a mod that makes trees drop more than one thing like leaves do I'm not asking someone to make this so please don't close topic.

Example of what I mean


Hit leaves leaves drop sapling so could it be possible without messing with the core code to make trees drop something else as well as trees?
Sometimes, it's harder to think up a mod than it is to create it.
Mods: Orichalcum Stonebricks Extra Chests
 

User avatar
Topywo
Member
 
Posts: 1718
Joined: Fri May 18, 2012 20:27

by Topywo » Mon Oct 29, 2012 22:49

I didn't know but had to try it out. I used the init.lua from the default to try out. I went to the registering of the leaves:

minetest.register_node("default:leaves", {
description = "Leaves",
drawtype = "allfaces_optional",
visual_scale = 1.3,
tiles = {"default_leaves.png"},
paramtype = "light",
groups = {snappy=3, leafdecay=3, flammable=2},
drop = {
max_items = 1,
items = {
{
-- player will get sapling with 1/20 chance
items = {'default:sapling'},
--rarity = 20,
},
{
-- player will get leaves only if he get no saplings,
-- this is because max_items is 1
items = {'default:leaves'},
}
}
},
sounds = default.node_sound_leaves_defaults(),
})

Changing or 'deleting' (commenting out) max_items = 1 didn't seem to have any effect.
Deleting rarity = 20 resulted in a drop of both 1 leave and 1 sappling

Then I gave both leaves and sapplings a rarity of 5 and that resulted in sometimes me getting leaves and sometimes sapplings, but not always (as expected).

If you don't want to mess with the default mod and don't want to make a different tree mod, you could copy the leaves part and make it a separate mod that 'overrides' the default mod. From lua_api.txt: https://github.com/celeron55/minetest/blob/master/doc/lua_api.txt :

Naming convention for registered textual names
----------------------------------------------
Registered names should generally be in this format:
  "modname:<whatever>" (<whatever> can have characters a-zA-Z0-9_)
This is to prevent conflicting names from corrupting maps and is
enforced by the mod loader.
Example: mod "experimental", ideal item/node/entity name "tnt":
         -> the name should be "experimental:tnt".
Enforcement can be overridden by prefixing the name with ":". This can
be used for overriding the registrations of some other mod.
Example: Any mod can redefine experimental:tnt by using the name
         ":experimental:tnt" when registering it.
(also that mod is required to have "experimental" as a dependency)
The ":" prefix can also be used for maintaining backwards compatibility.
 

User avatar
Chinchow
Member
 
Posts: 683
Joined: Tue Sep 18, 2012 21:37

by Chinchow » Tue Oct 30, 2012 20:30

Ok I tried making a mod for Halloween when this Idea came to me but the mod won't work and I don't know why

Here is 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_node("holidaychests:halloween_chest", {
    description = "Halloween Chest",
    tiles = {"holidaychests_halloween_chest_top.png", "holidaychests_halloween_chest_top.png", "holidaychests_halloween_chest_side.png",
        "holidaychests_halloween_chest_side.png", "holidaychests_halloween_chest_side.png", "holidaychests_halloween_chest_front.png"},
    paramtype2 = "facedir",
    groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
    legacy_facedir_simple = true,
    sounds = default.node_sound_wood_defaults(),
    on_construct = function(pos)
        local meta = minetest.env:get_meta(pos)
        meta:set_string("formspec",
                "size[8,9]"..
                "list[current_name;main;0,0;8,4;]"..
                "list[current_player;main;0,5;8,4;]")
        meta:set_string("infotext", "Halloween Chest")
        local inv = meta:get_inventory()
        inv:set_size("main", 9*4)
    end,
    can_dig = function(pos,player)
        local meta = minetest.env:get_meta(pos);
        local inv = meta:get_inventory()
        return inv:default_torch("main")
    end,
    on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
        minetest.log("action", player:get_player_name()..
                " moves stuff in chest at "..minetest.pos_to_string(pos))
    end,
    on_metadata_inventory_put = function(pos, listname, index, stack, player)
        minetest.log("action", player:get_player_name()..
                " moves stuff to chest at "..minetest.pos_to_string(pos))
    end,
    on_metadata_inventory_take = function(pos, listname, index, stack, player)
        minetest.log("action", player:get_player_name()..
                " takes stuff from chest at "..minetest.pos_to_string(pos))
light_source = LIGHT_MAX-1
    end,
})



local function has_locked_chest_privilege(meta, player)
    if player:get_player_name() ~= meta:get_string("owner") then
        return false
    end
    return true
end
Sometimes, it's harder to think up a mod than it is to create it.
Mods: Orichalcum Stonebricks Extra Chests
 

User avatar
Topywo
Member
 
Posts: 1718
Joined: Fri May 18, 2012 20:27

by Topywo » Tue Oct 30, 2012 23:18

Chinchow wrote:Ok I tried making a mod for Halloween when this Idea came to me but the mod won't work and I don't know why

Here is the code:

minetest.register_node("holidaychests:halloween_chest", {
description = "Halloween Chest",
tiles = {"holidaychests_halloween_chest_top.png", "holidaychests_halloween_chest_top.png", "holidaychests_halloween_chest_side.png",
"holidaychests_halloween_chest_side.png", "holidaychests_halloween_chest_side.png", "holidaychests_halloween_chest_front.png"},
paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),

-- drop = 'default:torch',
drop = {max_items = 2,
items = {
{
items = {'default:torch'},
},
{
items = {'holidaychests:halloween_chest'},
},
}
},

on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec",
"size[8,9]"..
"list[current_name;main;0,0;8,4;]"..
"list[current_player;main;0,5;8,4;]")
meta:set_string("infotext", "Halloween Chest")
local inv = meta:get_inventory()
inv:set_size("main", 9*4)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
--return inv:default_torch("main")
return inv:is_empty("main")
end,
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
minetest.log("action", player:get_player_name()..
" moves stuff in chest at "..minetest.pos_to_string(pos))
end,
on_metadata_inventory_put = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name()..
" moves stuff to chest at "..minetest.pos_to_string(pos))
end,
on_metadata_inventory_take = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name()..
" takes stuff from chest at "..minetest.pos_to_string(pos))
light_source = LIGHT_MAX-1
end,
})



local function has_locked_chest_privilege(meta, player)
if player:get_player_name() ~= meta:get_string("owner") then
return false
end
return true
end


1. It seems that max_items does have a function. It limits the amount of returned items. I guess I had it removed when I thought it didn't have a use.

2. The red line is causing the error. You need to outcomment them with -- or remove the line and replace it with the blue line under it. The blue line is necessary to prevent a filled chest to be put in your inventory (causing your stuff in the chest to disappear).

3. If you want the chest to return and return an extra torch you need the green lines. Leave the purple outcommented or remove it.

4. If you want the chest to change in a torch use the purple line and outcommend or remove the green lines.

5. I've not examined the possibility to create a torch in the chest whenever you open it (like an ever filled cup) if that is what you wanted. That's not something I can do at the moment, if it is possible at all.

Good luck with your mod!
 

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

by PilzAdam » Wed Oct 31, 2012 10:06

Also move the line
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
light_source = LIGHT_MAX-1
behind the
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
end,
 

El Penguino
New member
 
Posts: 1
Joined: Thu Nov 01, 2012 23:41

by El Penguino » Thu Nov 01, 2012 23:48

how do you write mods?
 

User avatar
Chinchow
Member
 
Posts: 683
Joined: Tue Sep 18, 2012 21:37

by Chinchow » Thu Nov 01, 2012 23:52

Really that is your question? but Ok don't wanna give a tutorial but go up a bit a read the stuff in the white box and use that as something to build off also check minetest/games/mods/default/init
Sometimes, it's harder to think up a mod than it is to create it.
Mods: Orichalcum Stonebricks Extra Chests
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 9 guests

cron