Post your modding questions here

User avatar
mahmutelmas06
Member
 
Posts: 355
Joined: Mon Mar 02, 2015 13:10
GitHub: mahmutelmas06
IRC: mahmutelmas06
In-game: masum

Re: Post your modding questions here

by mahmutelmas06 » Tue Nov 17, 2015 01:39

rubenwardy wrote:If you're willing to use the food mod (you can just install the library bit of it "food", you don't need to install the food that comes with it, "food_basic")

https://github.com/rubenwardy/food/blob ... rt.lua#L20
https://github.com/rubenwardy/food/blob ... ua#L19-L64

If you're not willing to, the just reinplement the function linked to by the second link. (If you just copy and paste, then you need to follow the GPL license.)


Thank you. I have seen your code before and i was curious if it could be problem to copy paste.
And i am using your food mod personally which is very good mod with no unnecessary items.

I am preparing a beverage mod wich provides various drinks.
But i dont want to hard dependecies to any mode thats why i asked for.
My Mods:

Beverage
 

User avatar
Don
Member
 
Posts: 1641
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Post your modding questions here

by Don » Tue Nov 17, 2015 03:34

Are you wanting to do something 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
o = {"farming:orange", "farming_plus:orange", "farming_redo:orange"}
for i, orange in pairs (o) do
--craft goes here with orange as the variable
end
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here
 

User avatar
mahmutelmas06
Member
 
Posts: 355
Joined: Mon Mar 02, 2015 13:10
GitHub: mahmutelmas06
IRC: mahmutelmas06
In-game: masum

Re: Post your modding questions here

by mahmutelmas06 » Tue Nov 17, 2015 14:48

Both codes are what i have wanted
Thank you for help
My Mods:

Beverage
 

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 » Tue Nov 17, 2015 22:40

mahmutelmas06 wrote:Thank you. I have seen your code before and i was curious if it could be problem to copy paste.
And i am using your food mod personally which is very good mod with no unnecessary items.

I am preparing a beverage mod wich provides various drinks.
But i dont want to hard dependecies to any mode thats why i asked for.


Everything in food/food/ is now wtfpl.
Eg, food/food/init.lua

food_basic/support.lua is WTFPL as well, just not the other files in food_basic
 

DoyleChris
Member
 
Posts: 176
Joined: Sat Jul 25, 2015 19:54
In-game: DoyleChris

Re: Post your modding questions here

by DoyleChris » Sat Nov 21, 2015 21:58

Stairs.jpg
Stairs
Stairs.jpg (108.82 KiB) Viewed 2896 times

I have a wall question. In the picture i set up some stairs going up and stairs going down. I am using HomeDecor as a mod. In the picture you see the back of the stairs going up and the hole going down to the basement. I put railings on the stairs going up but i am trying to figure out how to fill in behind the stairs going up.

1. Code to use a wall to fill it in, but i dont want to use a full block to build the wall if i can put a portion up against the side closest to the stairs like the railing. Like the red section in the picture.
2. Use the railing for that but if i do it angles up to the stairs when i want it to be level.
 

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

Re: Post your modding questions here

by Hybrid Dog » Sun Nov 22, 2015 00:33

If you use homedecor, you can place that fence as wall, can't you?
 

User avatar
mahmutelmas06
Member
 
Posts: 355
Joined: Mon Mar 02, 2015 13:10
GitHub: mahmutelmas06
IRC: mahmutelmas06
In-game: masum

Re: Post your modding questions here

by mahmutelmas06 » Sun Nov 22, 2015 22:18

How to use that nodes on_use function. I tried this but what is wrong ?
I hear sound but eat function doesnt work.


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, user, pointed_thing)
            minetest.sound_play("beverage_hot", {
                     pos = {x=0, y=0, z=0},
                     max_hear_distance = 30,
                     gain = 10.0,})
                           minetest.item_eat(5, "beverage:cup")
                  itemstack:take_item()
            return itemstack
            end,
My Mods:

Beverage
 

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 Nov 22, 2015 22:24

That's not how item_eat works. The documentation seems to be wrong.
item_eat returns a function to be used on_use.

For example:

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 = minetest.item_eat(5)


goes to

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, user, pointed_thing)
     -- code to eat
end


You want minetest.do_item_eat
 

User avatar
mahmutelmas06
Member
 
Posts: 355
Joined: Mon Mar 02, 2015 13:10
GitHub: mahmutelmas06
IRC: mahmutelmas06
In-game: masum

