qwrwed wrote:How do I use add_node or set_node to create other nodes? i am making a plasma screen TV mod which has 6 nodes, arranged like this:
1 2 3
4 5 6
5 is the node that is placed, and when the player places it the other 5 nodes should generate. However, I don't know how to do this, and looking in the code for the stargate mod, doors mod and beds mod did not help - the first two were too complicated for this, and I don't even know where I'm going wrong using code from beds, so I would like to start from scratch. The nodes (which are nodeboxes) are plasmascreen:screen1, plasmascreen:screen2 etc. up to plasmascreen:screen6.
placing nodes with on_construct
placing nodes with on_construct
I am going to try and place 6 nodes with only one placed by the player, but I don't know how to use on_construct to place nodes. Right now I am using after_place_node, but that only works for adding a second node because there is no placer to activate the "after_place_node" function for any more. How do I place a node (with facedir) on_construct?
Last edited by qwrwed on Thu Jul 25, 2013 11:41, edited 1 time in total.
- PilzAdam
- Member
- Posts: 4026
- Joined: Fri Jul 20, 2012 16:19
- GitHub: PilzAdam
- IRC: PilzAdam
- Location: Germany
Code: Select all
-- pos is the position of the "5" node in the format {x=1, y=2 z=3}
pos.y = pos.y + 1
minetest.set_node(pos, {name="tv:screen_2})
-
- Member
- Posts: 4290
- Joined: Sun Sep 09, 2012 17:31
- GitHub: Sokomine
- IRC: Sokomine
- In-game: Sokomine
If your plasma screen ought to switch pictures/channels like the TV from homedecor or the TV from Redcrabs server, perhaps you ought to take a diffrent approach and just make the nodebox larger than one node. That does work. Sideeffects are that nodes may really overlap.
A list of my mods can be found here.
- PilzAdam
- Member
- Posts: 4026
- Joined: Fri Jul 20, 2012 16:19
- GitHub: PilzAdam
- IRC: PilzAdam
- Location: Germany
And the texture just repeats itself, wich doesnt look good.Sokomine wrote:If your plasma screen ought to switch pictures/channels like the TV from homedecor or the TV from Redcrabs server, perhaps you ought to take a diffrent approach and just make the nodebox larger than one node. That does work. Sideeffects are that nodes may really overlap.
- webdesigner97
- Member
- Posts: 1328
- Joined: Mon Jul 30, 2012 19:16
- GitHub: webD97
- IRC: webdesigner97
- In-game: webdesigner97
- Location: Cologne, Germany
- Contact:
If you need your manually placed node to facedir, make sure to add param2 to the node:
And for changing pictures: Why not use a texture animation?
Code: Select all
after_place_node = function(pos,placer,itemstack)
--Don't forget to modify the <pos> table
minetest.set_node(pos,{name="bla", param2=minetest.dir_to_facedir(placer:get_look_dir())})
end
Visit me: webD97.de | @GitHub | @DeviantArt
Mods: StreetsMod | Vehicles
Featured from my blog: Dockerize the Minetest server
On my own behalf: Chameleon - A PHP image manipulation library built around GD
Mods: StreetsMod | Vehicles
Featured from my blog: Dockerize the Minetest server
On my own behalf: Chameleon - A PHP image manipulation library built around GD
Thanks webdesigner and PilzAdam, I will try that. Sokomine, I did that after making the first 6 nodes (it seemed simpler than using set_node) but I found that even when using a 32x48 texture, it just reverted to 6 16x16 textures. As for animation, I'm not that good with textures (maybe I will ask VanessaE) so I'll try to get the placement of the TV and a stand for it first. Currently, I have used black for the borders and dark grey for the screen.
I get this error:
The definition with the after_place_node is this:
This happened when I tried to modify the papyrus_bed/beds code as well.
Code: Select all
17:42:54: ERROR[main]: ServerError: LuaError: error: ...cuments\minetest-0.4.7\bin\..\mods\plasmascreen\init.lua:146: calling 'get_node' on bad self (table expected, got userdata)
Code: Select all
minetest.register_node("plasmascreen:screen5", {
description = "Plasma TV",
tiles = {"plasmascreen_screen.png", "plasmascreen_back.png", "plasmascreen_screen.png", "plasmascreen_screen.png", "plasmascreen_back.png", "plasmascreen_screen5.png"},
paramtype = "light",
paramtype2 = "facedir",
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-0.5000, -0.5000, 0.4375, 0.5000, 0.5000, 0.5000},
{-0.5000, -0.5000, 0.3750, 0.5000, -0.3125, 0.4375},
}
},
selection_box = {
type = "fixed",
fixed = {
{-0.5000, -0.5000, 0.4375, 0.5000, 0.5000, 0.5000},
{-0.5000, -0.5000, 0.3750, 0.5000, -0.3125, 0.4375},
}
},
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2},
after_place_node = function(pos,placer,itemstack)
pos.y = pos.y + 1
minetest.set_node(pos,{name="plasmascreen:screen2", param2=minetest.dir_to_facedir(placer:get_look_dir())})
end
})
Last edited by qwrwed on Wed Jul 24, 2013 16:45, edited 1 time in total.
- webdesigner97
- Member
- Posts: 1328
- Joined: Mon Jul 30, 2012 19:16
- GitHub: webD97
- IRC: webdesigner97
- In-game: webdesigner97
- Location: Cologne, Germany
- Contact:
Which line is 146?
Visit me: webD97.de | @GitHub | @DeviantArt
Mods: StreetsMod | Vehicles
Featured from my blog: Dockerize the Minetest server
On my own behalf: Chameleon - A PHP image manipulation library built around GD
Mods: StreetsMod | Vehicles
Featured from my blog: Dockerize the Minetest server
On my own behalf: Chameleon - A PHP image manipulation library built around GD
(previous problem solved)
Another problem: when I place screen5, screen4 appears to the left of it as planned, but instead of appearing to the right, screen6 appears in place of screen5. Here is the code:
Everything before the first "end" works fine.
Also, the nodes I place aren't being saved when I exit the world, although it is recorded in the terminal.
Another problem: when I place screen5, screen4 appears to the left of it as planned, but instead of appearing to the right, screen6 appears in place of screen5. Here is the code:
Code: Select all
after_place_node = function(pos,placer,itemstack)
local param2 = minetest.get_node(pos).param2
if param2 == 0 then
pos.x = pos.x-1
minetest.set_node(pos,{name="plasmascreen:screen4", param2=minetest.dir_to_facedir(placer:get_look_dir())})
elseif param2 == 1 then
pos.z = pos.z+1
minetest.set_node(pos,{name="plasmascreen:screen4", param2=minetest.dir_to_facedir(placer:get_look_dir())})
elseif param2 == 2 then
pos.x = pos.x+1
minetest.set_node(pos,{name="plasmascreen:screen4", param2=minetest.dir_to_facedir(placer:get_look_dir())})
elseif param2 == 3 then
pos.z = pos.z-1
minetest.set_node(pos,{name="plasmascreen:screen4", param2=minetest.dir_to_facedir(placer:get_look_dir())})
end
local param2 = minetest.get_node(pos).param2
if param2 == 0 then
pos.x = pos.x+1
minetest.set_node(pos,{name="plasmascreen:screen6", param2=minetest.dir_to_facedir(placer:get_look_dir())})
elseif param2 == 1 then
pos.z = pos.z-1
minetest.set_node(pos,{name="plasmascreen:screen6", param2=minetest.dir_to_facedir(placer:get_look_dir())})
elseif param2 == 2 then
pos.x = pos.x-1
minetest.set_node(pos,{name="plasmascreen:screen6", param2=minetest.dir_to_facedir(placer:get_look_dir())})
elseif param2 == 3 then
pos.z = pos.z+1
minetest.set_node(pos,{name="plasmascreen:screen6", param2=minetest.dir_to_facedir(placer:get_look_dir())})
end
end
})
Also, the nodes I place aren't being saved when I exit the world, although it is recorded in the terminal.
Last edited by qwrwed on Wed Jul 24, 2013 19:11, edited 1 time in total.
- SuperStarSonic
- Member
- Posts: 160
- Joined: Fri Oct 14, 2022 20:30
- GitHub: Python-Sargent
- In-game: SuperStarSonic
- Location: Earth (may be out of date)
Re:
webdesigner97 wrote: ↑Wed Jul 24, 2013 15:58If you need your manually placed node to facedir, make sure to add param2 to the node:
And for changing pictures: Why not use a texture animation?Code: Select all
after_place_node = function(pos,placer,itemstack) --Don't forget to modify the <pos> table minetest.set_node(pos,{name="bla", param2=minetest.dir_to_facedir(placer:get_look_dir())}) end
what does this mean?--Don't forget to modify the <pos> table
- SuperStarSonic
- Member
- Posts: 160
- Joined: Fri Oct 14, 2022 20:30
- GitHub: Python-Sargent
- In-game: SuperStarSonic
- Location: Earth (may be out of date)
Re: placing nodes with on_construct
do you have to deconstruct the 'pos' table into separate elements stacked into a 'list-like' structure?
Code: Select all
minetest.set_node({pos.x, pos.y, pos.z}, name="node_name")
Who is online
Users browsing this forum: No registered users and 31 guests