Post your modding questions here

Gerald
Member
 
Posts: 47
Joined: Sun Dec 28, 2014 10:35
In-game: gerald7

Re: Post your modding questions here

by Gerald » Sat Jul 02, 2016 12:01

teh_newbz wrote:Why is player:getpos() returning nil? Whenever I try to use player:getpos() the game crashes with `attempt to call getpos a nil value`


on_use has three arguments: itemstack, user, pointed_thing. Therefore player is the itemstack, which does not have getpos().
I would recommend to use the pointed position instead of the player position to spawn something.
Normally you want to remove the item after using it.
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_use = function(itemstack, player, pointed_thing)
  if pointed_thing.type == "node" then
    minetest.spawn_tree(pointed_thing.above, treedef)
    itemstack:take_item()
  end
  return itemstack
end
 

Cerapter
New member
 
Posts: 4
Joined: Sat Jul 02, 2016 14:38
GitHub: LordCerapter
In-game: Cerapter

Re: Post your modding questions here

by Cerapter » Sat Jul 02, 2016 22:23

How would I go about replacing default:stone in mapgen(s) with my owns?

What I mean is that, let's say, I have 4 different blocks, mymod:mystone1 to mymod:mystone4. From y=0 to y=-800, I want a layer of all four of mymod's stones, so, from 0 to -200, I'd have a layer of mystone1, then from -200 to -400, a layer of mystone2, etc.

I looked into the mapgen.lua file, and saw that there is even a node_stone variable, that almost does what I want. In fact, I managed to get biomes full of my nodes as a test, going down to y=-32 or so.

But what I'd want to is to replace default:stone in every biome with my own, and besides that, I also want to switch it off every 200 nodes downwards.

I looked at the biomes, and while there is an 'underground' biome, it seems to not have a set node_stone; the game seems to just accept that the 'filler' node for underground is going to be default:stone.

So, basically, can I somehow get what are basically geological layers? I've even tried dissecting other mods that seem to try to do the same, but I really can't wrap my head around the codes.

Really, I think the 'underground' biome is the biggest problem here. Well, I just have a feeling if that I replaced those with different "biomes" of layers of different stones, I could get what I want. But I'd like to only make a mod as of yet, not a subgame.
 

KCoombes
Member
 
Posts: 278
Joined: Thu Jun 11, 2015 23:19
In-game: Knatt or Rudilyn

Re: Post your modding questions here

by KCoombes » Sun Jul 03, 2016 01:29

If you don't care what name it's called in debug mode (f5), use minetest.override_item - you still have to define your nodes (create a nodes.lua file for this), define your biomes (create a mapgen.lua file for this), then lastly an overrides.lua file to declare your overrides. Add a depends.txt file (containing the word "default") to these and dump everything in a folder called 'mymod' (or whatever), plus put your textures in a folder called 'textures' in the mymod folder. Oh a new thing I've seen in 0.4.14 - add a mod.config file with just "name = (insert modname here)" to your main folder (without the ()'s or the ""'s).

Create a new world, enable your mod in 'configure' and test it out (go mining).
 

Cerapter
New member
 
Posts: 4
Joined: Sat Jul 02, 2016 14:38
GitHub: LordCerapter
In-game: Cerapter

Re: Post your modding questions here

by Cerapter » Sun Jul 03, 2016 10:52

I don't think that is what I want or need, but thanks anyway. It seems override_item cannot override biomes, or at least, that's what the wiki says.

But even if it does, I want to turn off the 'underground' biome, not override it, unless I could somehow get it to never appear — I wonder if setting the minimal y larger than the maximal y would make it never appear, as technically, no placement would fill those requirements, right?

Also, I love how you explained how to set up a mod folder, but chose to not elaborate on minetest.override_item — one would think you would explain the thing not detailed in every tutorial about Minetest modding. Not picking on you here, just found it funny.
 

KCoombes
Member
 
Posts: 278
Joined: Thu Jun 11, 2015 23:19
In-game: Knatt or Rudilyn

Re: Post your modding questions here

by KCoombes » Sun Jul 03, 2016 12:13

Oh sorry - I thought you wanted to create your own biomes (hence the detailed how-to) - if all you want is to not have the underground biome, find the mapgen.lua file in the minetest/games/minetest_game/mods/default folder and find the entry for register.biome "underground" (around line 825) and comment the entry out (825 through 841 or so)

As for why I detailed setting up custom biomes but did not define override_item : loads of modding resources/lua.api resources cover it, but not one resource for explaining exactly how to make it all work together.
 

Cerapter
New member
 
Posts: 4
Joined: Sat Jul 02, 2016 14:38
GitHub: LordCerapter
In-game: Cerapter

Re: Post your modding questions here

