Post your modding questions here

User avatar
Achilles
Member
 
Posts: 246
Joined: Sun Dec 15, 2013 11:55
In-game: Achilles

Re: Post your modding questions here

by Achilles » Fri Sep 19, 2014 18:42

jin_xi wrote:
Achilles wrote:Has anyone ever considered making a 'PickPocket' mod?

It would encourage players not to leave their accounts idle for too long a time....


wow thats a really good idea! could be fun to try and come up with some games with that


Maybe it would make a good game also, but I meant it for another purpose lol
 

User avatar
Esteban
Member
 
Posts: 872
Joined: Sun Sep 08, 2013 13:26
GitHub: Esteban-
IRC: Esteban
In-game: Esteban

Re: Post your modding questions here

by Esteban » Fri Sep 19, 2014 18:50

What other methods are available to make a node spawn on a map beyond ABMs?
 

User avatar
TenPlus1
Member
 
Posts: 1874
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

Re: Post your modding questions here

by TenPlus1 » Fri Sep 19, 2014 18:57

minetest.register_on_generated(function(minp, maxp, seed)

this will place specific nodes when a new area of map is generated and with a specific set of rules that you specify in the function...
 

User avatar
Esteban
Member
 
Posts: 872
Joined: Sun Sep 08, 2013 13:26
GitHub: Esteban-
IRC: Esteban
In-game: Esteban

Re: Post your modding questions here

by Esteban » Fri Sep 19, 2014 18:58

TenPlus1 wrote:minetest.register_on_generated(function(minp, maxp, seed)

this will place specific nodes when a new area of map is generated and with a specific set of rules that you specify in the function...


Thanks!
 

User avatar
AMMOnym
Member
 
Posts: 682
Joined: Tue Sep 10, 2013 14:18
IRC: AMMOnym
In-game: AMMOnym

Re: Post your modding questions here

by AMMOnym » Sat Sep 20, 2014 18:52

20:49:33: ERROR[main]: ServerError: ...top\minetest-0.4.10\bin\..\mods\PKMNS\pok
enodes\init.lua:192: attempt to index local 'pos' (a nil value)
20:49:33: ERROR[main]: stack traceback:
20:49:33: ERROR[main]: ...top\minetest-0.4.10\bin\..\mods\PKMNS\pokenodes\init.
lua:192: in function 'on_rightclick'
20:49:33: ERROR[main]: ...min\Desktop\minetest-0.4.10\bin\..\builtin\game\item.
lua:326: in function <...min\Desktop\minetest-0.4.10\bin\..\builtin\game\item.lu
a:319>

How can I repair it ?

minetest.register_node("pokenodes:bulbasaur", {
description = "Bulbasaur",
wield_image = "pokeball.png",
drawtype = "torchlike",
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
walkable = false,
tiles = {"bulbasaur.png"},
groups = {catch=1, catch4=1,},
inventory_image = "pokeball.png",
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
local pos = pointed_thing.above;
local node = minetest.env:get_node({x=pos.x, y=pos.y+1, z=pos.z});
if(node.name == "air") then
local p = {x=pos.x, y=pos.y+1, z=pos.z};
minetest.set_node(p, {name="default:dirt"})
--return;
end
end,
on_destruct = function(pos)
minetest.chat_send_all("set");
local p = {x=pos.x, y=pos.y+1, z=pos.z};
minetest.env:remove_node(p);
end
})

This is code
Last edited by AMMOnym on Sat Sep 20, 2014 18:58, edited 1 time in total.
 

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

Re: Post your modding questions here

by Krock » Sat Sep 20, 2014 18:56

AMMOnym 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
on_rightclick = function(itemstack, clicker, pointed_thing)
      local pos = pointed_thing.above;
      local node = minetest.env:get_node({x=pos.x, y=pos.y+1, z=pos.z});
      if(node.name == "air") then
         local p = {x=pos.x, y=pos.y+1, z=pos.z};
         minetest.set_node(p, {name="default:dirt"})
         --return;
      end
   end,

https://github.com/minetest/minetest/bl ... i.txt#L603
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
on_rightclick = function(itemstack, clicker, pointed_thing)
      if pointed_thing.type ~= "node" then
         return
      end
      local pos = pointed_thing.above
      local node = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z})
      if node.name == "air" then
         local p = {x=pos.x, y=pos.y+1, z=pos.z}
         minetest.set_node(p, {name="default:dirt"})
         --return;
      end
   end,
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
AMMOnym
Member
 
