Post your modding questions here

BirgitLachner
Member
 
Posts: 135
Joined: Thu May 05, 2016 10:18
In-game: Bibs

Re: Post your modding questions here

by BirgitLachner » Sat Oct 15, 2016 14:35

Thanks a lot Krock ... you had an error in you 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
turtle_formspec_positions[player_name] = pos

must be
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
turtle_formspec_positions[player_name] = new_pos


... but now it works (more or less) as wanted for all directions. And I checked if there is a walkable block. If it is not walkable I allow the movement. It works but I don't know if that is good coding!
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
   
-- Check new position if empty
local newposchecktable = minetest.get_node(new_pos)
local newposcheck = newposchecktable.name
local walkable = minetest.registered_nodes[newposcheck].walkable

if not walkable then
 ... [i]move the block[/i]



Next step:

A bigger problem is that up and down is always correct but forward and backward depends on the direction where the turtle looks.

What does not 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
        local newposchecktable = minetest.get_node(new_pos)
   local newposcheck = newposchecktable.name
   local direction = dir_to_facedir(minetest.registered_nodes[newposcheck].param2)


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.registered_nodes[newposcheck].param2

... always give nil as output

And at least ... I want the turtle to turn around to the left and to the right. I think that I have to change the direction like with a screwdriver. I will late have a look at the code of the screwdriver.

Thanks ... Birgit
 

BirgitLachner
Member
 
Posts: 135
Joined: Thu May 05, 2016 10:18
In-game: Bibs

Re: Post your modding questions here

by BirgitLachner » Sat Oct 15, 2016 16:37

Okay ... I searched in the minetest-game code how the screwdriver works: Many things can be deleted as I don't need to check if the turtle is moveable and so on.

I finally got it to turn the turtle to the right and left ...

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 nextrangeright(x)
   x = x + 1
   if x > 3 then
      x = 0
   end
   return x
end

local function nextrangeleft(x)
   x = x - 1
   if x < 0 then
      x = 3
   end
   return x
end


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 fields.turnright then
      local ndef = minetest.registered_nodes[node.name]

      -- Compute param2
      local rotationPart = node.param2 % 32 -- get first 4 bits
      local preservePart = node.param2 - rotationPart
      local axisdir = math.floor(rotationPart / 4)
      local rotation = rotationPart - axisdir * 4
      rotationPart = axisdir * 4 + nextrangeright(rotation)
      
      local new_param2 = preservePart + rotationPart
      
      node.param2 = new_param2
      minetest.swap_node(pos, node)
   end

   if fields.turnleft then
      local ndef = minetest.registered_nodes[node.name]

      -- Compute param2
      local rotationPart = node.param2 % 32 -- get first 4 bits
      local preservePart = node.param2 - rotationPart
      local axisdir = math.floor(rotationPart / 4)
      local rotation = rotationPart - axisdir * 4
      rotationPart = axisdir * 4 + nextrangeleft(rotation)
      
      local new_param2 = preservePart + rotationPart
      
      node.param2 = new_param2
      minetest.swap_node(pos, node)
   end


Okay ... but I do not really understand how it works ... just copied it and changed it ;-)

What I'm still missing ... how can I get an information in which direction the face is looking to? I just need an output and which type it is to decide in which direction "forward" is.

Thanks ... Birgit

BTW ... I think I should move to (or start) an extra thread for my questions.
 

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

Re: Post your modding questions here

by Krock » Sun Oct 16, 2016 08:26

BirgitLachner wrote:What I'm still missing ... how can I get an information in which direction the face is looking 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
Make sure your turtle definition contains this line:
paramtype2 = "facedir",

-- Get the node and read param2, which is the facedir in our case:
local node = minetest.get_node(pos)
local dir = minetest.facedir_to_dir(node.param2)
-- Do something with the direction, it is a table like {x=1, y=0, z=0}
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
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Post your modding questions here