Re: Post your modding questions here

by mahmutelmas06 » Sun Nov 22, 2015 23:42

I know that on_use = minetest.item_eat(5) works well. But i want to get a sound played too when it used.
(by the way your documentation is very nice)
My Mods:

Beverage
 

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 » Mon Nov 23, 2015 00:12

Replace item et with:

return minetest.item_eat(5)(itemstack, user, pointed_thing)
 

User avatar
mahmutelmas06
Member
 
Posts: 355
Joined: Mon Mar 02, 2015 13:10
GitHub: mahmutelmas06
IRC: mahmutelmas06
In-game: masum

Re: Post your modding questions here

by mahmutelmas06 » Mon Nov 23, 2015 02:05

thank you. I will try tomorrow.
My Mods:

Beverage
 

User avatar
maikerumine
Member
 
Posts: 946
Joined: Mon Aug 04, 2014 14:27
GitHub: maikerumine
In-game: maikerumine

how to: get_puncher_name help

by maikerumine » Mon Nov 23, 2015 22:11

Hi

I am trying to get puncher name for a mod but it only accepts either owner or player.

So is there a way I can get the puncher/hitter name from the one actually punching?
Image
See the () bit? that is where I want the puncher/hitter's name to be.
This line of code needs to find a puncher name so it can be called:
L175..
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 puncher_name = player:get_puncher_name()

in the bottom code:
L250..
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
meta:set_string("infotext", player_name.." was killed".." at ".. time.year .. "/".. time.month .. "/" .. time.day .. ", " ..time.hour.. ":".. time.min .." by: ("..puncher_name..")");


ERROR
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
2015-11-23 17:01:52: ACTION[Server]: Player ADMIN punched by player wow13, damage 4 HP
2015-11-23 17:01:52: ERROR[Main]: UNRECOVERABLE error occurred. Stopping server. Please fix the following error:
2015-11-23 17:01:52: ERROR[Main]: Lua: Runtime error from mod 'bones' in callback on_dieplayer(): E:\MT\bin\..\mods\bones\init.lua:179: attempt to call method 'get_puncher_name' (a nil value)



FULL MODDED BONES 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 0.5 mod: bones
-- See README.txt for licensing and other information.
--REVISED 20151117 by maikerumine for adding bones to inventory after punch

bones = {}


local function is_owner(pos, name)
   local owner = minetest.get_meta(pos):get_string("owner")
   if owner == "" or owner == name then
      return true
   end
   return false
end

bones.bones_formspec =
   "size[8,9]"..
   default.gui_bg..
   default.gui_bg_img..
   default.gui_slots..
   "list[current_name;main;0,0.3;8,4;]"..
   "list[current_player;main;0,4.85;8,1;]"..
   "list[current_player;main;0,6.08;8,3;8]"..
   default.get_hotbar_bg(0,4.85)

--local share_bones_time = tonumber(minetest.setting_get("share_bones_time") or 1200)--ORIGINAL TIME
local share_bones_time = tonumber(minetest.setting_get("share_bones_time") or 600)--DEBUGGING TIME
local share_bones_time_early = tonumber(minetest.setting_get("share_bones_time_early") or (share_bones_time/4))

