Compare commits

12 Commits

Author SHA1 Message Date
c875a96af7 Add user alerts and check on node digging
- Bump to version 1.2.2
 - Add `metatools.alert_users` which sends the string passed as argument
   to all players currently operating on nodes
 - Register a dignode callback in which we alert users about players
   trying to dig operated nodes, or open nodes in general. Only node
   operated by a person different from the person digging are blocked
 - Add `metatools.get_context_from_pos`. It receives a table, but does
   no assertions (yet?)
 - Move `playerlocks` over to `metatools.playerlocks` for similar
   reasons to why we moved `nodelock`
 - Create field `success` for meta_exec, a function run when the command
   is successful; it receives the executed function's parameters and its
   output (status, msg) as arguments
 - Update /meta help's message
 - Fix instances of `contexts` not replaced by `metatools.contexts`
 - Assert that the context id is correct upon running `metatools.show`
2016-09-20 18:33:20 +02:00
73c80b1201 Move contexts over to the namespace to fix crash
- Move `contexts` into `metatools.contexts`, otherwise there is no way
   assertions.lua will be able to use it
2016-09-20 17:19:28 +02:00
0dfec122fe Add meta prune to close all unoperated nodes
- Add informations and help in meta command for the prune subcommand
 - Add `metatools.prune` to prune from the API
2016-09-19 19:03:49 +02:00
cff85689d7 Rewrite calls of meta_exec with new structure
- Pass a table to meta_exec containing parameters, function to be
   called, scope string and requirements to check
 - Add basic ownership and contextid requirement checks in meta_exec
   when needed
 - Update README.md
 - Move assertion tools to assertions.lua
2016-09-19 18:59:08 +02:00
2a4a2b6bfc Rewrite again to detach the API
- Rewrite the whole mod with a non-player-dependent approach
 - Store data in contexts rather than per-player registers
 - Make it look more like an actual API usable by mods, since now, it is
   one
2016-09-18 21:31:41 +02:00
ec2ae309da New version. New code. Everything is rewritten.
- Keep a similar structure but separate fields and inventory
   manipulation
 - Remove itemstack read, show can do it
 - Add list (list init, list delete) to manipulate lists
 - Rewrite the whole code for a new structure to come, with an API
2016-09-17 21:18:36 +02:00
2ed6e41fcf Crashfix on /meta set <variable name> without new value 2016-09-16 17:35:12 +02:00
0585ad63d4 Add command /meta erase 2016-08-26 19:15:08 +02:00
fbbe641e08 Removed WIP about tables
- Tables cannot be added as tables into metadatas, removed wip work. I'm likely
   going to rewrite this with serialize but only when the parallel manipulation
   system is implemented (write, read)
2015-06-13 14:10:41 +02:00
e5f7423c71 Early implementation of table handler
- Added basic feature for tables. Might be removed later
 - Updated TodoList
2015-05-12 21:51:18 +02:00
6cdef4dbc4 Fixed README.md
- Fixed metadata graph
2015-05-10 13:18:14 +02:00
58e462a485 Bumped version to 1.0
- Added check for stratum when meta::set
 - Updated README.md
 - Bumped version to 1.0
2015-05-08 14:51:48 +02:00
3 changed files with 891 additions and 394 deletions

View File

@ -2,9 +2,11 @@ Minetest mod metatools
######################
A mod inspired by mgl512's itemframe issue
Version : 1.2.2
# Authors
- LeMagnesium / Mg / ElectronLibre : Source code writer
- Paly2 / Palige : Contributor for the source code
- Ataron : Texture creater
# Purpose
@ -16,50 +18,41 @@ stratum.
"metatools_stick.png" by Ataron (CC-BY-NC-SA)
# Todo
- Add a check if set is done in Node/fields/
- Add a table handler for meta::set
- Rewrite the table stocking : a variable containing a copy of the global
table returned by :to_table(), on which we would work, and a save command to
apply it on the node
# Special thanks
- mgl512 (Le_Docteur) for its locked itemframe which gave me the idea of a tool
allowing to see/edit metadatas
- Ataron who created the stick's texture
- palige who agreed to test the mod for its first release, and contributed to the last version
# Command tutorial
- help => Get help
- open (x,y,z) => Open the node to manipulate at pos (x,y,z)
- show => Show fields/path list at actual position
- enter <path> => Enter next stratum through <path>
- quit => Quit actual field and go back to previous stratum
- set <name> <value> => Set metadata <name> to <value> (create it if it doesn't exist)
- itemstack => Manipulate itemstacks in Node/inventory/*/
- read <name> => Read itemstack at field name (itemstring and count)
- erase <name> => Erase itemstack at field name
- write <name> <itemstring> [<count>] => Set itemstack in field <name> with item <itemstring> and count <count>. Default count is one, 0 not handled.
- close => Close node
- Soon to come, please refer to /meta help until then
Node metadatas look like this :
Stratum : 0 1 2 ...
Nodes/
0 1 2 3 ...
Node/
|
+- fields
| |
| +- foo
| +- bar
| +- ...
+- inventory
|
+- main
| |
| +- 1
| +- 2
| +- 3
| +- ...
+- craft
| |
| +- 1
| +- 2
| +- 3
| +- ...
+- ...
+- fields
| |
| +- foo
| +- bar
| +- ...
+- inventory
|
+- main
| |
| +- 1
| +- 2
| +- 3
| +- ...
+- craft
| |
| +- 1
| +- 2
| +- 3
| +- ...
+- ...

38
assertions.lua Normal file
View File

@ -0,0 +1,38 @@
-- Assertion tools for Metatools
function assert_contextid(ctid)
return metatools.contexts[ctid] ~= nil
end
function assert_ownership(ctid, name)
return metatools.playerlocks[name] == ctid
end
function assert_pos(pos)
if type(pos) ~= "string" then
return pos and pos.x and pos.y and pos.z and minetest.pos_to_string(pos)
else
return minetest.string_to_pos(pos) ~= nil
end
end
function assert_mode(mode)
return mode and (mode == "fields" or mode == "inventory")
end
function assert_poslock(pos)
return nodelock[minetest.pos_to_string(pos)] == nil
end
function assert_specific_mode(contextid, mode)
return assert_contextid(contextid) and metatools.contexts[contextid].mode == mode
end
function assert_field_type(ftype)
return ftype and type(ftype) == "string" and (ftype == "int" or ftype == "float" or ftype == "string")
end
function assert_integer(int)
return int and tonumber(int) and tonumber(int) % 1 == 0
end

1182
init.lua

File diff suppressed because it is too large Load Diff