Skip to content

Commit

Permalink
set default channel and owner on place
Browse files Browse the repository at this point in the history
  • Loading branch information
BuckarooBanzay committed Dec 16, 2020
1 parent 62c62de commit 2998723
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions controller.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ minetest.register_node("digiline_global_memory:controller", {
cracky=3
},

on_construct = function(pos)
after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos)
-- default digiline channel
meta:set_string("channel", "global_memory")
meta:set_string("owner", placer:get_player_name() or "")
meta:set_string("formspec","field[channel;Channel;${channel}")
end,

Expand Down Expand Up @@ -47,8 +50,7 @@ minetest.register_node("digiline_global_memory:controller", {
end
local meta = minetest.get_meta(pos)
if fields.channel then
-- set owner and channel on submit
meta:set_string("owner", name)
-- setchannel on submit
meta:set_string("channel",fields.channel)
end
end,
Expand Down
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ digiline_send("channel", {
})
```

**NOTE**: the memory is bound to the user who placed it, the same register can only be accessed if it is placed by the same player

# Chatcommands

* **/digiline_global_memory [name]** Returns the contents of the current players memory with given name
Expand Down

0 comments on commit 2998723

Please sign in to comment.