Hybrid Dog wrote:ozkur, there are lots of ways to upload a mod, e.g. here's the init.lua of my version of the drippingwater mod as png:
(it's grey because ascii)
ozkur wrote:Sorry that this is the derpiest of all derpy and stupid questions:
How do I upload a mod to the forums?
kaeza wrote:ozkur wrote:Sorry that this is the derpiest of all derpy and stupid questions:
How do I upload a mod to the forums?
Use an archiving program(*) to compress your folder in a ZIP file, create a new topic for it in the WIP Mods subforum(**), and upload the ZIP file as an attachment ("Upload attachment" tab under the posting text box).
(*) Windows comes with support to compress folders, or you can use an external program like 7-zip.
(**) See also the guidelines for mod releases.
Hybrid Dog wrote:BrunoMine, you can only get active objects. Maybe you need to forceload some chunks.
on_punch = function(pos, node, player, pointed_thing)
local inv = player:get_inventory()
inv:add_item("main", "modname:node")
on_punch = function(pos, node, puncher, pointed_thing)
minetest.set_node(pos, {name = "modename:othernode", param2 = node.param2})
end
end
GreenDimond wrote:I seem to be having trouble with registering 2 'on_punch' to the same node.
sofar wrote:GreenDimond wrote:I seem to be having trouble with registering 2 'on_punch' to the same node.
You can't. Combine the code into one function.
get_item = function ()
-- function(pos, node, player, pointed_thing)
local inv = player:get_inventory()
inv:add_item("main", "modname:nodedame")
end,
replace_model = function ()
-- function(pos, node, puncher, pointed_thing)
minetest.set_node(pos, {name = "modname:othernodename", param2 = node.param2})
end,
do_punch = function do_punch()
get_item()
replace_model()
end,
on_punch = do_punch
get_item = function (player)
-- function(pos, node, player, pointed_thing)
local inv = player:get_inventory()
inv:add_item("main", "modname:nodename")
end,
replace_model = function (pos, node)
-- function(pos, node, puncher, pointed_thing)
minetest.set_node(pos, {name = "modname:othernodename", param2 = node.param2})
end,
on_punch = function (pos, node, player, pointed_thing)
node.get_item(player)
node.replace_model(pos, node)
end
})
2017-02-13 21:02:12: ERROR[Main]: ServerError: Lua: Runtime error from mod 'modname' in callback node_on_punch(): /home/alex/.minetest/mods/modname/nodes.lua:68: attempt to call field 'get_item' (a nil value)
2017-02-13 21:02:12: ERROR[Main]: stack traceback:
2017-02-13 21:02:12: ERROR[Main]: /home/alex/.minetest/mods/modname/nodes.lua:68: in function </home/alex/.minetest/mods/modname/nodes.lua:67>
local target_yaw = yaw+math.pi+math.pi/2
local entity_yaw = entity.object:getyaw()
if target_yaw <= 6.2 and target_yaw >= 0.2 then --this is the only method I have to stop the problem
entity.object:setyaw(entity_yaw+(target_yaw-entity_yaw)/4)
else
entity.object:setyaw(target_yaw)
end
-- before the node definition, make these as local functions
local function get_item(player)
local inv = player:get_inventory()
inv:add_item("main", "modname:nodename")
end
local function replace_model(pos, node)
-- function(pos, node, puncher, pointed_thing)
minetest.set_node(pos, {name = "modname:othernodename", param2 = node.param2})
end
minetest.register_node("name",{
-- ...
on_punch = function (pos, node, player, pointed_thing)
get_item(player)
replace_model(pos, node)
end
-- ...
})
D00Med wrote:I have a maths related question.
I can make an entity rotate so that it matches the player's yaw. Now I'm trying to make the entity 'catch-up' to the player's yaw. There's a problem with this though. When the player's yaw crosses 0/2pi the difference between the player's yaw and the entity's yaw makes the entity spin around in the opposite direction(the long way around).
At the moment the rotation of the entity is divided into four steps. The higher the number of steps it takes to catch up, the more noticeable the problem 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
local target_yaw = yaw+math.pi+math.pi/2
local entity_yaw = entity.object:getyaw()
if target_yaw <= 6.2 and target_yaw >= 0.2 then --this is the only method I have to stop the problem
entity.object:setyaw(entity_yaw+(target_yaw-entity_yaw)/4)
else
entity.object:setyaw(target_yaw)
end
^ yaw is the player's yaw
How can I do this so that the shortest difference is used?
@GreenDimond:
Have you tried just using get_item and replace_model rather than node.get_item and node.replace_model?
get_item = function(pos, node, player)
local inv = player:get_inventory()
inv:add_item("main", "modname:nodename")
end,
replace_model = function(pos, node)
minetest.set_node(pos, {name = "modname:othernodename", param2 = node.param2})
end,
on_punch = function(pos, node, player, pointed_thing)
node.get_item(player)
node.replace_model(pos, node)
end
})
2017-02-14 08:16:04: ERROR[Main]: ServerError: Lua: Runtime error from mod 'modname' in callback node_on_punch(): /home/alex/.minetest/mods/modname/nodes.lua:66: attempt to call field 'get_item' (a nil value)
2017-02-14 08:16:04: ERROR[Main]: stack traceback:
2017-02-14 08:16:04: ERROR[Main]: /home/alex/.minetest/mods/modname/nodes.lua:66: in function </home/alex/.minetest/mods/modname/nodes.lua:65>
on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "node" then
return
end
local pos = pointed_thing.under
local pname = user:get_player_name()
if minetest.is_protected(pos, pname) then
minetest.record_protection_violation(pos, pname)
return
end
local node = minetest.get_node(pos).name
if node == "modename:node1" then
-- minetest.swap_node(pos, {name = "modename:node2"})
minetest.set_node(pos, {name = "modename:node2", param2 = node.param2})
return itemstack
end
end,
GreenDimond wrote:Is that not the code I currently have?
We could talk about this in IRC if you like (#minetest).
orwell wrote:GreenDimond wrote:Is that not the code I currently have?
We could talk about this in IRC if you like (#minetest).
No not exactly. The .name went elsewhere. IRC not today.
function() replace_donemodel(pos, node)
minetest.set_node(pos, {name = "modname:nodename", param2 = node.param2})
end,
on_place = {
minetest.after(2.0, replace_donemodel)}
GreenDimond wrote:This code lets the game start and actually does something when I punch the node. My game crashes.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_item = function (player)
-- function(pos, node, player, pointed_thing)
local inv = player:get_inventory()
inv:add_item("main", "modname:nodename")
end,
replace_model = function (pos, node)
-- function(pos, node, puncher, pointed_thing)
minetest.set_node(pos, {name = "modname:othernodename", param2 = node.param2})
end,
on_punch = function (pos, node, player, pointed_thing)
node.get_item(player)
node.replace_model(pos, node)
end
})
I think I am about 90% of the way there, but am now moving as fast as a brick. So wat do now?
error 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
2017-02-13 21:02:12: ERROR[Main]: ServerError: Lua: Runtime error from mod 'modname' in callback node_on_punch(): /home/alex/.minetest/mods/modname/nodes.lua:68: attempt to call field 'get_item' (a nil value)
2017-02-13 21:02:12: ERROR[Main]: stack traceback:
2017-02-13 21:02:12: ERROR[Main]: /home/alex/.minetest/mods/modname/nodes.lua:68: in function </home/alex/.minetest/mods/modname/nodes.lua:67>
In case you are wondering, I use "modname" and "nodename" and stuff to keep the mod a secret :P
GreenDimond wrote:Functions hate me :(
I am trying to get a simple function to work, and it doesn't.Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
function() replace_donemodel(pos, node)
minetest.set_node(pos, {name = "modname:nodename", param2 = node.param2})
end,
on_place = {
minetest.after(2.0, replace_donemodel)}
This is inside a register_node.
I want the model to be replaced 2 seconds after it is placed (or set).
I have tried registering the function outside the register node aswell, but nothing works. What do?
EDIT: Fixed.
GreenDimond wrote:Functions hate me :(
I am trying to get a simple function to work, and it doesn't.Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
function() replace_donemodel(pos, node)
minetest.set_node(pos, {name = "modname:nodename", param2 = node.param2})
end,
on_place = {
minetest.after(2.0, replace_donemodel)}
This is inside a register_node.
I want the model to be replaced 2 seconds after it is placed (or set).
I have tried registering the function outside the register node aswell, but nothing works. What do?
EDIT: Fixed.
-- in definition of node A
on_punch = function(pos, node, puncher, pointed_thing)
minetest.set_node(pos, { name = "nodeBName", param2 = node.param2 })
minetest.after(2, minetest.set_node, pos, { name = "nodeCName", param2 = node.param2 })
end,
local function replace_donemodel(pos, node)
minetest.set_node(pos, {name = "waffles:wafflemaker_open_done", param2 = node.param2})
end
minetest.register_node("node:name", {
after_place_node = function(pos, placer, itemstack, pointed_thing)
local node = minetest.get_node(pos)
minetest.after(2.0, replace_donemodel, pos, node)
end
})
Users browsing this forum: No registered users and 3 guests