Posts: 682
Joined: Tue Sep 10, 2013 14:18
IRC: AMMOnym
In-game: AMMOnym

Re: Post your modding questions here

by AMMOnym » Sat Sep 20, 2014 19:20

Krock wrote:
AMMOnym 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
on_rightclick = function(itemstack, clicker, pointed_thing)
      local pos = pointed_thing.above;
      local node = minetest.env:get_node({x=pos.x, y=pos.y+1, z=pos.z});
      if(node.name == "air") then
         local p = {x=pos.x, y=pos.y+1, z=pos.z};
         minetest.set_node(p, {name="default:dirt"})
         --return;
      end
   end,

https://github.com/minetest/minetest/bl ... i.txt#L603
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
on_rightclick = function(itemstack, clicker, pointed_thing)
      if pointed_thing.type ~= "node" then
         return
      end
      local pos = pointed_thing.above
      local node = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z})
      if node.name == "air" then
         local p = {x=pos.x, y=pos.y+1, z=pos.z}
         minetest.set_node(p, {name="default:dirt"})
         --return;
      end
   end,


It works now, thanks. Do you know, how to spawn dirt just above pointed node ? Becouse when I click on side of node, it makes a node like x+1, y+1
 

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

Re: Post your modding questions here

by Krock » Sat Sep 20, 2014 19:35

AMMOnym wrote:It works now, thanks. Do you know, how to spawn dirt just above pointed node ? Becouse when I click on side of node, it makes a node like x+1, y+1

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 pos = pointed_thing.under

There you go. The poinuted node under and 1 node above is the position you wish.
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
AMMOnym
Member
 
Posts: 682
Joined: Tue Sep 10, 2013 14:18
IRC: AMMOnym
In-game: AMMOnym

Re: Post your modding questions here

by AMMOnym » Sat Sep 20, 2014 19:46

Krock wrote:
AMMOnym wrote:It works now, thanks. Do you know, how to spawn dirt just above pointed node ? Becouse when I click on side of node, it makes a node like x+1, y+1

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 pos = pointed_thing.under

There you go. The poinuted node under and 1 node above is the position you wish.

FINNALY it works......I like you !!
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Post your modding questions here

by rubenwardy » Sun Sep 21, 2014 10:46

.
Last edited by rubenwardy on Sun Sep 21, 2014 10:49, edited 1 time in total.
 

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

Re: Post your modding questions here

by Krock » Sun Sep 21, 2014 10:49

rubenwardy wrote:Did you even read the error message?

Pos doesn't exist on line 192. You have probably got the function parameters wrong.

I think this is self-explaining :P
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
      if pointed_thing.type ~= "node" then
         return
      end
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
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Post your modding questions here

by rubenwardy » Sun Sep 21, 2014 10:50

I didn't see your answer. I was talking to AMMOnym
 

User avatar
AMMOnym
Member
 
Posts: 682
Joined: Tue Sep 10, 2013 14:18
IRC: AMMOnym
In-game: AMMOnym

Re: Post your modding questions here

by AMMOnym » Sun Sep 21, 2014 11:02

rubenwardy wrote:I didn't see your answer. I was talking to AMMOnym

You can see working code in pokenodes now. I know that I had that really bad, but I am just moddet beginner.
 

4aiman
Member
 
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

Re: Post your modding questions here

by 4aiman » Mon Sep 22, 2014 10:07

Answering my own question: there's no way besides caching.
 

User avatar
AMMOnym
Member
 
Posts: 682
Joined: Tue Sep 10, 2013 14:18
IRC: AMMOnym
In-game: AMMOnym

Re: Post your modding questions here

by AMMOnym » Mon Sep 22, 2014 13:33

Hello could someone explain me this numbers (Its from on_generated function)