by azekill_DIABLO » Sun Oct 16, 2016 12:04

idk it doesn't 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
minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing, tiles)
   local node = minetest.get_node_or_nil(pointed_thing.under)
   local tilenode = minetest.registered_nodes[node.name].tiles
   print(tilenode[1])
      minetest.add_particlespawner({
         amount = 54,
         time = 0.40,
         minpos = {node},
         maxpos = {node},
         minvel = {x = -1, y = -1, z = -1},
         maxvel = {x = 1,  y = 1,  z = 1},
         minacc = {x = -1, y = -4, z = -1},
         maxacc = {x = 1, y = -3, z = 1},
         minexptime = 1,
         maxexptime = 4,
         minsize = 0.5,
         maxsize = 1,
         texture = tilenode,
      })
end)
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
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

BirgitLachner
Member
 
Posts: 135
Joined: Thu May 05, 2016 10:18
In-game: Bibs

Re: Post your modding questions here

by BirgitLachner » Sun Oct 16, 2016 12:37

Thanks, once again ...
Krock 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
-- Get the node and read param2, which is the facedir in our case:
local node = minetest.get_node(pos)
local dir = minetest.facedir_to_dir(node.param2)
-- Do something with the direction, it is a table like {x=1, y=0, z=0}


Well ... that was what I did before and I can't understand the output of the table converted to a string ... but after searching how to get a value from the table I found it in the lua reference.

... now the basic version of TurtleMiner is working and released to github. https://github.com/BiLachner/TurtleMiner
 

ozkur
Member
 
Posts: 180
Joined: Wed Oct 07, 2015 20:59
In-game: ozkur or XoRoUZ

Re: Post your modding questions here

by ozkur » Sun Oct 16, 2016 17:05

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("rocket:pod", {
    description = " Rocket Control Pod",
    tiles = {"top.png", "pad.png", "pod.png"},
    groups = {cracky = 1},
    on_punch = function(pos, node, player, pointed_thing)
      local tank = minetest.get_node({pos.x, pos.y-2, pos.z})
      local engine = minetest.get_node({pos.x, pos.y-3, pos.z})
      local pad = minetest.get_node({pos.x, pos.y-4, pos.z})
      --if tank.name == "rocket:tankfull" and engine.name == "rocket:engine" and pad.name == "rocket:pad" then
        --player:get_pos(p)
        --player:set_pos({p.x, 25000, p.z})
        --player:set_physics_override(1, 1, 0.17)
        --player:set_sky({0, 0, 0}, "skybox"})
        --minetest.remove_node({pos.x, pos.y-1, pos.z})
        --minetest.remove_node({pos.x, pos.y-2, pos.z})
        --minetest.remove_node(pos)
        minetest.chat_send_all(tank.name)
        minetest.chat_send_all("how does minetest getnode work?")
        minetest.chat_send_all(engine.name)
        minetest.chat_send_all(pad.name)
      --end
    end
})



After making fixes from earlier, it still didn't work. When punching it, it says ignore or "default:water_source" for all three.
Biplanes! 'Nuff said

I am a native English speaker, Ich spreche kein Deuscht, mais je parle un pue français.
 

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

Re: Post your modding questions here

by Krock » Sun Oct 16, 2016 17:22

ozkur 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 tank = minetest.get_node({pos.x, pos.y-2, pos.z})