minetest.register_node("bones:bones", {
   description = "Bones",
   tiles = {
      "bones_top.png",
      "bones_bottom.png",
      "bones_side.png",
      "bones_side.png",
      "bones_rear.png",
      "bones_front.png"
   },
   paramtype2 = "facedir",
   groups = {cracky = 2, oddly_breakable_by_hand = 2},
--   groups = {dig_immediate=1},
   sounds = default.node_sound_dirt_defaults({
      footstep = {name="default_gravel_footstep", gain=0.5},
      dug = {name="default_gravel_footstep", gain=1.0},
   }),
   
   can_dig = function(pos, player)
      local inv = minetest.get_meta(pos):get_inventory()
      return is_owner(pos, player:get_player_name()) and inv:is_empty("main")
   end,
   
   allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
      if is_owner(pos, player:get_player_name()) then
         return count
      end
      return 0
   end,
   
   allow_metadata_inventory_put = function(pos, listname, index, stack, player)
      return 0
   end,
   
   allow_metadata_inventory_take = function(pos, listname, index, stack, player)
      if is_owner(pos, player:get_player_name()) then
         return stack:get_count()
      end
      return 0
   end,
   
   on_metadata_inventory_take = function(pos, listname, index, stack, player)
      local meta = minetest.get_meta(pos)
      if meta:get_inventory():is_empty("main") then
         minetest.remove_node(pos)
      end
   end,
   
   on_punch = function(pos, node, player)
      if(not is_owner(pos, player:get_player_name())) then
         return
      end
      
      local inv = minetest.get_meta(pos):get_inventory()
      local player_inv = player:get_inventory()
      local has_space = true

      for i=1,inv:get_size("main") do
         local stk = inv:get_stack("main", i)
         if player_inv:room_for_item("main", stk) then
            inv:set_stack("main", i, nil)
            player_inv:add_item("main", stk)
            
         else
            has_space = false
            break
         end
      end
      
--ADD GIVE BONE TO INVENTORY WHILST REMOVING NODE
      -- remove bones if player emptied them
      if has_space then
         minetest.remove_node(pos)
         player:get_inventory():add_item('main', 'bones:bones 1')
         --END ADDED BONE TO INV
      end
   
   end,
   
   on_timer = function(pos, elapsed)
      local meta = minetest.get_meta(pos)
      local time = meta:get_int("time") + elapsed--swap this
      if time >= share_bones_time then
      
--BEGIN TIME AFTER BONE EXPIRE   
         local time = os.date("*t");--for this on new map
         meta:set_string("infotext", "R.I.P. ".. meta:get_string("owner").." at ".. time.year .. "/".. time.month .. "/" .. time.day .. ", " ..time.hour.. ":".. time.min ..")");--new old bones code         
         --meta:set_string("infotext", meta:get_string("owner").."'s old bones")--org old bones code
         meta:set_string("owner", "")   
      else
         meta:set_int("time", time)
         return true
      end
   end,
})

local function may_replace(pos, player)
   local node_name = minetest.get_node(pos).name
   local node_definition = minetest.registered_nodes[node_name]

   
   -- if the node is unknown, we let the protection mod decide
   -- this is consistent with when a player could dig or not dig it
   -- unknown decoration would often be removed
   -- while unknown building materials in use would usually be left
   if not node_definition then
      -- only replace nodes that are not protected
      return not minetest.is_protected(pos, player:get_player_name())
   end

   -- allow replacing air and liquids
   if node_name == "air" or node_definition.liquidtype ~= "none" then
      return true
   end

   -- don't replace filled chests and other nodes that don't allow it
   local can_dig_func = node_definition.can_dig
   if can_dig_func and not can_dig_func(pos, player) then
      return false
   end

   -- default to each nodes buildable_to; if a placed block would replace it, why shouldn't bones?
   -- flowers being squished by bones are more realistical than a squished stone, too
   -- exception are of course any protected buildable_to
   return node_definition.buildable_to and not minetest.is_protected(pos, player:get_player_name())
end

minetest.register_on_dieplayer(function(player)--added hitter

   if minetest.setting_getbool("creative_mode") then
      return
   end
   
   local player_inv = player:get_inventory()
   if player_inv:is_empty("main") and
      player_inv:is_empty("craft") then
      return
   end

   local pos = player:getpos()
   pos.x = math.floor(pos.x+0.5)
   pos.y = math.floor(pos.y+0.5)
   pos.z = math.floor(pos.z+0.5)
   local param2 = minetest.dir_to_facedir(player:get_look_dir())
   local player_name = player:get_player_name()
   local puncher_name = player:get_puncher_name()      --is nil?   why??? cannot use hitter:get_hitter_name.  this is the key to adding the hitter.
   local player_inv = player:get_inventory()

   if (not may_replace(pos, player)) then
      if (may_replace({x=pos.x, y=pos.y+1, z=pos.z}, player)) then
         -- drop one node above if there's space
         -- this should solve most cases of protection related deaths in which players dig straight down
         -- yet keeps the bones reachable
         pos.y = pos.y+1
      else
         -- drop items instead of delete
         for i=1,player_inv:get_size("main") do
            minetest.add_item(pos, player_inv:get_stack("main", i))
         end
         for i=1,player_inv:get_size("craft") do
            minetest.add_item(pos, player_inv:get_stack("craft", i))
         end
         -- empty lists main and craft
         player_inv:set_list("main", {})
         player_inv:set_list("craft", {})
         return
      end
   end
   
   minetest.set_node(pos, {name="bones:bones", param2=param2})
   
   local meta = minetest.get_meta(pos)
   local inv = meta:get_inventory()
   inv:set_size("main", 8*4)
   inv:set_list("main", player_inv:get_list("main"))
   
   for i=1,player_inv:get_size("craft") do
      local stack = player_inv:get_stack("craft", i)
      if inv:room_for_item("main", stack) then
         inv:add_item("main", stack)
      else
         --drop if no space left
         minetest.add_item(pos, stack)
      end
   end
   
   player_inv:set_list("main", {})
   player_inv:set_list("craft", {})
   
--BEGIN TIME AT TIME OF DEATH   
---------------------------
--[[
--   if minetest.register_on_punchplayer then
      minetest.register_on_punchplayer(
      function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage)
         if not player or not hitter then
            print("[BoneZ] on_punchplayer called with nil objects")
         end
         if not hitter:is_player() then
            return false
         end
         if minetest.is_protected(pos, hitter:get_player_name()) then
            return true
         else
            return false
         end
      end)
--   end
----------------------------]]




   meta:set_string("formspec", bones.bones_formspec)
   meta:set_string("owner", player_name)
   meta:set_string("puncher",puncher_name)

   if share_bones_time ~= 0 then
      local time = os.date("*t");