by Cerapter » Sun Jul 03, 2016 13:09

Ah, again, that solution is not good; I can't really tell people to comment out something in their games if they want to use my mod.

But anyways, I managed to get what I wanted to by just having my stones be generated as sheet-style ores in default:stone. Granted, that still leaves default:stone around, but eh, it's not that big of a deal.
 

User avatar
TumeniNodes
Member
 
Posts: 1335
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes

Re: Post your modding questions here

by TumeniNodes » Tue Jul 05, 2016 17:08

222 wrote:I was hoping to write recipes for TumeniNodes' angledstairs mod; I was wondering if there was an easier way to write it without listing every single variant.

I saw how 'stairs' has one recipe with 'subname' and "recipeitem" but I don't understand how it works.


I'll take a look at this and see if I can help.
I am no good at coming up with recipes though...
Flick?... Flick who?
 

teh_newbz
New member
 
Posts: 3
Joined: Sat Jul 02, 2016 10:48

Re: Post your modding questions here

by teh_newbz » Wed Jul 06, 2016 07:33

How can I get the direction the player is facing as X+/X-/Z+/Z-?

I looked into get_look_dir() but I couldn't find any examples.
Last edited by teh_newbz on Wed Jul 06, 2016 08:30, edited 1 time in total.
 

User avatar
D00Med
Member
 
Posts: 712
Joined: Sat Feb 07, 2015 22:49
GitHub: D00Med

Re: Post your modding questions here

by D00Med » Wed Jul 06, 2016 07:57

Is this what you are looking for?:
get_look_dir()
Look! I have a signature :]
My subgame: https://forum.minetest.net/viewtopic.php?f=15&t=14051#p207242
dmobs2 is coming...
 

teh_newbz
New member
 
Posts: 3
Joined: Sat Jul 02, 2016 10:48

Re: Post your modding questions here

by teh_newbz » Wed Jul 06, 2016 08:19

D00Med wrote:Is this what you are looking for?:
get_look_dir()


Can you provide an example of get_look_dir()? I'm having a bit of trouble understanding how to use it
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

Re: Post your modding questions here

by paramat » Wed Jul 06, 2016 08:34

Cerapter.

> while there is an 'underground' biome, it seems to not have a set node_stone

The line is commented out so that it falls back to the default of stone.

You need to write a mod (depending on default) that at the start does 'minetest.clear_registered_biomes'
Then copy-paste all the biome registrations from default/mapgen.lua and edit to what you want.

For every surface biome: replace (or add) 'node stone' with your own stone and change ymin to y = -200.
Change the 'underground biome' to have ymax = -200 ymin = -400 and add your own 'node stone'.
Add additional underground biomes each 200 thick, each with chosen stone.

This won't work in mgv6 though, biomes are hardcoded, use sheet ore instead for that.
 

User avatar
D00Med
Member
 
Posts: 712
Joined: Sat Feb 07, 2015 22:49
GitHub: D00Med

Re: Post your modding questions here

by D00Med » Wed Jul 06, 2016 09:11

teh_newbz wrote:Can you provide an example of get_look_dir()? I'm having a bit of trouble understanding how to use it

Ok, here is what I use it for:
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_use = function(itemstack, placer, pointed_thing)
         local dir = placer:get_look_dir();
         local playerpos = placer:getpos();
         local obj = minetest.env:add_entity({x=playerpos.x+dir.x,y=playerpos.y+1.5+dir.y,z=playerpos.z+0+dir.z}, "scifi_mobs:bfg_shot")
         local vec = {x=dir.x*6,y=dir.y*6,z=dir.z*6}
Look! I have a signature :]
My subgame: https://forum.minetest.net/viewtopic.php?f=15&t=14051#p207242
dmobs2 is coming...
 

Cerapter
New member
 
Posts: 4
Joined: Sat Jul 02, 2016 14:38
GitHub: LordCerapter
In-game: Cerapter

Re: Post your modding questions here

by Cerapter » Wed Jul 06, 2016 09:18

paramat wrote:'minetest.clear_registered_biomes'

Ah right, there is that thing too!
Totally forgot about that, even though default.register_biomes() starts with it. I suppose I have just always skimmed over that.

I'll try fiddling around with that to see what happens.

EDIT: Nevermind, this fucks me over.
paramat wrote:> Do I have to define biomes in such a way that only ONE biome type can match any given combination of altitude, temp, and humidity?

Yes.

I think this might be way out of my league for now, and should start with something simpler.
 

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

Re: Post your modding questions here

by burli » Fri Jul 08, 2016 10:20

Is it possible to get only walkable nodes or how can I check for walkable nodes?
 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

Re: Post your modding questions here

by Hybrid Dog » Fri Jul 08, 2016 11:13