minp, maxp, seed+21, 1/10/10/10, 1, -31000, -40)
 

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

Re: Post your modding questions here

by Topywo » Mon Sep 22, 2014 20:28

AMMOnym wrote:Hello could someone explain me this numbers (Its from on_generated function)

minp, maxp, seed+21, 1/10/10/10, 1, -31000, -40)


I can't explain properly what it means. I recognize it from the ore generation in mapgen.lua from an old default:

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
-- Ore generation
--

function default.generate_ore(name, wherein, minp, maxp, seed, chunks_per_volume, chunk_size, ore_per_chunk, height_min, height_max)
   if maxp.y < height_min or minp.y > height_max then
      return
   end
   local y_min = math.max(minp.y, height_min)
   local y_max = math.min(maxp.y, height_max)
   local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1)
   local pr = PseudoRandom(seed)
   local num_chunks = math.floor(chunks_per_volume * volume)
   local inverse_chance = math.floor(chunk_size*chunk_size*chunk_size / ore_per_chunk)
   --print("generate_ore num_chunks: "..dump(num_chunks))
   for i=1,num_chunks do
      local y0 = pr:next(y_min, y_max-chunk_size+1)
      if y0 >= height_min and y0 <= height_max then
         local x0 = pr:next(minp.x, maxp.x-chunk_size+1)
         local z0 = pr:next(minp.z, maxp.z-chunk_size+1)
         local p0 = {x=x0, y=y0, z=z0}
         for x1=0,chunk_size-1 do
         for y1=0,chunk_size-1 do
         for z1=0,chunk_size-1 do
            if pr:next(1,inverse_chance) == 1 then
               local x2 = x0+x1
               local y2 = y0+y1
               local z2 = z0+z1
               local p2 = {x=x2, y=y2, z=z2}
               if minetest.env:get_node(p2).name == wherein then
                  minetest.env:set_node(p2, {name=name})
               end
            end
         end
         end
         end
      end
   end
   --print("generate_ore done")
end

minetest.register_on_generated(function(minp, maxp, seed)
   -- Generate regular ores
   default.generate_ore("default:stone_with_coal", "default:stone", minp, maxp, seed+0, 1/8/8/8,    3, 8, -31000,  64)
   default.generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+1, 1/12/12/12, 2, 3,    -15,   2)
   default.generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+2, 1/9/9/9,    3, 5,    -63, -16)
   default.generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+3, 1/7/7/7,    3, 5, -31000, -64)
   
   default.generate_ore("default:stone_with_mese", "default:stone", minp, maxp, seed+4, 1/16/16/16, 2, 3,   -127,  -64)
   default.generate_ore("default:stone_with_mese", "default:stone", minp, maxp, seed+5, 1/9/9/9,    3, 5, -31000, -128)
   default.generate_ore("default:mese",            "default:stone", minp, maxp, seed+8, 1/16/16/16, 2, 3, -31000,-1024)
   
   default.generate_ore("default:stone_with_coal", "default:stone", minp, maxp, seed+7, 1/24/24/24, 6,27, -31000,  0)
   default.generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+6, 1/24/24/24, 6,27, -31000, -64)
 

User avatar
AMMOnym
Member
 
Posts: 682
Joined: Tue Sep 10, 2013 14:18
IRC: AMMOnym
In-game: AMMOnym

Re: Post your modding questions here

by AMMOnym » Tue Sep 23, 2014 14:06

That is what I am looking for. Thanks Topywo
 

User avatar
AMMOnym
Member
 
Posts: 682
Joined: Tue Sep 10, 2013 14:18
IRC: AMMOnym
In-game: AMMOnym

Re: Post your modding questions here

by AMMOnym » Tue Sep 23, 2014 17:19

Hello me again,
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 function generate_ore(name, wherein, minp, maxp, seed, chunks_per_volume, ore_per_chunk, height_min, height_max)
   if maxp.y < height_min or minp.y > height_max then
      return
   end
   local y_min = math.max(minp.y, height_min)
   local y_max = math.min(maxp.y, height_max)
   local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1)
   local pr = PseudoRandom(seed)
   local num_chunks = math.floor(chunks_per_volume * volume)
   local chunk_size = 3
   if ore_per_chunk <= 4 then
      chunk_size = 2
   end
   local inverse_chance = math.floor(chunk_size*chunk_size*chunk_size / ore_per_chunk)
   --print("generate_ore num_chunks: "..dump(num_chunks))
   for i=1,num_chunks do
      local y0 = pr:next(y_min, y_max-chunk_size+1)
      if y0 >= height_min and y0 <= height_max then
         local x0 = pr:next(minp.x, maxp.x-chunk_size+1)
         local z0 = pr:next(minp.z, maxp.z-chunk_size+1)
         local p0 = {x=x0, y=y0, z=z0}
         for x1=0,chunk_size-1 do
         for y1=0,chunk_size-1 do
         for z1=0,chunk_size-1 do
            if pr:next(1,inverse_chance) == 1 then
               local x2 = x0+x1
               local y2 = y0+y1
               local z2 = z0+z1
               local p2 = {x=x2, y=y2, z=z2}
               if minetest.env:get_node(p2).name == wherein then
                  minetest.env:set_node(p2, {name=name})
               end
            end
         end
         end
         end
      end
   end
end

minetest.register_on_generated(function(minp, maxp, seed)
generate_ore("pokenodes:teamrocketmember", "default:dirt_with_grass", minp, maxp, seed+21,   1/10/10/10,    1, -31000,  10)
end)


Is there any way how to generate them ON the default:dirt_with_grass ?
 

Icalasari
Member
 
Posts: 17
Joined: Tue Sep 23, 2014 05:29
IRC: Icalasari
In-game: Icalasari

Re: Post your modding questions here

by Icalasari » Wed Sep 24, 2014 06:04

Topic: The heck is wrong with this code:

minetest.register_on_joinplayer(
set_physics_override{
jump= 25.0
}
)

Reason: I have been trying many different combinations of placements of brackets and node sets and such to try to get a jump mod in and later do blocks that would affect jump height
More Info: :| The wiki is really lacking on how to call stuff like this to affect the player
 

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

Re: Post your modding questions here

by Topywo » Wed Sep 24, 2014 08:32

@aMMOnym
I never tried to use the code that way, but in that case you might need to spawn them in "air" and build an if/then construction around it that checks if there's default_dirt_with_grass under it. If that works, you can use - 31.000 and + 31000 to spawn your pokemons.
 

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

Re: Post your modding questions here

by Topywo » Wed Sep 24, 2014 08:38

@Icalasari
Idk, but you might find this mod (playerplus from TenPlus1) usable to understand how to code it:
viewtopic.php?f=9&t=10090
 

User avatar
AMMOnym
Member
 
Posts: 682
Joined: Tue Sep 10, 2013 14:18
IRC: AMMOnym
In-game: AMMOnym

Re: Post your modding questions here

by AMMOnym » Wed Sep 24, 2014 12:07

Topywo wrote:@aMMOnym
I never tried to use the code that way, but in that case you might need to spawn them in "air" and build an if/then construction around it that checks if there's default_dirt_with_grass under it. If that works, you can use - 31.000 and + 31000 to spawn your pokemons.

Thank you for answer. I have diferent idea now. I will make a block which will looks like default:dirt_with_grass(generated). And amb to spawn trainers on these dirt nodes.
 

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

Re: Post your modding questions here

by Krock » Wed Sep 24, 2014 15:44

Icalasari wrote:Topic: The heck is wrong with this code:

minetest.register_on_joinplayer(
set_physics_override{
jump= 25.0
}
)


Please look at https://github.com/minetest/minetest/bl ... ua_api.txt
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)
   player:set_physics_override({
      jump = 25.0
   })
end)

using 25 for jump is a bit too much. Use something like 1.5 or 2.
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>
 

Icalasari
Member
 
Posts: 17
Joined: Tue Sep 23, 2014 05:29
IRC: Icalasari
In-game: Icalasari

Re: Post your modding questions here

by Icalasari » Thu Sep 25, 2014 05:38

Krock wrote:
Icalasari wrote:Topic: The heck is wrong with this code:

