classroom/README.md

127 lines
3.9 KiB
Markdown
Raw Permalink Normal View History

2019-07-09 21:15:52 -07:00
# Classroom Manager
An easy way to manage students in-game, with support for bulk actions and macros.
2019-11-24 12:26:55 -08:00
An action is something that can be performed on a selection of students.
You can use actions to move players, grant/revoke privs, and more.
A list of built-in actions can be found below, however, you can
add more actions using the API for this mod.
This mod requires Minetest 5.1 or later.
2019-07-09 21:15:52 -07:00
Author: rubenwardy<br>
2022-09-03 07:32:59 -07:00
License: MIT
2019-07-09 21:15:52 -07:00
## Usage
First, make sure that you grant the `teacher` priv to any teachers like so:
/grant username teacher
This allows them to access the classroom control panel, and exempts them from
being included in actions.
2019-11-24 12:26:55 -08:00
Open the Inventory and switch to the classroom tab.
Only sfinv is supported currently.
2019-07-09 21:15:52 -07:00
* The set of students that an action works on depends on the toggle bar at the top.
* **All:** apply the action to all students, but not teachers.
* **Group:** apply the action to all students in the currently selected group.
* **Selected:** apply the action only to the student that is currently selected.
2019-11-24 12:26:55 -08:00
* You can changed the selected group using the tab header to the left.
* You can manage groups using the New/Edit Group buttons in the
top-right.
* Use `>` to add the selected player to the group, `<` to remove.
2019-07-09 21:15:52 -07:00
### Actions
| Name | Behaviour |
|-------------|--------------------------------------------------------------------|
| Bring | Teleports users to your position |
| Look | Rotates the users to look at the teacher |
| Mute/Unmute | Grants or revokes the ability to use chat |
| Fly/No fly | Grants or revokes the ability to fly (key: K) |
2019-11-24 08:39:27 -08:00
| Kick | Remove from the server |
| Ban | Permanently exclude from the server |
| Audience | Move to the crosshair location, spread out and facing you |
2019-11-24 12:26:55 -08:00
## API
**WARNING:** This API is unstable, and breaking changes may be introduced before 1.0 is released.
### Selectors
A selector is a string which represents a selection of students.
* `*` - All students
* `group:<name>` - All students in group `<name>`
* `user:<name>` - The user `<name>`
### Actions
```lua
classroom.register_action("mymod:bring", {
2019-11-24 12:26:55 -08:00
-- Button text
title = "Bring",
-- Button tooltip
description = "Teleport players to your location",
-- Whether this should be restricted to online players
-- TODO: false isn't supported yet
online_required = true,
-- Function to perform the action
func = function(runner, names)
local pos = runner:get_pos()
for i=1, #names do
local player = minetest.get_player_by_name(names[i])
player:set_pos(pos)
end
end,
-- Custom keys are allowed
})
```
### Group
```lua
{
-- Human-readable group name
name = name,
-- List of student names
students = {},
-- Custom keys are allowed
}
```
### Methods
* `classroom.get_students()`
* Get online students
* Returns list of player names
* `classroom.get_group_students(name)`
* Get students in group, some students may be offline
* Returns list of player names
* `classroom.get_students_except(excluded_students)`
* Get online students not in the list `excluded_students`
* Returns list of player names
* `classroom.get_all_groups()`
* Returns table of `groupname -> group`
* `classroom.get_group(name)`
* Returns group
* `classroom.create_group(name)`
* Creates a group
* Returns the newly created group or nil if the name already exists
* `classroom.add_student_to_group(group_name, student_name)`
* `classroom.remove_student_from_group(group_name, student_name)`
* `classroom.register_action(name, action_def)`
* `classroom.get_actions()`
* Returns list of action defs
* `classroom.get_students_by_selector(selector)`
* Gets online students using a selector.
* Returns list of player names