Page 1 of 1

[HELP NEEDED] SWAT Mod

PostPosted: Mon Feb 27, 2012 20:22
by tinoesroho
I'm coding a mod that grants the priv holders the ability to "SWAT" a player sky-high. Sadly, I'm a little stuck (as you can see, it swats the swatter sky-high, not the target.) Can I get a hand?

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_chat_message(function(name)
local cmd = "/swat"
minetest.env:get_player_by_name(name):setpos({x=0, y=300, z=0})
minetest.chat_send_all('Zeus smote a displeasing fool!')
        return true
end)

PostPosted: Mon Feb 27, 2012 23:41
by Gatharoth
Right now, your code is sending the person that types it in. Because of this line.

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.env:get_player_by_name(name):setpos({x=0, y=300, z=0})


You need to change the command, to require a name. And instead of using "(name)" use what was entered into the command.

As such, the on_chat_message function takes the name of the player typing the message. So again, "(name)" is going to be the one typing the message.