burli wrote:Is it possible to get only walkable nodes or how can I check for walkable nodes?

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 def = minetest.registered_nodes[node.name]
if not def then
-- unknown node
return
end
local walkable = def.walkable
 

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

Re: Post your modding questions here

by burli » Fri Jul 08, 2016 11:21

Thanks, but walkable is only defined if a node is not walkable.

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("default:stone", {
   description = "Stone",
   tiles = {"default_stone.png"},
   groups = {cracky = 3, stone = 1},
   drop = 'default:cobble',
   legacy_mineral = true,
   sounds = default.node_sound_stone_defaults(),
})


So I have to assume that walkable = nil means walkable = true?
 

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

Re: Post your modding questions here

by Krock » Fri Jul 08, 2016 12:09

burli wrote:So I have to assume that walkable = nil means walkable = true?

No, because it uses the default value 'true' when it's not defined in the node def.
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>
 

Mad Alchemist
New member
 
Posts: 4
Joined: Fri Jul 08, 2016 17:26

Re: Post your modding questions here

by Mad Alchemist » Fri Jul 08, 2016 17:40

How to add a new liquid to minetest? I have added a sulphur, which can be used as fuel or crafted to acid. But when I place acid from bucket on solid block, it appears like block and don't flow :(
This works fine:
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
bucket.register_liquid(
    "nether:acid_source",
    "nether:acid_flowing",
    "nether:acid_bucket",
    "bucket_acid.png",
    "Acid bucket")


I think problem is here, but can't find it:
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("nether:acid_source", {
    description = "Acid Source",
    drawtype = "liquid",
    tiles = {
      {
          name = "acid_source_animated.png",
          animation = {
            type = "vertical_frames",
            aspect_w = 16,
            aspect_h = 16,
            length = 2.0,
          },
      },
    },
    special_tiles = {
      -- New-style lava source material (mostly unused)
      {
         name = "acid_source_animated.png",
         animation = {
            type = "vertical_frames",
            aspect_w = 16,
            aspect_h = 16,
            length = 3.0,
         },
         backface_culling = false,
      },
   },
   alpha = 160,
   paramtype = "light",
   walkable = false,
   pointable = false,
   diggable = false,
   buildable_to = true,
   is_ground_content = false,
   drop = "",
   drowning = 1,
   liquidtype = "flowing",
   liquid_viscosity = 1,
   liquid_renewable = false,
   liquid_range = 2,
  damage_per_second = 4,
   post_effect_color = {a = 103, r = 30, g = 76, b = 90},
   groups = {liquid = 2, puts_out_fire = 1},
})
minetest.register_node("nether:acid_flowing", {
   description = "Flowing Acid",
   drawtype = "flowingliquid",
   tiles = {"acid.png"},
   special_tiles = {
      {
         name = "acid_flowing_animated.png",
         backface_culling = false,
         animation = {
            type = "vertical_frames",
            aspect_w = 16,
            aspect_h = 16,
            length = 0.8,
         },
      },
      {
         name = "acid_flowing_animated.png",
         backface_culling = true,
         animation = {
            type = "vertical_frames",
            aspect_w = 16,
            aspect_h = 16,
            length = 0.8,
         },
      },
   },
   alpha = 160,
   paramtype = "light",
   paramtype2 = "flowingliquid",
   walkable = false,
   pointable = false,
   diggable = false,
   buildable_to = true,
   is_ground_content = false,
   drop = "",
   drowning = 1,
   liquidtype = "flowing",
   --liquid_alternative_flowing = "default:river_water_flowing",
   --liquid_alternative_source = "default:river_water_source",
   liquid_viscosity = 1,
   liquid_renewable = false,
   liquid_range = 2,
  damage_per_second = 4,
  post_effect_color = {a = 103, r = 30, g = 76, b = 90},
   groups = {liquid = 2, puts_out_fire = 1,
      not_in_creative_inventory = 1},
})

Code is mostly copypasted from lava and water code.
 

User avatar
everamzah
Member
 
Posts: 490
Joined: Thu Jan 29, 2015 00:47
GitHub: everamzah
IRC: everamzah
In-game: everamzah

Re: Post your modding questions here

by everamzah » Fri Jul 08, 2016 19:57

I'm guessing, but maybe it's the commented out alternative stuff, where river water is defined.
 

Mad Alchemist
New member
 
Posts: 4
Joined: Fri Jul 08, 2016 17:26

Re: Post your modding questions here

by Mad Alchemist » Fri Jul 08, 2016 21:03

I'm guessing, but maybe it's the commented out alternative stuff, where river water is defined.

Yes, now acid flows.
But I still can't ignite sulphur block with flint and steel.
 