All positions in the Minetest API are tables with the keys "x", "y" and "z", each with its coordinate as value.
So a proper position table looks like the following way: (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
local new_pos = {
    x = 99,
    y = -1,
    z = 7
}

Now I replaced the numbers with the value of the variable "pos" and put it into the get_node function:
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 tank = minetest.get_node({x = pos.x, y = pos.y - 2, z = pos.z})


What you did was to initialize a new array-like table, with the values [1] = pos.x, [2] = pos.y - 2 and [3] = pos.z - that's why it didn't work.
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>
 

ozkur
Member
 
Posts: 180
Joined: Wed Oct 07, 2015 20:59
In-game: ozkur or XoRoUZ

Re: Post your modding questions here

by ozkur » Sun Oct 16, 2016 17:29

Krock wrote:
ozkur 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 tank = minetest.get_node({pos.x, pos.y-2, pos.z})

All positions in the Minetest API are tables with the keys "x", "y" and "z", each with its coordinate as value.
So a proper position table looks like the following way: (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
local new_pos = {
    x = 99,
    y = -1,
    z = 7
}

Now I replaced the numbers with the value of the variable "pos" and put it into the get_node function:
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 tank = minetest.get_node({x = pos.x, y = pos.y - 2, z = pos.z})


What you did was to initialize a new array-like table, with the values [1] = pos.x, [2] = pos.y - 2 and [3] = pos.z - that's why it didn't work.

Thanks!
Biplanes! 'Nuff said

I am a native English speaker, Ich spreche kein Deuscht, mais je parle un pue français.
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Post your modding questions here

by azekill_DIABLO » Sun Oct 16, 2016 17:49

azekill_DIABLO wrote:idk it doesn't 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
minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing, tiles)
   local node = minetest.get_node_or_nil(pointed_thing.under)
   local tilenode = minetest.registered_nodes[node.name].tiles
   print(tilenode[1])
      minetest.add_particlespawner({
         amount = 54,
         time = 0.40,
         minpos = {node},
         maxpos = {node},
         minvel = {x = -1, y = -1, z = -1},
         maxvel = {x = 1,  y = 1,  z = 1},
         minacc = {x = -1, y = -4, z = -1},
         maxacc = {x = 1, y = -3, z = 1},
         minexptime = 1,
         maxexptime = 4,
         minsize = 0.5,
         maxsize = 1,
         texture = tilenode,
      })
end)


please?
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
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

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

Re: Post your modding questions here

by Krock » Sun Oct 16, 2016 18:13

azekill_DIABLO wrote:idk it doesn't 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
minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing, tiles)
   local node = minetest.get_node_or_nil(pointed_thing.under)
        [...]
         minpos = {node},
         maxpos = {node},
         [...]
         texture = tilenode,

"{node}" is not a position, use "pos". Also correct the "texture" value to "tilenode[1]".

Next customer please!
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>
 

ozkur
Member
 
Posts: 180
Joined: Wed Oct 07, 2015 20:59
In-game: ozkur or XoRoUZ

Re: Post your modding questions here

by ozkur » Sun Oct 16, 2016 18:22

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
player:getpos(p)
        player:setpos({p.x, 25000, p.z})

pos is already bieng used... so i cant rename p to pos.
it says that the line player:getpos(p) is the problem.
Biplanes! 'Nuff said

I am a native English speaker, Ich spreche kein Deuscht, mais je parle un pue français.
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Post your modding questions here

by azekill_DIABLO » Sun Oct 16, 2016 18:31

Okay thanks!

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
--start registering things
minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing, tiles)
   local node = minetest.get_node_or_nil(pointed_thing.under)
   local tilenode = minetest.registered_nodes[node.name].tiles
   print(tilenode[1])
      minetest.add_particlespawner({
         amount = 54,
         time = 0.40,
         minpos = {pos},
         maxpos = {pos},
         minvel = {x = -1, y = -1, z = -1},
         maxvel = {x = 1,  y = 1,  z = 1},
         minacc = {x = -1, y = -4, z = -1},
         maxacc = {x = 1, y = -3, z = 1},
         minexptime = 1,
         maxexptime = 4,
         minsize = 0.5,
         maxsize = 1,
         texture = tilenode[1],
      })
end)


i done something wrong...
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
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

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

Re: Post your modding questions here

by Krock » Sun Oct 16, 2016 18:50

ozkur 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
player:getpos(p)
        player:setpos({p.x, 25000, p.z})
.