--      meta:set_string("infotext", player_name.." was killed".." at ".. time.year .. "/".. time.month .. "/" .. time.day .. ", " ..time.hour.. ":".. time.min .." by: ("..meta:get_string("hitter")..")");---works returns()
      meta:set_string("infotext", player_name.." was killed".." at ".. time.year .. "/".. time.month .. "/" .. time.day .. ", " ..time.hour.. ":".. time.min .." by: ("..puncher_name..")");
--      meta:set_string("infotext", player_name.." was killed".." at ".. time.year .. "/".. time.month .. "/" .. time.day .. ", " ..time.hour.. ":".. time.min .." by: (".. meta:get_string("owner")..")");--prototype code get hittername-change owner to hitter
      --meta:set_string("infotext", player_name.."'s fresh corpse.  :-( R.I.P. ".. meta:get_string("owner").." at ".. time.month .. "/" .. time.day .. ", " ..time.hour.. ":".. time.min ..")");   
      --meta:set_string("infotext", player_name.."'s fresh bones")--old bones code

      if share_bones_time_early == 0 or not minetest.is_protected(pos, player_name) then
         meta:set_int("time", 0)
      else
         meta:set_int("time", (share_bones_time - share_bones_time_early))
      end

      minetest.get_node_timer(pos):start(10)
   else
      meta:set_string("infotext", player_name.."'s bones")
   end

end)

Attachments
bones.png
bones.png (163.41 KiB) Viewed 2896 times
 

User avatar
jp
Member
 
Posts: 705
Joined: Wed Dec 18, 2013 09:03
GitHub: kilbith

Re: Post your modding questions here

by jp » Tue Nov 24, 2015 14:50

Use puncher:get_player_name() instead, inside of on_punch callback.
 

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

Re: Post your modding questions here

by Hybrid Dog » Tue Nov 24, 2015 16:59

sender, hitter, puncher, etc. are all the same, l would like if they get replaced by player, that the player is the one who punched the node in an on_punch function is self evident, isn't it?
 

bark
Member
 
Posts: 35
Joined: Thu Sep 24, 2015 13:25
In-game: bark

Re: Post your modding questions here

by bark » Sat Nov 28, 2015 12:30

I'm puzzled beyond.. Can someone please help me to understand the following?

I'm trying to make a lottery, using a coin I have defined as a craftitem. When I rightclick the lotteryblock with a coin in my inventory, there are three different outcomes:

  • A coin is removed from inventory, and one of the four prizes are awarded to the player (intended function)
  • The coin is not removed from inventory, and the player is still awarded with one of the four prizes
  • The coin is not removed from inventory, and no award is given, but the chat messages announcing the awarded prize are still displayed

All three outcomes occur without server restart and without editing the code. Why does this happen?!

Edit: I discovered that outcome three tends to happen after /clearinv, but not always.

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_craftitem("barkhouse:coin", {
   description = "Coin",
   inventory_image = "barkhouse_coin.png",
})

minetest.register_node("barkhouse:lotteryblock", {
   description = "Lottery Block",
   tiles = {"default_cloud.png"},
   groups = {cracky = 3, stone = 1},
   sounds = default.node_sound_stone_defaults(),
   on_rightclick = function(pos, node, player)
      local inv = player:get_inventory()
      if inv:contains_item("main", "barkhouse:coin") then
         inv:remove_item("main", "barkhouse:coin")
         minetest.chat_send_player(player:get_player_name(),"You spent 1 coin at the lottery.")   
            local random_number = math.random(1, 4) -- Between 1 and 5.
            if random_number == 1 then
            minetest.chat_send_all(player:get_player_name() .. " spent a coin at the lottery and were awarded with Five Nyancat Rainbows!")
            inv:add_item("main", "default:nyancat_rainbow 5")
            return
            elseif random_number == 2 then
            minetest.chat_send_all(player:get_player_name() .. " spent a coin at the lottery and were awarded with Five Diamond Blocks!")
            inv:add_item("main", "default:diamondblock 5")
            return
            elseif random_number == 3 then
            minetest.chat_send_all(player:get_player_name() .. " spent a coin at the lottery and were awarded with Twenty Steel Blocks!")
            inv:add_item("main", "default:steelblock 20")
            return
            elseif random_number == 4 then
            minetest.chat_send_all(player:get_player_name() .. " spent a coin at the lottery and were awarded with Fifty Obsidian!")
            inv:add_item("main", "default:obsidian 50")
            return
         end

      else
         minetest.chat_send_player(player:get_player_name(),"You have no coins...")   
      end
   end,
})
 

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

Re: Post your modding questions here

by TenPlus1 » Sat Nov 28, 2015 15:17

Here is the working 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_craftitem("barkhouse:coin", {
   description = "Coin",
   inventory_image = "barkhouse_coin.png",
})

minetest.register_node("barkhouse:lotteryblock", {
   description = "Lottery Block",
   tiles = {"default_cloud.png"},
   groups = {cracky = 3, stone = 1},
   sounds = default.node_sound_stone_defaults(),
   on_rightclick = function(pos, node, player, itemstack)
      local itemname = itemstack:get_name()
      local inv = player:get_inventory()
      local name = player:get_player_name()
      if itemname == "barkhouse:coin" then
         itemstack:take_item()
         player:set_wielded_item(itemstack)
         minetest.chat_send_player(name,"You spent 1 coin at the lottery.")   
            local random_number = math.random(1, 4) -- Between 1 and 4.
            if random_number == 1 then
            minetest.chat_send_all(name .. " spent a coin at the lottery and were awarded with Five Nyancat Rainbows!")
            inv:add_item("main", "default:nyancat_rainbow 5")
            return
            elseif random_number == 2 then
            minetest.chat_send_all(name .. " spent a coin at the lottery and were awarded with Five Diamond Blocks!")
            inv:add_item("main", "default:diamondblock 5")
            return
            elseif random_number == 3 then
            minetest.chat_send_all(name .. " spent a coin at the lottery and were awarded with Twenty Steel Blocks!")
            inv:add_item("main", "default:steelblock 20")
            return
            elseif random_number == 4 then
            minetest.chat_send_all(name .. " spent a coin at the lottery and were awarded with Fifty Obsidian!")
            inv:add_item("main", "default:obsidian 50")
            return
         end
      else
         minetest.chat_send_player(name,"You have no coins...")
      end
   end,
})
 

bark
Member
 
Posts: 35
Joined: Thu Sep 24, 2015 13:25
In-game: bark

Re: Post your modding questions here

by bark » Sat Nov 28, 2015 17:28

Thanks for your swift reply, TenPlus1! Your code works much better than mine. It now works almost as intended, and the strange bugs described in my previous post are gone.

There is, however, one bug remaining: If the player has the coin equipped, it is not removed from the inventory. If the coin is not equipped, everything works as intended.
 

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

Re: Post your modding questions here

by TenPlus1 » Sat Nov 28, 2015 18:08

The way I made it work was to have the player holding the coins and right clicking the lotto machine, each click results in 1 coin taken away from the pile until all coins are gone.
 

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 » Sat Nov 28, 2015 18:18

You could make it work if the coin isn't equiped like to:

http://rubenwardy.com/minetest_modding_ ... king-items
 

bark
Member
 
Posts: 35
Joined: Thu Sep 24, 2015 13:25
In-game: bark

Re: Post your modding questions here

by bark » Sun Nov 29, 2015 21:03

Thanks for your input! It works perfectly now! :D

I'm going to look into rubenwardy's suggestion when I have some spare time.
 

User avatar
iangp
Member
 
Posts: 114
Joined: Sat May 31, 2014 19:26
GitHub: 14NGiestas
IRC: iangp
In-game: iangp

Re: Post your modding questions here

by iangp » Tue Dec 01, 2015 23:59

Function Revert actions by user does not work?
And There's some way to change textures in game?
That's my mod that I'm working:
viewtopic.php?f=9&t=13672
I have tried this, without sucess:
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_craftitem("time_travel:phone", {
   description = "A common telephone",
   wield_image = "timetravel_phone.png",
   inventory_image = "timetravel_phone.png",
   visual = "sprite",
   physical = true,
   textures = {"timetravel_phone.png"},
   on_use = function(itemstack, user, pointed_thing)
      minetest.rollback_revert_actions_by("player:"..user:get_player_name(), 5) -- hours*minutes*seconds
      --time_travel(user)
      --help --> https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L1343
   end,
})
God's not dead, He's surely alive!
エル プサイ コングルー

My mods (WIP):
 

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

Re: Post your modding questions here

by Hybrid Dog » Wed Dec 02, 2015 15:53

iangp wrote:Function Revert actions by user does not work?
And There's some way to change textures in game?
That's my mod that I'm working:
viewtopic.php?f=9&t=13672
I have tried this, without sucess:
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_craftitem("time_travel:phone", {
   description = "A common telephone",
   wield_image = "timetravel_phone.png",
   inventory_image = "timetravel_phone.png",
   visual = "sprite",
   physical = true,
   textures = {"timetravel_phone.png"},
   on_use = function(itemstack, user, pointed_thing)
      minetest.rollback_revert_actions_by("player:"..user:get_player_name(), 5) -- hours*minutes*seconds
      --time_travel(user)
      --help --> https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L1343
   end,
})

maybe you need to enable rollback
https://github.com/minetest/minetest/bl ... #L847-L850
l like how your time machine works.
 

User avatar
iangp
Member
 
Posts: 114
Joined: Sat May 31, 2014 19:26
GitHub: 14NGiestas
IRC: iangp
In-game: iangp

Re: Post your modding questions here

by iangp » Wed Dec 02, 2015 22:05

Hybrid Dog wrote:
iangp wrote:Function Revert actions by user does not work?
And There's some way to change textures in game?
That's my mod that I'm working:
viewtopic.php?f=9&t=13672
I have tried this, without sucess:
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_craftitem("time_travel:phone", {
   description = "A common telephone",
   wield_image = "timetravel_phone.png",
   inventory_image = "timetravel_phone.png",
   visual = "sprite",
   physical = true,
   textures = {"timetravel_phone.png"},
   on_use = function(itemstack, user, pointed_thing)
      minetest.rollback_revert_actions_by("player:"..user:get_player_name(), 5) -- hours*minutes*seconds
      --time_travel(user)
      --help --> https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L1343
   end,
})

maybe you need to enable rollback
https://github.com/minetest/minetest/bl ... #L847-L850
l like how your time machine works.


Thank you, Hybrid!!!
God's not dead, He's surely alive!
エル プサイ コングルー

My mods (WIP):
 

User avatar
mahmutelmas06
Member
 
Posts: 355
Joined: Mon Mar 02, 2015 13:10
GitHub: mahmutelmas06
IRC: mahmutelmas06
In-game: masum

Re: Post your modding questions here

by mahmutelmas06 » Thu Dec 03, 2015 15:40

How this replace node works.
I have created a node and i dont want to place it. I want to replace it with the node i point.

i have tried them

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_placenode = function(pos, newnode, placer, oldnode, itemstack, pointed_thing)
         minetest.register_on_placenode(pos, "test:node_1", placer, "default:dirt_with_grass", itemstack, pointed_thing)
   end,



   after_place_node = function(pos, placer, itemstack)
         minetest.swap_node({x=0, y= -6, z=-0}, {name = "test:node_1" })
   end,
My Mods:

Beverage
 

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

Re: Post your modding questions here

by Hybrid Dog » Thu Dec 03, 2015 16:45

mahmutelmas06 wrote:How this replace node works.
I have created a node and i dont want to place it. I want to replace it with the node i point.

i have tried them

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_placenode = function(pos, newnode, placer, oldnode, itemstack, pointed_thing)
         minetest.register_on_placenode(pos, "test:node_1", placer, "default:dirt_with_grass", itemstack, pointed_thing)
   end,



   after_place_node = function(pos, placer, itemstack)
         minetest.swap_node({x=0, y= -6, z=-0}, {name = "test:node_1" })
   end,

l'm not sure if this works, if you place sth on a buildable_to node, it gets replaced, so maybe you only need to set e.g. air before placing:
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("yournode:mec", {
    […]
})

local place = minetest.registered_nodes["yournode:mec"].on_place
minetest.override_item("yournode:mec", {
    on_place = function(itemstack, placer, pointed_thing)
        if not pointed_thing then
            return -- abort if it's missing for some reason
        end
        minetest.remove_node(pointed_thing.under)
        return place(itemstack, placer, pointed_thing)
    end
})
 

User avatar
mahmutelmas06
Member
 
Posts: 355
Joined: Mon Mar 02, 2015 13:10
GitHub: mahmutelmas06
IRC: mahmutelmas06
In-game: masum

Re: Post your modding questions here

by mahmutelmas06 » Thu Dec 03, 2015 20:56

Yes it worked. Thank you Hybrid Dog
My Mods:

Beverage
 

User avatar
mahmutelmas06
Member
 
Posts: 355
Joined: Mon Mar 02, 2015 13:10
GitHub: mahmutelmas06
IRC: mahmutelmas06
In-game: masum

Re: Post your modding questions here

by mahmutelmas06 » Thu Dec 10, 2015 13:31

Can i texture nodeboxes independent or do i have to use a mesh model ?


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
   node_box = {
      type = "fixed",
      fixed = {
         {-0.1875, -0.25, -0.125, 0.125, -0.25, 0.1875}, -- bottom
         {-0.1875, -0.25, -0.125, 0.125, -0.0625, -0.0625}, -- left
         {-0.1875, -0.25, 0.125, 0.125, -0.0625, 0.1875}, -- right
         {0.0625, -0.25, -0.125, 0.125, -0.0625, 0.1875}, -- back
         {-0.1875, -0.25, -0.125, -0.125, -0.0625, 0.1875}, -- front
         {-0.0625, -0.25, 0.0625, 0, -0.5, -5.58794e-009}, -- hold
         {-0.125, -0.5, -0.0625, 0.0625, -0.4375, 0.125}, -- holdbottom
      }
   },
My Mods:

Beverage
 

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

Re: Post your modding questions here

by Hybrid Dog » Fri Dec 11, 2015 17:05

mahmutelmas06 wrote:Can i texture nodeboxes independent or do i have to use a mesh model ?


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
   node_box = {
      type = "fixed",
      fixed = {
         {-0.1875, -0.25, -0.125, 0.125, -0.25, 0.1875}, -- bottom
         {-0.1875, -0.25, -0.125, 0.125, -0.0625, -0.0625}, -- left
         {-0.1875, -0.25, 0.125, 0.125, -0.0625, 0.1875}, -- right
         {0.0625, -0.25, -0.125, 0.125, -0.0625, 0.1875}, -- back
         {-0.1875, -0.25, -0.125, -0.125, -0.0625, 0.1875}, -- front
         {-0.0625, -0.25, 0.0625, 0, -0.5, -5.58794e-009}, -- hold
         {-0.125, -0.5, -0.0625, 0.0625, -0.4375, 0.125}, -- holdbottom
      }
   },

as far as l know you can't

somewhere l read that 0gb.us greatly improved nodebox polygon calculation, polygons inside the boxes, which are not visible if the texture doesn't have transparency, were removed
at least nodeboxes have backface culling, sadly the meshes, see viewtopic.php?f=6&t=12840 don't have backface culling
 

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

Re: Post your modding questions here

by bobomb » Sun Dec 13, 2015 18:28

if you place a node in a mapchunk that hasn't been generated yet, will it be overwritten by on_generate?
 

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

Re: Post your modding questions here

by Hybrid Dog » Mon Dec 14, 2015 17:23

bobomb wrote:if you place a node in a mapchunk that hasn't been generated yet, will it be overwritten by on_generate?

As far as l know (dungeons generation) the node doesn't get overridden by core mapgen.
But l sometimes saw bugs, e.g. grass and trees at mapblock corners at nyanland.

Players are btw not able to place a node there because that 1. would be put after mapgen in the queue and 2. ignore isn't buildable_to.
 

PreviousNext

Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 5 guests

cron