User:Xyz/stress

!

http://irc.minetest.ru/minetest/2013-02-17#i_2877771

Experimental implementation: https://github.com/xyzz/minetest-stress

Core concepts
All functions are prefixed with. All properties are prefixed with.

What do we want:
 * Consistent API
 * Good docs (with examples)


 * Chaining
 * Events
 * Nice assignments instead of ugly function calls . This is probably not a good idea though because it won't work in all places, making people confused.

Same for others.

Types
All  members should have   property containing their type as a string.

Underlined functions return, this should be used for method chaining.

Stress.Position
Same as position. Can be created from either  or

Supports -(unary), +, -, *.

Do use it as vector.

stressedArea
,,   are stressedPositions
 * —  is stressedNode
 * —  is stressedNode
 * —  is stressedNode

Stress.Node
Created via

Implements:
 * — get node name
 * — set node name (like )
 * — same as
 * — returns all meta as a table
 * — overwrites meta with the table (or should it rather update values instead of deleting all that are not present in the table?)
 * — get single meta value
 * — set meta
 * — returns Stress.Inventory (name is actually listname)

Stress.NodeDef
(needs better name)

Created via, i.e.


 * — registers event:
 * — registers ABM
 * every(time, function)
 * every(time, chance, function)
 * — registers ABM
 * every(time, function)
 * every(time, chance, function)
 * every(time, chance, function)

Stress.Inventory

 * — returns true if inventory is empty
 * — remove everything from inventory
 * — get size of an inventory
 * — set size of an inventory
 * ­— get the Xth stack from inventory, modifiable
 * ­— get the Xth stack from inventory, modifiable
 * ­— get the Xth stack from inventory, modifiable

Stress.Stack
Stress.Stack points to the specific slot in inventory.
 * — takes N items (or 1 if N is not provided)
 * — adds N items (or 1 if N is not provided)
 * — takes N items (or 1 if N is not provided)
 * — adds N items (or 1 if N is not provided)
 * — takes N items (or 1 if N is not provided)
 * — adds N items (or 1 if N is not provided)
 * — takes N items (or 1 if N is not provided)
 * — adds N items (or 1 if N is not provided)
 * — adds N items (or 1 if N is not provided)

Something
An example of code in stress: same without stress

Something more?