--...
on_activate = function(self, staticdata)
if staticdata ~= "" then
self.owner = staticdata
end
end,
on_staticdata = function(self)
return self.owner
end,
--...
DS-minetest wrote:@BrunoMine: You can use on_staticdata eg.
...
on_activate = function(self, staticdata)
if staticdata ~= "" then
local t=minetest.deserialize(staticdata)
self.owner = t.owner
self.otherstuff = t.otherstuff
end
end,
--!!! not on_staticdata!!!--
get_staticdata = function(self)
return minetest.serialize({
owner=self.owner
otherstuff=self.otherstuff
})
end,
--...
D00Med wrote:Is it possible to use a texture for the inventory slots?
local monochrome, sounds = {}, {}
function monochrome.play_sound(pos)
local spos = minetest.hash_node_position(pos)
sounds[spos] =minetest.sound_play("monochrome_mc",{pos=pos, max_hear_distance=5, gain=1.25, loop=true})
end
function monochrome.stop_sound(pos)
local spos = minetest.hash_node_position(pos)
if sounds[spos] then minetest.sound_stop(sounds[spos]) end
end
minetest.register_node("monochrome:mc_on", {
description = "Monochrome",
tiles = {
{image = "nbea_monochrome2.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 3.0
},
}
},
paramtype = "light",
sunlight_propagates = true,
is_ground_content = false,
drop = "monochrome:mc_off",
groups = {cracky = 3, not_in_creative_inventory = 1},
sounds = default.node_sound_metal_defaults(),
mesecons = {effector = {
state = mesecon.state.on,
action_off = function (pos, node)
monochrome.stop_sound(pos)
minetest.swap_node(pos, {name = "monochrome:mc_off"})
end,
}},
})
minetest.register_node("monochrome:mc_off", {
description = "Monochrome",
tiles = {"nbea_monochrome.png"},
paramtype = "light",
sunlight_propagates = true,
is_ground_content = false,
groups = {cracky = 3},
sounds = default.node_sound_metal_defaults(),
mesecons = {effector = {
state = mesecon.state.off,
action_on = function (pos, node)
minetest.swap_node(pos, {name = "monochrome:mc_on"})
monochrome.play_sound(pos)
end,
}}
})
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)
Napiophelios wrote:I have a simple mesecon node I want to play sound (looped) when activated
The sounds works but I can't get the sounds to stop when its deactivated.
Can anyone tell me what's wrong with this/what I am doing wrong here?
Am I going about this the wrong 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 monochrome, sounds = {}, {}
function monochrome.play_sound(pos)
local spos = minetest.hash_node_position(pos)
sounds[spos] =minetest.sound_play("monochrome_mc",{pos=pos, max_hear_distance=5, gain=1.25, loop=true})
end
function monochrome.stop_sound(pos)
local spos = minetest.hash_node_position(pos)
if sounds[spos] then minetest.sound_stop(sounds[spos]) end
end
minetest.register_node("monochrome:mc_on", {
description = "Monochrome",
tiles = {
{image = "nbea_monochrome2.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 3.0
},
}
},
paramtype = "light",
sunlight_propagates = true,
is_ground_content = false,
drop = "monochrome:mc_off",
groups = {cracky = 3, not_in_creative_inventory = 1},
sounds = default.node_sound_metal_defaults(),
mesecons = {effector = {
state = mesecon.state.on,
action_off = function (pos, node)
monochrome.stop_sound(pos)
minetest.swap_node(pos, {name = "monochrome:mc_off"})
end,
}},
})
minetest.register_node("monochrome:mc_off", {
description = "Monochrome",
tiles = {"nbea_monochrome.png"},
paramtype = "light",
sunlight_propagates = true,
is_ground_content = false,
groups = {cracky = 3},
sounds = default.node_sound_metal_defaults(),
mesecons = {effector = {
state = mesecon.state.off,
action_on = function (pos, node)
minetest.swap_node(pos, {name = "monochrome:mc_on"})
monochrome.play_sound(pos)
end,
}}
})
D00Med wrote:How to animate a model in blender:
(do this in the default view)
Before you start, make sure your model is joined(no separate cubes etc.), if they aren't select them all and click join from the tool panel. Press 't' to change to wireframe mode. Then you'll need to add bones. Add one using the 'create' panel, and then(IMPORTANT), switch to edit mode and add any other bones you need. If you select the little circle on the end of a bone and press 'e', you can make a bone that is connected to the one you have highlighted. Make a bone for every part that should move, for example a head would have at least one bone. Then in object mode, first select the model, then the bones(not the other way around) and press 'p', and choose "with automatic weights" from the menu. If you're lucky this will work nicely, if you aren't you'll have to do more work. Highlight the bones and press 'ctrl+tab'(pose mode), and highlight a bone(it should be blue), then use 'r' to rotate it a bit to see if it works. Rightclick afterwards to cancel, this is just a test. Do the same for all bones. It's likely that some bones will move parts you don't want them to.
Fixing bone problems:
Staying in 'pose mode', right click the model and switch to edit mode. You can then select the face(or lines and vertices) of a moving part. Once you have done this(just for one part), find the panel on the right(or wherever you have the properties panel with all the icon tabs) and click the icon of an inverted triangle. You should then see a list of bones(you may need to make the panel a bit wider). Find the bone you need the part to attach to and rightclick it. Then choose 'assign'. If you don't know which bone to assign to, just go to object mode, then right click on the correct bone. It's name should show up in the bottom left corner. If you are trying to stop a bone controlling a certain part, you would do the same, but this time click 'remove' instead of 'assign'.
Now that the bones are assigned you can actually start animating the model. Down the bottom of the window there should be a timeline. Move the green line to 1 or 0 or wherever the start is, move your mouse over the model and press 'i', then choose 'locrotscale'. This is how you insert a frame into the animation. It's best to do this straight away so you don't lose the initial position of the model. Then you can move to a different frame(like 5 or 6) and use the bones to put the model into the right starting pose for an animation. You can move, rotate, or scale bones(although if you scale bones you can't scale the model easily afterwards). When you have done that, use 'i' to insert the frame.
You don't have to do this for every frame, just for the important ones. For example, to make a bone bend, you would make one frame with it's stating position, move a few frames ahead(like 10) and then rotate it and make a new frame. Blender will automatically fill in the frames in-between with the rotation of the arm.
Notes:
You can delete frames with 'alt+i'
You can set the end and start points of the animation, this is useful for testing.
I hope this is useful for you and that I haven't missed anything important.
Also you should keep an eye on this thread: viewtopic.php?f=47&t=16455
local monochrome, sounds = {}, {}
function monochrome.play_sound(pos)
local spos = minetest.hash_node_position(pos)
sounds[spos] =minetest.sound_play("monochrome_mc",{pos=pos, max_hear_distance=5, gain=1.25, loop=true})
end
function monochrome.stop_sound(pos)
local spos = minetest.hash_node_position(pos)
if sounds[spos] then minetest.sound_stop(sounds[spos]) end
end
minetest.register_node("monochrome:mc_on", {
description = "Monochrome",
tiles = {
{image = "monochrome_monochrome2.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 3.0
},
}
},
paramtype = "light",
sunlight_propagates = true,
is_ground_content = false,
drop = "monochrome:mc_off",
groups = {cracky = 3, mesecon = 1, not_in_creative_inventory = 1},
sounds = default.node_sound_metal_defaults(),
on_destruct = function(pos)
monochrome.stop_sound(pos)
end,
mesecons = {effector = {
state = mesecon.state.on,
action_off = function (pos, node)
monochrome.stop_sound(pos)
minetest.swap_node(pos, {name = "monochrome:mc_off"})
end,
}},
})
minetest.register_node("monochrome:mc_off", {
description = "Monochrome",
tiles = {"monochrome_monochrome.png"},
paramtype = "light",
sunlight_propagates = true,
is_ground_content = false,
groups = {cracky = 3, mesecon_effector_off = 1, mesecon = 1},
sounds = default.node_sound_metal_defaults(),
on_construct = function(pos)
monochrome.stop_sound(pos)
end,
mesecons = {effector = {
state = mesecon.state.off,
action_on = function (pos, node)
minetest.swap_node(pos, {name = "monochrome:mc_on"})
monochrome.play_sound(pos)
end,
}}
})
--- "I just don't know what went wrong!" (c) ...
modName = minetest.get_current_modname()
--- t = true
t = false
local eObj = {
visual = "cube",
visual_size = {x=1, y=1, z=1},
enameInObj = "old",
p={enameInObj1 = "old"}
}
function eObj:get_staticdata()
if t then
minetest.chat_send_player("singleplayer","get_staticdata self.p.enameInObj"..self.p.enameInObj1)
do return minetest.serialize(self.p.enameInObj1) end
else
minetest.chat_send_player("singleplayer","get_staticdata self.enameInObj"..self.enameInObj)
do return minetest.serialize(self.enameInObj) end
end
end
function eObj:on_activate( staticdata)
if staticdata == "" then
if t then
self.p.enameInObj1 = "new name"..minetest.get_us_time()
minetest.chat_send_player("singleplayer","on_activate INIT self.p.enameInObj1"..self.p.enameInObj1)
else
self.enameInObj = "new name"..minetest.get_us_time()
minetest.chat_send_player("singleplayer","on_activate INIT self.enameInObj"..self.enameInObj)
end
else
if t then
self.p.enameInObj1 = minetest.deserialize(staticdata)
minetest.chat_send_player("singleplayer","on_activate NEXT self.p.enameInObj1"..self.p.enameInObj1)
else
self.enameInObj = minetest.deserialize(staticdata)
minetest.chat_send_player("singleplayer","on_activate NEXT self.enameInObj"..self.enameInObj)
end
end
end
minetest.register_entity( modName .. ":eProto", eObj )
minetest.register_on_punchnode( function( pos, node, puncher, pointed_thing)
minetest.add_entity(pos, modName .. ":eProto")
minetest.chat_send_player("singleplayer","entity created right now time "..minetest.get_us_time())
end )
Nyarg wrote:Hi folks ) I found a lot of cruel magic, but don't know WTH is does.
If you start next code as is and punch anywhere two time you will see 2 entity with his different metadata based on us_time().
Now go away from it while it disappering (server destroy ones).
Ingame console show us correct different names in get_staticdata()
Now go back to entities while its appears again.
Another message show us right different names accepted via staticdata string (looks like server remember it f each entity).
BUT, if you select in code t = true (another block code will work) then after entity disappeared, message show equaled names.
Why additional table added in same place works different ???
17:26 oops minor code fixedYour 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
--- "I just don't know what went wrong!" (c) ...
modName = minetest.get_current_modname()
--- t = true
t = false
local eObj = {
visual = "cube",
visual_size = {x=1, y=1, z=1},
enameInObj = "old",
p={enameInObj1 = "old"}
}
function eObj:get_staticdata()
if t then
minetest.chat_send_player("singleplayer","get_staticdata self.p.enameInObj"..self.p.enameInObj1)
do return minetest.serialize(self.p.enameInObj1) end
else
minetest.chat_send_player("singleplayer","get_staticdata self.enameInObj"..self.enameInObj)
do return minetest.serialize(self.enameInObj) end
end
end
function eObj:on_activate( staticdata)
if staticdata == "" then
if t then
self.p.enameInObj1 = "new name"..minetest.get_us_time()
minetest.chat_send_player("singleplayer","on_activate INIT self.p.enameInObj1"..self.p.enameInObj1)
else
self.enameInObj = "new name"..minetest.get_us_time()
minetest.chat_send_player("singleplayer","on_activate INIT self.enameInObj"..self.enameInObj)
end
else
if t then
self.p.enameInObj1 = minetest.deserialize(staticdata)
minetest.chat_send_player("singleplayer","on_activate NEXT self.p.enameInObj1"..self.p.enameInObj1)
else
self.enameInObj = minetest.deserialize(staticdata)
minetest.chat_send_player("singleplayer","on_activate NEXT self.enameInObj"..self.enameInObj)
end
end
end
minetest.register_entity( modName .. ":eProto", eObj )
minetest.register_on_punchnode( function( pos, node, puncher, pointed_thing)
minetest.add_entity(pos, modName .. ":eProto")
minetest.chat_send_player("singleplayer","entity created right now time "..minetest.get_us_time())
end )
Oops it's my epic fail. I completely forgot it (Byakuren wrote:P is a table pointer
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)
"[combine:16x32:0,0=default_stone.png:0,16=default_wood.png"
Nyarg wrote:I have a new little question.
Is it possible increase visible range for entities more than ~50 nodes far ?
I need ~200 nodes far visible for entity, but experiments with minetest.conf take no effect.
active_block_range = 10
active_object_send_range_blocks = 10
azekill_DIABLO wrote:Thank you doomed! but in minetest how do i active animation, for an entity?
self.object:set_animation({x=<start frame>, y=<end frame>}, 15, 0, true)
orwell wrote:Maybe play with these two settings at the same time:
=256 nodes
Nyarg wrote:orwell wrote:Maybe play with these two settings at the same time:
=256 nodes
I set it but have no effect.
Nyarg wrote:Wow now my entities stay visible really FARrrrrr ! MUAHAHAHA
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)
azekill_DIABLO wrote:*trying*
no. it still think it does not exist sorry. :/
minetest.register_entity(
"eat:test1",
{
on_activate = function(self, staticdata, dtime_s)
minetest.chat_send_all("<1> activated")
minetest.chat_send_all("<1> "..dtime_s)
if staticdata == nil then
minetest.chat_send_all("<1> nil")
elseif staticdata == "" then
minetest.chat_send_all("<1> \"\"")
else
minetest.chat_send_all("<1> "..staticdata)
end
if not self.at then
self.at = minetest.add_entity(self.object:getpos(), "eat:test2")
end
if self.at then
self.at:set_attach(self.object, "", {x=0,y=1,z=1}, {x=0,y=0,z=0})
minetest.chat_send_all("<1> attach")
end
self.object:setvelocity({x=1,y=0,z=0})
end,
get_staticdata = function(self)
return "sta"
end,
}
)
minetest.register_entity(
"eat:test2",
{
on_activate = function(self, staticdata, dtime_s)
minetest.chat_send_all("<2> activated")
minetest.chat_send_all("<2> "..dtime_s)
if staticdata == nil then
minetest.chat_send_all("<2> nil")
elseif staticdata == "" then
minetest.chat_send_all("<2> \"\"")
else
minetest.chat_send_all("<2> "..staticdata)
end
if staticdata ~= "" then
if not self.object:get_attach() then
minetest.chat_send_all("<2> remove")
self.object:remove()
end
end
end,
get_staticdata = function(self)
return "sta"
end,
}
)
-- [MOD] Angled Glass [angledglass] [1.2] by TumeniNodes 6-24-2016
angledglass = {}
-- Angled place function
-- To use put "on_place = angledglass.angled_place" in the node def
function angledglass.angled_place(itemstack, placer, pointed_thing)
local placer_pos = placer:getpos()
local pos = pointed_thing.above
local param2
if pos.x > placer_pos.x then
if pos.z > placer_pos.z then
param2 = 1
else
param2 = 2
end
else
if pos.z > placer_pos.z then
param2 = 0
else
param2 = 3
end
end
return minetest.item_place(itemstack, placer, pointed_thing, param2)
end
--Register angledglass.
--Node will be called angledglass:glass_<subname>
function angledglass.register_glass(subname, recipeitem, groups, images, description, sounds)
groups.glass = 1
minetest.register_node(":angledglass:glass" .. subname, {
description = description,
drawtype = "mesh",
mesh = "angled_glass.obj",
tiles = images,
use_texture_alpha = true,
paramtype = "light",
sunlight_propogates = true,
paramtype2 = "facedir",
is_ground_content = false,
groups = groups,
sounds = sounds,
collision_box = {
type = "fixed",
fixed = {
{0.375, -0.5, 0.375, 0.5, 0.5, 0.5},
{-0.5, -0.5, -0.5, -0.375, 0.5, -0.375},
{-0.4375, -0.5, -0.4375, -0.3125, 0.5, -0.3125},
{0.3125, -0.5, 0.3125, 0.4375, 0.5, 0.4375},
{0.25, -0.5, 0.25, 0.375, 0.5, 0.375},
{-0.375, -0.5, -0.375, -0.25, 0.5, -0.25},
{0.1875, -0.5, 0.1875, 0.3125, 0.5, 0.3125},
{-0.3125, -0.5, -0.3125, -0.1875, 0.5, -0.1875},
{0.125, -0.5, 0.125, 0.25, 0.5, 0.25},
{-0.25, -0.5, -0.25, -0.125, 0.5, -0.125},
{0.0625, -0.5, 0.0625, 0.1875, 0.5, 0.1875},
{-0.1875, -0.5, -0.1875, -0.0625, 0.5, -0.0625},
{0, -0.5, 0, 0.125, 0.5, 0.125},
{-0.125, -0.5, -0.125, 0, 0.5, 0},
{-0.0625, -0.5, -0.0625, 0.0625, 0.5, 0.0625},
}
},
on_place = angledglass.angled_place
})
end
-- Angled glass registration function.
-- Nodes will be called angledglass:{glass}_<subname>
function angledglass.register_glass(subname, recipeitem, groups, images, desc_glass, sounds)
end
-- Register glass
angledglass.register_glass("wood", "default:wood",
{choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, wood = 1},
{"default_wood.png", "default_glass.png"},
"Wooden Glass",
default.node_sound_glass_defaults())
-- [MOD] Angled Walls [angledwalls] [1.2] by TumeniNodes 6-24-2016
dofile(minetest.get_modpath("angledwalls").."/angledwalls.lua")
dofile(minetest.get_modpath("angledwalls").."/angledglass.lua")
if minetest.get_modpath("bakedclay") then
dofile(minetest.get_modpath("angledwalls").."/bakedclay.lua")
end
if minetest.get_modpath("quartz") then
dofile(minetest.get_modpath("angledwalls").."/quartz.lua")
end
Users browsing this forum: No registered users and 6 guests