"getpos" returns a table, takes no arguments. And then again the same coordinate table issue with "setpos". This is how your code could look like:
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 p = player:getpos(p)
player:setpos({x = p.x, y = 25000, z = p.z})

-- Or alternatively
local p = player:getpos(p)
p.y = 25000
player:setpos(p)


azekill_DIABLO wrote:i done something wrong...

You did not replace "{node}" with "pos", as I wrote earlier. Remove the brackets, so it will look 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
         minpos = pos,
         maxpos = pos,
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>
 

ozkur
Member
 
Posts: 180
Joined: Wed Oct 07, 2015 20:59
In-game: ozkur or XoRoUZ

Re: Post your modding questions here

by ozkur » Sun Oct 16, 2016 18:53

Krock wrote:
ozkur 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
player:getpos(p)
        player:setpos({p.x, 25000, p.z})
.

"getpos" returns a table, takes no arguments. And then again the same coordinate table issue with "setpos". This is how your code could look like:
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 p = player:getpos(p)
player:setpos({x = p.x, y = 25000, z = p.z})

-- Or alternatively
local p = player:getpos(p)
p.y = 25000
player:setpos(p)


azekill_DIABLO wrote:i done something wrong...

You did not replace "{node}" with "pos", as I wrote earlier. Remove the brackets, so it will look 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
         minpos = pos,
         maxpos = pos,

thanks again!!
Biplanes! 'Nuff said

I am a native English speaker, Ich spreche kein Deuscht, mais je parle un pue français.
 

PlanetKiller
Member
 
Posts: 14
Joined: Mon Nov 23, 2015 22:50

Re: Post your modding questions here

by PlanetKiller » Mon Oct 17, 2016 16:44

I'm doing some tests with node data, and writing down my findings, but I came across an error.
Here is my tools.lua script in my sketchy mod:

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_tool("sketchy:meta_rod", {
   description = "Meta Rod",
   
   inventory_image = "sketchy_meta.png",
   
   on_use = function(itemstack, user, pointed_thing)

      local name = user:get_player_name()       
      local point = pointed_thing.under
      
      if point then -- check if it is a node/exists
         local meta = minetest.get_meta(point)
         local tabe = meta:to_table()
         print(dump(meta:to_table()))
         --print(user)
         --print(tabe)
         if minetest.serialize(tabe) then
            local output = minetest.serialize(tabe)
            print(output)
         end
      end
   end

})



