Post your modding questions here

Anonymous_moose
Member
 
Posts: 38
Joined: Tue Aug 27, 2013 20:25

Re: Post your modding questions here

by Anonymous_moose » Wed Jul 22, 2015 11:35

Hybrid Dog wrote:
Anonymous_moose wrote:I am trying to make a wearable spacesuit that works with 3darmor and moontest. I have figured out how to get the breath to restore, but only cannot find out how to get the game to know if the space suit is being worn. any help would be much appreciated.

l guess you would need to search in the armour inventory slots.

I have tried that, but I really cannot find out how to manipulate the detached inventory slots.
 

bobomb
Member
 
Posts: 101
Joined: Sat May 23, 2015 20:28
GitHub: bobombolo
IRC: bobomb

Re: Post your modding questions here

by bobomb » Wed Jul 22, 2015 16:10

Hybrid Dog wrote:maybe using minetest.after(0, […] could work

that is what I ended up doing.
 

User avatar
cHyper
Member
 
Posts: 587
Joined: Fri May 06, 2011 08:49
IRC: cHyper
In-game: cHyper

Re: Post your modding questions here

by cHyper » Thu Jul 23, 2015 18:51

Hi!

Are there any mods with achivements or Statistics elements.

Thanks
 

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 Jul 23, 2015 20:56

See awards.

Or pilzadams stats.
 

User avatar
cHyper
Member
 
Posts: 587
Joined: Fri May 06, 2011 08:49
IRC: cHyper
In-game: cHyper

Re: Post your modding questions here

by cHyper » Thu Jul 23, 2015 21:28

rubenwardy wrote:See awards.

Or pilzadams stats.




https://forum.minetest.net/viewtopic.php?f=11&t=8127
stats from PilzAdam seems to be a good mod, it functions but is outdated.
 

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

Re: Post your modding questions here

by stu » Sat Jul 25, 2015 17:55

Anonymous_moose wrote:
Hybrid Dog wrote:
Anonymous_moose wrote:I am trying to make a wearable spacesuit that works with 3darmor and moontest. I have figured out how to get the breath to restore, but only cannot find out how to get the game to know if the space suit is being worn. any help would be much appreciated.

l guess you would need to search in the armour inventory slots.

I have tried that, but I really cannot find out how to manipulate the detached inventory slots.


This should do 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
local inv = player:get_inventory()
if inv:contains_item("armor", "your_mod_name:spacesuit") then
   --Do Stuff
end
 

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 » Sun Jul 26, 2015 18:19

[Bones mod in Minetest_game]

I would like to know how to stop bones from disappearing when punched or getting removed when their emptied. In other words, I want to be able to collect bones.
I don't know what lines I must remove or rewrite.
+ Code from the version of bones mod I am currently using

Thanks in advance
 

User avatar
ExeterDad
Member
 
Posts: 1121
Joined: Sun Jun 01, 2014 20:00
In-game: ExeterDad

Re: Post your modding questions here

by ExeterDad » Sun Jul 26, 2015 20:50

look 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
      -- remove bones if player emptied them


Then change 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
      -- remove bones if player emptied them
      if has_space then
         minetest.remove_node(pos)
      end

to 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
     -- remove bones if player emptied them
      -- if has_space then
         -- minetest.remove_node(pos)
     --  end
Last edited by ExeterDad on Mon Jul 27, 2015 14:28, edited 1 time in total.
٩(̾●̮̮̃̾•̃̾)۶

Kibbie and I have a beautiful public server now! HOMETOWN
 

Anonymous_moose
Member
 
Posts: 38
Joined: Tue Aug 27, 2013 20:25

Re: Post your modding questions here

by Anonymous_moose » Sun Jul 26, 2015 21:41

Thanks stu!
 

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 » Mon Jul 27, 2015 12:58

Thanks ExeterDad! :D
 

bobomb
Member
 
Posts: 101
Joined: Sat May 23, 2015 20:28
GitHub: bobombolo
IRC: bobomb

Re: Post your modding questions here

by bobomb » Mon Jul 27, 2015 19:48

what is the best method to determine surface height given an x,z coordinate? is there something in the lua api? is there a preferred algorithm?

i found this but it was never merged? https://github.com/minetest/minetest/pull/640

thanks
 

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

Re: Post your modding questions here

by Hybrid Dog » Tue Jul 28, 2015 15:00

bobomb wrote:what is the best method to determine surface height given an x,z coordinate? is there something in the lua api? is there a preferred algorithm?

i found this but it was never merged? https://github.com/minetest/minetest/pull/640

thanks

ln which situation do you need to find out the surface height?
mapgen for example offers a heightmap mapgen_object
 

bobomb
Member
 
Posts: 101
Joined: Sat May 23, 2015 20:28
GitHub: bobombolo
IRC: bobomb

Re: Post your modding questions here

by bobomb » Wed Jul 29, 2015 02:21

i have solved this but the situation is not a mapgen situation. it is after the world is generated.

I ended up converting a function made for core that was never merged from: https://github.com/sapier/minetest/blob/c6f814b52a5e2b2f12c76215db3524571c56fe20/src/environment.cpp#L868

here it is:
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 get_surface(basepos, searchup, searchdown, walkable_only)

   local max = searchup + basepos.y
   if searchdown then basepos.y = basepos.y - searchdown end
   local last_node = minetest.get_node(basepos)
   local node = last_node
   local runpos = basepos

   local last_was_walkable = node.walkable

   while ( runpos.y < max and minetest.get_content_id(node.name) ~= c_air ) do
      runpos.y = runpos.y + 1
      last_node = node
      node = minetest.get_node(runpos)

      if not (walkable_only) then
         if minetest.get_content_id(last_node.name) ~= c_air
         and minetest.get_content_id(last_node.name) ~= c_ignore
         and minetest.get_content_id(node.name) == c_air then
            return runpos.y
         end
      else
         local is_walkable = node.walkable
         if last_was_walkable and not is_walkable then
            return runpos.y
         end
         last_was_walkable = is_walkable
      end
   end

   return basepos.y - 1
end


there are still some issues with this, like it returns max when nothing no air was detected, and it returns 0 when no ground was detected. also i don't know how to test for "is_walkable" in lua. how does one test a node for various group memberships, and is walkability a group or something else in the lua api?
 

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

Re: Post your modding questions here

by Hybrid Dog » Wed Jul 29, 2015 15:40

bobomb wrote:i have solved this but the situation is not a mapgen situation. it is after the world is generated.

I ended up converting a function made for core that was never merged from: https://github.com/sapier/minetest/blob/c6f814b52a5e2b2f12c76215db3524571c56fe20/src/environment.cpp#L868

here it is:
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 get_surface(basepos, searchup, searchdown, walkable_only)

   local max = searchup + basepos.y
   if searchdown then basepos.y = basepos.y - searchdown end
   local last_node = minetest.get_node(basepos)
   local node = last_node
   local runpos = basepos

   local last_was_walkable = node.walkable

   while ( runpos.y < max and minetest.get_content_id(node.name) ~= c_air ) do
      runpos.y = runpos.y + 1
      last_node = node
      node = minetest.get_node(runpos)

      if not (walkable_only) then
         if minetest.get_content_id(last_node.name) ~= c_air
         and minetest.get_content_id(last_node.name) ~= c_ignore
         and minetest.get_content_id(node.name) == c_air then
            return runpos.y
         end
      else
         local is_walkable = node.walkable
         if last_was_walkable and not is_walkable then
            return runpos.y
         end
         last_was_walkable = is_walkable
      end
   end

   return basepos.y - 1
end


there are still some issues with this, like it returns max when nothing no air was detected, and it returns 0 when no ground was detected. also i don't know how to test for "is_walkable" in lua. how does one test a node for various group memberships, and is walkability a group or something else in the lua api?

node.walkable is nil because node is from minetest.get_node(pos), which returns a table containing the name, param1 and param2 of the node at pos
this function should test if a node is 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
-- is_walkable(minetest.get_node(pos).name)

local function is_walkable(name)
local data = minetest.registered_nodes[name]
if not data then
return false
end
return not (data.walkable == false)
end

walkable is not a group, it's something of the node definition, groups is something of the node definition, too
if you want to find out if a node is in a specific group, there's a function for it http://dev.minetest.net/minetest.get_item_group
 

bobomb
Member
 
Posts: 101
Joined: Sat May 23, 2015 20:28
GitHub: bobombolo
IRC: bobomb

Re: Post your modding questions here

by bobomb » Wed Jul 29, 2015 17:26

i knew that walkable code would not work, anyway here is a complete translation of sapier's function without any changes like "downsearch" which is redundant. (still need to deal with cases of no top found / no bottom found)
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
-- a lua rewrite of sapier's get_surface() proposal, see:
-- https://github.com/sapier/minetest/blob/c6f814b52a5e2b2f12c76215db3524571c56fe20/src/environment.cpp#L868
function get_surface(basepos, searchup, walkable_only)

   local max = searchup + basepos.y
   local last_node = minetest.get_node(basepos)
   local node = last_node
   local runpos = basepos

   local last_was_walkable = minetest.registered_nodes[node.name].walkable

   while ( runpos.y < max and minetest.get_content_id(node.name) ~= c_air ) do
      runpos.y = runpos.y + 1
      last_node = node
      node = minetest.get_node(runpos)

      if not (walkable_only) then
         if minetest.get_content_id(last_node.name) ~= c_air
         and minetest.get_content_id(last_node.name) ~= c_ignore
         and minetest.get_content_id(node.name) == c_air then
            return runpos.y
         end
      else
         local is_walkable = minetest.registered_nodes[node.name].walkable
         if last_was_walkable and not is_walkable then
            return runpos.y
         end
         last_was_walkable = is_walkable
      end
   end

   return basepos.y - 1
end
 

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 » Wed Jul 29, 2015 20:21

Hybrid Dog 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
local data = minetest.registered_nodes[name]if not data then
    return false
end
return not (data.walkable == false)



Would be simpler as:

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
return data and data.walkable


Table look ups can be costly. minetest.get_node can also be costly. get_node will return { name = "ignore" } is the MapBlock hasn't been loaded yet. Node that there may be stacked worlds - floating lands etc at 30000 (in the future) and you may be in a cave.
 

bobomb
Member
 
Posts: 101
Joined: Sat May 23, 2015 20:28
GitHub: bobombolo
IRC: bobomb

Re: Post your modding questions here

by bobomb » Thu Jul 30, 2015 04:29

Thanks Ruben. I am going to revise the function to handle caves and skylands, one way or another. My first approach was to make it relative to the player, but anyway that is on the to do list...

is Hybrid Dog's function necessary or can I just do
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
return minetest.registered_nodes[node.name].walkable


i know node name exists because that's what's being tested.
 

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 Jul 30, 2015 07:44

There may be unknown nodes in the world, this will cause the game to crash.
 

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

Re: Post your modding questions here

by Hybrid Dog » Thu Jul 30, 2015 14:26

rubenwardy wrote:
Hybrid Dog 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
local data = minetest.registered_nodes[name]if not data then
    return false
end
return not (data.walkable == false)

[/quote

Would be simpler as:

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
return data and data.walkable

l'm not sure if this works.
But you could short it this way:
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 data = minetest.registered_nodes[name]
return data and data.walkable ~= false
 

bobomb
Member
 
Posts: 101
Joined: Sat May 23, 2015 20:28
GitHub: bobombolo
IRC: bobomb

Re: Post your modding questions here

by bobomb » Thu Jul 30, 2015 20:16

I rewrote the function to scan from the top down which is much simpler and deals with caves and overhangs at least in a basic way:
https://gist.github.com/bobombolo/6127b153228344eb037a
 

User avatar
SAMIAMNOT
Member
 
Posts: 363
Joined: Wed Sep 03, 2014 00:51
In-game: notanewbie

Re: Post your modding questions here

by SAMIAMNOT » Sat Aug 01, 2015 03:08

How do you spawn nodes and/or mobs? I tried modding the More Mesecons mod and changed the add_item function to add_node but that did not work for the Mobs Redo mob NPCs.
I test mines.
 

User avatar
Nathan.S
Member
 
Posts: 679
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21

Re: Post your modding questions here

by Nathan.S » Sat Aug 01, 2015 15:44

Doubtless I'm just an idiot but can somebody tell me what is wrong with 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
if inv:contains_item('fuel', 'group:tree') then

It works just fine for non-groups, but I want to support multiple fuels as inputs in a smoker I'm making. I suppose I could just do a chain of if statements but a group would be quicker and easier.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website.
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: Post your modding questions here

by kaeza » Sat Aug 01, 2015 21:53

Note: UNTESTED:

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 is_item_in_group(itemname, group)
  local def = minetest.registered_items[name]
  if not def then return end
  return (def.groups and (def.groups[group] or 0)>0)
end
-- In your code (this assumes "fuel" inv only has a single slot):
-- ...
local item = inv:get_stack("fuel", 1)
local fuel_groups = { "tree", "wood", "oil", "radiactive" } -- Groups considered "fuel"
if item and (not item:is_empty()) then
  for _, g in ipairs(fuel_groups) do
    if is_item_in_group(item:get_name(), g) then
      -- We found some fuel. Do something with it.
      return
    end
  end
end
-- ...


Adapt as necessary.

Of course, the proper solution would be to implement group resolution or whatever in `contains_item`.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

User avatar
Nathan.S
Member
 
Posts: 679
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21

Re: Post your modding questions here

by Nathan.S » Sun Aug 02, 2015 14:43

Thank you so much kaeza, this looks like it should work. I just want people to be able to use logs, so I'll just be using the tree group. I tried just making a table and doing a if in table, which I know would work in python, but unfortunately LUA doesn't have that same feature.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website.
 

minetestcr
Member
 
Posts: 57
Joined: Fri Feb 13, 2015 21:31

Re: Post your modding questions here

by minetestcr » Mon Aug 10, 2015 15:20

Hello!

Is there a way to have one user in creative mode while the others are not? It would be the server admin in creative mode, and the players in survival.

thanks.
 

User avatar
benrob0329
Member
 
Posts: 1192
Joined: Thu Aug 06, 2015 22:39
GitHub: Benrob0329
In-game: benrob03

Re: Post your modding questions here

by benrob0329 » Mon Aug 10, 2015 15:29

Unified Inventory has a creative priv, that could work.
 

minetestcr
Member
 
Posts: 57
Joined: Fri Feb 13, 2015 21:31

Re: Post your modding questions here

by minetestcr » Mon Aug 10, 2015 17:39

benrob0329 wrote:Unified Inventory has a creative priv, that could work.



Thanks benrob0329.
 

User avatar
BrunoMine
Member
 
Posts: 902
Joined: Thu Apr 25, 2013 17:29
GitHub: BrunoMine

Re: Post your modding questions here

by BrunoMine » Wed Aug 12, 2015 21:21

how to identify the lag of a client. I do not care only server lag, but each client individually.
 

User avatar
Semmett9
Member
 
Posts: 149
Joined: Sun Oct 07, 2012 13:48

Re: Post your modding questions here

by Semmett9 » Thu Aug 13, 2015 08:56

How to activate a file if a mod is installed?

Is they a way to activate a file or bit of code if a mod is installed.

I have just mad a mod called "Beer_Test" and I’m currently working on a new mod "Farm_Test". Is they a way for me to add a line of code which looks for a mod called "Beer_Test"; and if it finds it will then activate some code which connects the two mods together.

Many Thanks
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: Post your modding questions here

by kaeza » Thu Aug 13, 2015 09:21

You need to add a file named `depends.txt` to the `farm_test` mod (if it doesn't already have one), and add this line to the file:

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
beer_test?


This ensures the `beer_test` mod gets loaded first if found, but the mod is not required (i.e. it is optional).

Then, in `farm_test/init.lua` (or wherever appropriate), you use code 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
if minetest.get_modpath("beer_test") then
  -- beer_test is installed. Add some glue code, extra items, etc. here.
end
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

PreviousNext

Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 5 guests

cron