minetest.register_on_joinplayer(
set_physics_override{
jump= 25.0
}
)


Please look at https://github.com/minetest/minetest/bl ... ua_api.txt
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)
   player:set_physics_override({
      jump = 25.0
   })
end)

using 25 for jump is a bit too much. Use something like 1.5 or 2.


The 25 was so I could know when I succeeded since it would be hard to miss shooting up into the sky

And thanks - I would... Not have picked up the function(player) part any time soon. So far I'm at the stage of learn by breaking things and asking so many questions that I am liable to tick off at least one person

Edit: Is the wiki the most up to date source on tutorials and references?

Edit 2: ...How did I miss the link in your post
 

User avatar
Achilles
Member
 
Posts: 246
Joined: Sun Dec 15, 2013 11:55
In-game: Achilles

Re: Post your modding questions here

by Achilles » Thu Sep 25, 2014 20:05

If you want to find out how to do something, then just post the question on this forum. It is liable that someone shall be able to answer it in a way that should suite you and others.

I am not saying that Minetest Wiki is not reliable (It is), however this forum is probably more so: depending on who is answering your query...
The Ironic Thing About Common Sense Is That It Isn't Very Common
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Post your modding questions here

by rubenwardy » Thu Sep 25, 2014 20:20

Achilles wrote:If you want to find out how to do something, then just post the question on this forum. It is liable that someone shall be able to answer it in a way that should suite you and others.

I am not saying that Minetest Wiki is not reliable (It is), however this forum is probably more so: depending on who is answering your query...


No no no no no!

That's like saying don't google it before, just ask the question on Stack Overflow. Not good

If you can't work out how to do it by
1) looking at lua-api.txt
2) reading wiki
3) searching the forum
Then, and only then, do you post a question.
 

fherno14
New member
 
Posts: 9
Joined: Wed Sep 17, 2014 05:25
In-game: fherno

Re: Post your modding questions here

by fherno14 » Thu Sep 25, 2014 21:41

tengo una idea para un mod de magia
como el de minecraft witchery o algo asi
 

Icalasari
Member
 
Posts: 17
Joined: Tue Sep 23, 2014 05:29
IRC: Icalasari
In-game: Icalasari

Re: Post your modding questions here

by Icalasari » Fri Sep 26, 2014 06:20

rubenwardy wrote:
Achilles wrote:If you want to find out how to do something, then just post the question on this forum. It is liable that someone shall be able to answer it in a way that should suite you and others.

I am not saying that Minetest Wiki is not reliable (It is), however this forum is probably more so: depending on who is answering your query...


No no no no no!

That's like saying don't google it before, just ask the question on Stack Overflow. Not good

If you can't work out how to do it by
1) looking at lua-api.txt
2) reading wiki
3) searching the forum
Then, and only then, do you post a question.


Heck, I did steps 2 and 3. I just didn't know of the api til Crock's post (and god I want to make love to the API it's so much easier than looking through the mods and trying to figure out, "Ok, this line does that but yet this one way over here seems needed and what the fuck is going on?"
 

User avatar
lag01
Member
 
Posts: 190
Joined: Sun Mar 16, 2014 03:41
GitHub: AndrejIT
IRC: lag01
In-game: lag

Re: Post your modding questions here

by lag01 » Fri Sep 26, 2014 16:41

I want to set callback function, to trigger when one player right clicks other player while holding craftitem. (Of course i need know both players from that function)
Can i use on_use callback for that? But how can i check/threat "pointed_thing" as player then?
 

User avatar
stu
Member
 
Posts: 737
Joined: Sat Feb 02, 2013 02:51
GitHub: stujones11

Re: Post your modding questions here

by stu » Fri Sep 26, 2014 17:21

lag01 wrote:I want to set callback function, to trigger when one player right clicks other player while holding craftitem. (Of course i need know both players from that function)
Can i use on_use callback for that? But how can i check/threat "pointed_thing" as player then?

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
if pointed_thing.type == "object" then
   local object = pointed_thing.ref
   if object:is_player() then
      -- do stuff to object
   end
end

hope it helps.
 

PreviousNext

Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 7 guests

cron