Both minetest.serialize(tabe) and print(dump(meta:to_table())) throw a massive error (Can't serialize data of type userdata) when I strike anything with an inventory (furnace, shelves, ect.).
Is this a bug, or is there a graceful way to catch this error?
I'd like to be able to see/change metadata on blocks, even give them metadata on generation.
I'm thinking about swapping the tilled soil with something that can track soil fertility/toxicity.
([noun].. " tried to " ..[verb]..[noun].. " at protected position "..[noun].. " with a bucket")
 

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

Re: Post your modding questions here

by Krock » Mon Oct 17, 2016 17:15

PlanetKiller wrote:Both minetest.serialize(tabe) and print(dump(meta:to_table())) throw a massive error (Can't serialize data of type userdata) when I strike anything with an inventory (furnace, shelves, ect.).

Interesting. I'm getting the same error. The stacks seem to be returned as an ItemStack, thus not possible to serialize (Minetest does not know what for an object type 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
        inventory = {
                fuel = {
                        <userdata>
                },
                dst = {
                        <userdata>,
                        <userdata>,
                        <userdata>,
                        <userdata>
                },
                src = {
                        <userdata>
                }
        }
}
2016-10-17 19:16:46: ERROR[Main]: ServerError: Lua: Runtime error from mod 'test' in callback Script
ApiItem::item_OnUse(): E:\Programme\minetest\bin\..\builtin\common\serialize.lua:151: Can't serializ
e data of type userdata
2016-10-17 19:16:46: ERROR[Main]: stack traceback:
2016-10-17 19:16:46: ERROR[Main]:       [C]: in function 'error'
2016-10-17 19:16:46: ERROR[Main]:       E:\Programme\minetest\bin\..\builtin\common\serialize.lua:15
1: in function 'dump_or_ref_val'
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
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Post your modding questions here

by azekill_DIABLO » Mon Oct 17, 2016 17:32

Krock wrote:
ozkur 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
player:getpos(p)
        player:setpos({p.x, 25000, p.z})
.

"getpos" returns a table, takes no arguments. And then again the same coordinate table issue with "setpos". This is how your code could look like:
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 p = player:getpos(p)
player:setpos({x = p.x, y = 25000, z = p.z})

-- Or alternatively
local p = player:getpos(p)
p.y = 25000
player:setpos(p)


azekill_DIABLO wrote:i done something wrong...

You did not replace "{node}" with "pos", as I wrote earlier. Remove the brackets, so it will look 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
         minpos = pos,
         maxpos = pos,


thnkas!
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
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

BirgitLachner
Member
 
Posts: 135
Joined: Thu May 05, 2016 10:18
In-game: Bibs

Re: Post your modding questions here

by BirgitLachner » Thu Oct 20, 2016 07:52

I wanted to have a formspec defintion where I show some parts depending on a variable. Something like ...

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.show_formspec(player_name, "turtleminer:turtle_formspec",
              "size[9,4]" ..
              "label[0,0;Click buttons to move the turtle around!]" ..
              "button_exit[5,1;2,1;exit;Exit]" ..
              "image_button[1,1;1,1;turtleminer_remote_arrow_up.png;up;]" ..
              "image_button[2,1;1,1;turtleminer_remote_arrow_fw.png;forward;]"
              if number >= 3 then
               "..button[3,1;2,1;digfront;dig front]" ..
               "button[3,3;2,1;digbottom;dig under]" ..
            end
              "image_button[1,2;1,1;turtleminer_remote_arrow_left.png;turnleft;]"..
              "image_button[3,2;1,1;turtleminer_remote_arrow_right.png;turnright;]" ..
              "image_button[1,3;1,1;turtleminer_remote_arrow_down.png;down;]" ..
              "image_button[2,3;1,1;turtleminer_remote_arrow_bw.png;backward;]"
              --.. "button[3,3;1,1;build;build]"
              )


I will have about 5 different possibilites for nearly the same formspecs and it would the best, if I can handle it with one code and only some if-statements.

Thanks!
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Post your modding questions here

by azekill_DIABLO » Thu Oct 20, 2016 09:16

then use on-reicive_field (oh my orthograph) for activing things after pushing button.
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
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

bell07
Member
 
Posts: 140
Joined: Sun Sep 04, 2016 15:15
GitHub: bell07

Re: Post your modding questions here

by bell07 » Thu Oct 20, 2016 10:05

BirgitLachner wrote:I wanted to have a formspec defintion where I show some parts depending on a variable

just concatenate the string, like
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 spec = "size[9,4]"
spec = spec.."label[0,0;Click buttons to move the turtle around!]"
if something then
   spec=spec.."button1[]"
else
  spec=spec.."otherbutton[]"
end
 minetest.show_formspec(player_name, "turtleminer:turtle_formspec",spec)
 

BirgitLachner
Member
 
Posts: 135
Joined: Thu May 05, 2016 10:18
In-game: Bibs

Re: Post your modding questions here

by BirgitLachner » Thu Oct 20, 2016 10:17

Thanks @bell07
 

amadin
Member
 
Posts: 471
Joined: Tue Jun 16, 2015 16:23
GitHub: Amadin

Re: Post your modding questions here

by amadin » Fri Oct 21, 2016 17:50

Hi all. Why looking through the transparent texture of colored glass, I do not see another colored glass? This is not always observed-effect (for example this depend on the sequence of different blocks installation), but with some laws. It seems this bug is for different mods with transparent blocks (for example caverealms). I use the code from "xpanes" mod from minetest_game for colored glass. Also this effect available in this mod too viewtopic.php?f=9&t=10456&hilit=glass
Image
Image
Last edited by amadin on Fri Oct 21, 2016 19:53, edited 3 times in total.
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Post your modding questions here

by azekill_DIABLO » Fri Oct 21, 2016 19:41

links broken sorry.
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
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

amadin
Member
 
Posts: 471
Joined: Tue Jun 16, 2015 16:23
GitHub: Amadin

Re: Post your modding questions here

by amadin » Fri Oct 21, 2016 19:50

azekill_DIABLO wrote:links broken sorry.

Fixed
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Post your modding questions here

by azekill_DIABLO » Fri Oct 21, 2016 19:57

Still broken.
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
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

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 » Fri Oct 21, 2016 22:46

partial transparency doesn't work very well
 

amadin
Member
 
Posts: 471
Joined: Tue Jun 16, 2015 16:23
GitHub: Amadin

Re: Post your modding questions here

by amadin » Sat Oct 22, 2016 06:31

rubenwardy wrote:partial transparency doesn't work very well

Maybe is another method for colored glass?
 

amadin
Member
 
Posts: 471
Joined: Tue Jun 16, 2015 16:23
GitHub: Amadin

Re: Post your modding questions here

by amadin » Sun Oct 23, 2016 11:47

In brewing stand i have one inv:set_size("src", 2) slot for 2 different ingredients (it looks like 2 slots). How check ingredient in the src slot is from my mod or not from my mod, even if placed only one ingredient? Source here http://github.com/amadin/lottpotion/blo ... rewing.lua
 

User avatar
taikedz
Member
 
Posts: 587
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake

Re: Post your modding questions here

by taikedz » Mon Oct 24, 2016 01:17

Heyaz

I am trying to define a chest and need to add funcitonality to prevent taking/putting certain items. For now I am testing 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
minetest.register_node("interchest:wormhole_chest", {
        description = "Wormhole Chest",
        on_construct = function(pos)
                local meta = minetest.get_meta(pos)
                meta:set_string("formspec",
                                "size[8,9]"..
                                "list[current_player;interchest:wormhole;0,0;8,4;]"..
                                "list[current_player;main;0,5;8,4;]" ..
                                "listring[current_player;interchest:wormhole]" ..
                                "listring[current_player;main]")
                meta:set_string("infotext", "Wormhole Chest")
        end,
        allow_metadata_inventory_put = function(pos, listname, index, stack, player)
                --minetest.chat_send_all(dump(stack))
                return 0 -- deny
        end,
        allow_metadata_inventory_take = function(pos, listname, index, stack, player)
                --minetest.chat_send_all(dump(stack))
                return 0 -- deny
        end,
})


You can see that for now I have defined "return 0" for the put and take callbacks

However these do not seem to get called at all.... I can happily transfer items to and from the chest , even though I expect the return 0 to cause a denial. The chats aren't printed when de-commented either.

Tried in singleplayer, and in multi-player modes...
 

User avatar
orwell
Member
 
Posts: 467
Joined: Wed Jun 24, 2015 18:45
GitHub: orwell96
In-game: orwell

Re: Post your modding questions here

by orwell » Mon Oct 24, 2016 19:39

You see, the inventory location of your 'interchest' inventory is 'current_player'. This inventory belongs to the player and not to the node, so the node callbacks aren't called. AFAIK you can't override allow_* methods for the player inventory. Try to use a detached inventory and set the allow_* methods there.
Approach (not approved)
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
register_detached_inventory("interchest_"..pname, {
     allow_put=function (whatever) return 0 end,
     allow_take=function (whatever) return whatelse end,
})
--and
meta:set_string("formspec", "... list[detached:interchest_"..pname..";a,s,o]  ..."
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...
 

PreviousNext

Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 6 guests

cron