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
/placeblock default:stone 10,15,10
given: player name and param ("default:stone 10,15,10")
Now let's split this param string:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
-> Outputs an array: { "default:stone", "10,15,10" }
Now split the 2nd element into numbers:
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 arg_pos = args[2]:split(",")
local pos = { x = tonumber(arg_pos[1]), y = tonumber(arg_pos[2]), z = tonumber(arg_pos[3]) }
And the final 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
local args = param:split(" ")
if #args ~= 2 then
return false, "Wrong arguments"
end
local arg_pos = args[2]:split(",")
if #arg_pos ~= 3 then
return false, "Wrong arguments"
end
local pos = { x = tonumber(arg_pos[1]), y = tonumber(arg_pos[2]), z = tonumber(arg_pos[3]) }
minetest.set_node(pos, { name = args[1] })