User avatar
everamzah
Member
 
Posts: 490
Joined: Thu Jan 29, 2015 00:47
GitHub: everamzah
IRC: everamzah
In-game: everamzah

Re: Post your modding questions here

by everamzah » Fri Jul 08, 2016 21:53

Flint & Steel checks for a node below with a flammable group rating. I don't know if that's what you want, but I guess you could try making the liquid flammable. You'll likely want to remove the 'puts_out_fire' group rating.
 

Mad Alchemist
New member
 
Posts: 4
Joined: Fri Jul 08, 2016 17:26

Re: Post your modding questions here

by Mad Alchemist » Sat Jul 09, 2016 11:05

But I want to make flammable sulphur block, not acid. (bucket_acid = bucket_water + nether:sulphur)
 

User avatar
everamzah
Member
 
Posts: 490
Joined: Thu Jan 29, 2015 00:47
GitHub: everamzah
IRC: everamzah
In-game: everamzah

Re: Post your modding questions here

by everamzah » Sat Jul 09, 2016 14:40

Again, flint & steel checks for a `flammable' group rating. If you want flammable sulfur - and it is not already flammable - then add `flammable = 1' (or such) to groups = {} in the node definition for sulfur.
 

Mad Alchemist
New member
 
Posts: 4
Joined: Fri Jul 08, 2016 17:26

Re: Post your modding questions here

by Mad Alchemist » Sat Jul 09, 2016 18:29

Ok, now all works fine. I have also created mod "glowwater"- harmless glowing liquid made from nether:acid and nether:glowstone, and glowwater lamps made from glass and glowwater.
I want to create one big mod with alchemy and magic, but don't know how to move "sulphur" from "nether" mod to new mod, because it is in map generation code (see attachment).
Attachments
glowwater.zip
Glowwater and glowwater lamps. Depends on my modified "nether", will not work with original one :( How to fix?
(16.94 KiB) Downloaded 89 times
nether.zip
My modified version of "nether" mod, added sulphur and acid).
(106.94 KiB) Downloaded 92 times
 

User avatar
Sirmentio
Member
 
Posts: 18
Joined: Thu Apr 21, 2016 17:22
In-game: Sirmentio

Re: Post your modding questions here

by Sirmentio » Mon Jul 11, 2016 16:37

Hello! Is it possible to have player specific variables that affect said players?
 

User avatar
everamzah
Member
 
Posts: 490
Joined: Thu Jan 29, 2015 00:47
GitHub: everamzah
IRC: everamzah
In-game: everamzah

Re: Post your modding questions here

by everamzah » Mon Jul 11, 2016 17:13

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 players = {}
minetest.register_on_joinplayer(function(player)
    players[player:get_player_name()] = 1
end)
minetest.register_on_leaveplayer(function(player)
    players[player:get_player_name()] = nil
end)
minetest.register_on_dieplayer(function(player)
    players[player:get_player_name()] = players[player:get_player_name()] + 1
    player:set_physics_override({speed = players[player:get_player_name()]})
end)


Go faster every time you die?
 

User avatar
Sirmentio
Member
 
Posts: 18
Joined: Thu Apr 21, 2016 17:22
In-game: Sirmentio

Re: Post your modding questions here

by Sirmentio » Mon Jul 11, 2016 18:23

That would work, thanks for the example!

EDIT: I do have one question, would it be possible to save the speeds in minetest.conf?
 

KCoombes
Member
 
Posts: 278
Joined: Thu Jun 11, 2015 23:19
In-game: Knatt or Rudilyn

Re: Post your modding questions here

by KCoombes » Mon Jul 11, 2016 19:33

Sirmentio wrote:That would work, thanks for the example!

EDIT: I do have one question, would it be possible to save the speeds in minetest.conf?


I wouldn't save it there, but create a player database file for that (search the mod forums for one called "db")
 

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

Re: Post your modding questions here

by Krock » Tue Jul 12, 2016 07:45

Sirmentio wrote:would it be possible to save the speeds in minetest.conf?

Yes, see lua_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.setting_set("setting_name", value)
Save: minetest.setting_set("speed_".. player_name, tostring(players[player_name]))
Get:  players[player_name] = tonumber(minetest.setting_get("speed_".. player_name))

But that will flood your minetest.conf file with settings that actually don't belong there. Better create a new file in the world directory, like I did with the last rewrite of "flatgen". With "minetest.serialize" and "minetest.deserialize" you can easily save and load an entire table.
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
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

Re: Post your modding questions here

by burli » Wed Jul 13, 2016 15:56

I want to create a simple lua entity cube. What are the minimum properties to spawn a cube?

The cube should not have a collision box or anything else. The cube should be able to move through nodes
 

PreviousNext

Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron