Compare commits

...

8 Commits

Author SHA1 Message Date
Starbeamrainbowlabs 45bed5cc71
docs: Improve //noise2d documentation
Thanks to @notsowow for pointing out that it didn't make sense!
2023-12-26 19:07:41 +00:00
Starbeamrainbowlabs faddfe1d48
reference: document movement speed adjustment tool
also update changelog
2023-12-26 15:06:29 +00:00
Starbeamrainbowlabs 7d3b35a47b
wea_wands: Add move speed adjustment tool
It alters the current player's movement speed up or down in x0.5 increments. Min = x0.5.
left/primary click: increase speed
right/secondary click: decrease speed
min speed = 0.5
documentation incoming!
2023-12-26 14:59:46 +00:00
Starbeamrainbowlabs 0a9c125316
Implement //speed 2023-12-26 13:37:19 +00:00
Starbeamrainbowlabs 6d81d47a31
.....why?!?! 2023-12-26 13:23:48 +00:00
Starbeamrainbowlabs a855ca729e
docs/HTMLPicture: remove debug logging 2023-12-26 13:12:17 +00:00
Starbeamrainbowlabs 460aed4f3b
such a stupid bug 2023-12-26 12:27:02 +00:00
Starbeamrainbowlabs 259b332883
docs: ....why wasn't this a problem *years* ago? 2023-12-26 12:22:57 +00:00
13 changed files with 203 additions and 29 deletions

View File

@ -138,6 +138,6 @@ module.exports = function(eleventyConfig) {
eleventyConfig.addPairedShortcode("gallerybox", shortcode_gallerybox);
eleventyConfig.addPassthroughCopy({
"node_modules/keen-slider/keen-slider.es.js": "."
"node_modules/keen-slider/keen-slider.es.js": "./keen-slider.es.js"
});
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 580 KiB

View File

@ -118,6 +118,8 @@ async function picture(source_image, alt, target_dir, urlpath, formats = "__AUTO
}
const target_original = path.join(target_dir, source_parsed.base);
if (!fs.existsSync(path.dirname(target_original)))
await fs.promises.mkdir(path.dirname(target_original), { recursive: true });
await fs.promises.copyFile(source_image, target_original);
const sources = await Promise.all(formats.map(async (format) => {
@ -134,7 +136,7 @@ async function picture(source_image, alt, target_dir, urlpath, formats = "__AUTO
};
}));
let result = `<picture>\n\t`;
let result = `<picture data-zoomable="true">\n\t`;
result += sources.map(source => `<source srcset="${source.srcset}" type="${source.mime}" />`).join(`\n\t`);
result += `\n\t<img loading="lazy" decoding="async" src="${urlpath}/${source_parsed.base}" alt="${htmlentities.encode(alt)}" />\n`;
result += `</picture>\n`

View File

@ -11,9 +11,12 @@ Note to self: See the bottom of this file for the release template text.
- Added [`//nodeapply`](https://worldeditadditions.mooncarrot.space/Reference/#nodeapply), a generalisation of [`//airapply`](https://worldeditadditions.mooncarrot.space/Reference/#airapply) that works with a defined list of nodes. Check out [the reference](https://worldeditadditions.mooncarrot.space/Reference/#nodeapply) - it has some cool tricks to it! (thanks for suggesting, @kliv91 from the Discord server!)
- Added [`//ngroups`](https://worldeditadditions.mooncarrot.space/Reference/#ngroups), which lists the groups that a given node is a member of. Useful when paired with [`//nodeapply`](https://worldeditadditions.mooncarrot.space/Reference/#nodeapply)!
- Added [`//rotate+`](https://worldeditadditions.mooncarrot.space/Reference/#rotate) to rotate regions through arbitrary series of potentially non-axis-aligned rotations.
- Added [`//speed`](https://worldeditadditions.mooncarrot.space/Reference/#rotate) to adjust your own movement speed
- Also added an associated [movement speed adjustment tool](https://worldeditadditions.mooncarrot.space/Reference/#movement), which looks like this: ![A picture of the move speed adjustment tool. It looks like a monarch butterfly.](https://raw.githubusercontent.com/sbrl/Minetest-WorldEditAdditions/dev/worldeditadditions_farwand/textures/worldeditadditions_movement.png)
### Bugfixes and changes
- Don't warn on failed registration of `//flora` → [`//bonemeal`](https://worldeditadditions.mooncarrot.space/Reference/#bonemeal) if the `bonemeal` mod isn't installed (e.g. in MineClone2) - thanks @VorTechnix in #106
- Improve documentation of [`//noise2d`](https://worldeditadditions.mooncarrot.space/Reference/#noise2d). If it still doesn't make sense, please let me know. It's a complicated command that needs reworking a bit to be easier to use.
## v1.14.5: The multipoint update, hotfix 5 (1st August 2023)

View File

@ -737,10 +737,32 @@ Usage examples:
### `//noise2d [<key_1> [<value_1>]] [<key_2> [<value_2>]] ...]`
Applies 2D noise to the terrain in the defined region. Like `//erode`, this command accepts a number of different key-value parameters and provides a number of different underlying algorithms.
In other words, this command changes the height of the terrain according to some noise function (e.g. Perlin noise):
![//noise2d applies 2D noise as a modifier to terrain height.](https://raw.githubusercontent.com/sbrl/Minetest-WorldEditAdditions/dev/.docs/images/reference/noise2d.jpeg)
It does so like this:
1. Take coordinates of each column
2. Plug them through a noise function (see below)
3. Apply the generated noise value to the terrain.
`//noise2d` has a number of parameters that let you adjust the mathematical properties of step 2, which are explained in the table below.
Some terms that are useful to know:
- **Scale:** How big or small the noise is. Lower values stretch it out to be bigger, and higher values squash it in.
- **Offset:** Noise is calculated by passing some coordinates into a function.
- **Perlin:** A noise algorithm. `//noise2d` defaults to this.
#### Table of parameters
Parameter | Type | Default Value | Description
------------|-----------|---------------|-----------------------
algorithm | `string` | perlinmt | The 2D noise algorithm to apply - see below.
apply | `string¦integer` | 5 | How to apply the noise to the terrain - see below.
scale | `float` | 1 | Sets `scalex`, `scaley`, and `scalez` all at once. Consider also `//apply`.
scalex | `float` | 1 | The scale of the noise on the x axis.
scaley | `float` | 1 | The scale of the noise on the y axis.
scalez | `float` | 1 | The scale of the noise on the z axis.
@ -751,12 +773,29 @@ exponent | `float` | 0 | Raise the generated noise value (with a range of 0 t
multiply | `float` | 1 | Multiply the generated noise value by this number
add | `float` | 0 | Add this number to the generated noise value.
#### Apply
Different values of the `apply` parameter result in the generated noise values being applied in different ways:
- An integer indicates that the noise should be rescaled to a given amplitude (equal parts of the range above and below 0) before being added to the terrain heightmap.`
- The exact string `add`: Noise values are added to each heightmap pixel.
- The exact string `multiply`: Each heightmap pixel is multiplied by the corresponding noise value.
1. An integer indicates that the noise should be rescaled to a given amplitude (equal parts of the range above and below 0) before being added to the terrain heightmap.`
2. The exact string `add`: Noise values are added to each heightmap pixel.
3. The exact string `multiply`: Each heightmap pixel is multiplied by the corresponding noise value.
An integer is the most common way to use `//noise2d`. So, for example:
```weacmd
//noise2d apply 5
```
...would alter the height of each column of nodes by at most 5 blocks either side, while:
```weacmd
//noise2d apply 10
```
...would alter the height by 10 blocks instead of 5.
#### Types of noise
Another thing that can be changed is the noise algorithm. This changes what the noise that is applied to the terrain looks like.
The following algorithms are currently available:
@ -765,7 +804,7 @@ Algorithm | Description
`perlinmt` | **Default**. Perlin noise, backed by Minetest's inbuilt `PerlinNoise` class.
`perlin` | Perlin noise, backed by a pure Lua perlin noise implementation. Functional, but currently contains artefacts I'm having difficulty tracking down.
`sin` | A sine wave created with `math.sin()`.
`white` | Random white noise.
`white` | Random white noise. In other words, just random values.
`red` | Red noise - has a lower frequency than white noise. Ref [Noise Functions and Map Generation by Red Blob Games](https://www.redblobgames.com/articles/noise/introduction.html).
`infrared` | Even smoother than red noise. Tends to also be quite flat unless you use a slightly higher `apply` value (e.g. `20`).
@ -776,6 +815,7 @@ When specifying algorithm names, the `algorithm` parameter name is optional. For
//noise2d offsetx 4 algorithm perlin scale 0.2
```
#### Further examples
Example invocations:
```weacmd
@ -1494,6 +1534,23 @@ This command is intended for development and modding. You will not normally need
-->
### `//speed [<value=1>]`
Adjusts your player movement speed to the specified value. In other words:
```weacmd
//speed 2
```
...will double your movement speed.
This command also takes Minetest's "Fast mode" into account and adjusts accordingly. Relative adjustments can be done by prepending either a `+` to increase or `-` to decrease respectively.
```weacmd
//speed +0.5
//speed -3
```
### `//y`
Confirms the execution of a command if it could potentially affect a large number of nodes and take a while. This is a regular WorldEdit command.
@ -1524,6 +1581,15 @@ Prevents the execution of a command if it could potentially affect a large numbe
██ ██████ ██████ ███████ ███████
-->
### Movement speed adjustment tool
The movement speed adjustment tool, as the name suggests, adjusts your local player movement speed. It looks like this: ![A picture of the move speed adjustment tool. It looks like a monarch butterfly.](https://raw.githubusercontent.com/sbrl/Minetest-WorldEditAdditions/dev/worldeditadditions_farwand/textures/worldeditadditions_movement.png).
Primary (left) clicking will increase your movement speed, and secondary (right) clicking will decrease it in x0.5 increments, down to a minimum of x0.5.
Note this only affects **you**, and **not any other player**.
See also [`//speed`](#speed).
### Far Wand
The far wand (`worldeditadditions:farwand`) is a variant on the traditional WorldEdit wand (`worldedit:wand`). It looks like this: ![A picture of the far wand](https://raw.githubusercontent.com/sbrl/Minetest-WorldEditAdditions/main/worldeditadditions_farwand/textures/worldeditadditions_farwand.png)

17
package-lock.json generated
View File

@ -1,17 +0,0 @@
{
"name": "WorldEditAdditions",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"dependencies": {
"keen-slider": "^6.8.6"
}
},
"node_modules/keen-slider": {
"version": "6.8.6",
"resolved": "https://registry.npmjs.org/keen-slider/-/keen-slider-6.8.6.tgz",
"integrity": "sha512-dcEQ7GDBpCjUQA8XZeWh3oBBLLmyn8aoeIQFGL/NTVkoEOsmlnXqA4QykUm/SncolAZYGsEk/PfUhLZ7mwMM2w=="
}
}
}

View File

@ -1,5 +0,0 @@
{
"dependencies": {
"keen-slider": "^6.8.6"
}
}

View File

@ -0,0 +1,74 @@
local weac = worldeditadditions_core
local wea = worldeditadditions
local weacmd = worldeditadditions_commands
local Vector3 = weac.Vector3
-- ███████ ██████ ███████ ███████ ██████
-- ██ ██ ██ ██ ██ ██ ██
-- ███████ ██████ █████ █████ ██ ██
-- ██ ██ ██ ██ ██ ██
-- ███████ ██ ███████ ███████ ██████
worldeditadditions_core.register_command("speed", {
params = "[<value=1>]",
description =
"Changes your movement speed. A value of 1 = normal speed. Prepend + or - to add or subtract a given amount from the current value.",
privs = { worldedit = true },
require_pos = 0,
parse = function(params_text)
if not params_text or params_text == "" then
params_text = "1"
end
local speed
local mode = "absolute"
params_text = weac.trim(params_text)
if params_text:sub(1,1) == "+" or params_text:sub(1,1) == "-" then
mode = "relative"
end
speed = tonumber(params_text)
if not speed then return false, "Error: Invalid speed value. The speed value must be a number." end
print("DEBUG:speed/parse PARAMS_TEXT", params_text, "MODE", mode, "SPEED", speed)
return true, mode, speed
end,
nodes_needed = function(name)
return 0
end,
func = function(name, mode, speed)
local start_time = weac.get_ms_time()
print("DEBUG:speed NAME", name, "MODE", mode, "SPEED", speed)
local player = minetest.get_player_by_name(name)
if mode == "absolute" then
player:set_physics_override({
speed = speed,
climb_speed = speed
})
elseif mode == "relative" then
local overrides = player:get_physics_override()
local src_speed = overrides.speed or 1
local src_climb_speed = overrides.climb_speed or 1
player:set_physics_override({
speed = src_speed + speed,
climb_speed = src_climb_speed + speed
})
else
return false, "Error: Unknown adjustment mode '"..tostring(mode).."'. This is a bug."
end
local overrides_after = player:get_physics_override()
local time_taken = weac.get_ms_time() - start_time
return true, "Movement speed is now x"..tostring(overrides_after.speed).."."
end
})

View File

@ -58,6 +58,8 @@ dofile(wea_cmd.modpath.."/commands/wireframe/init.lua")
dofile(wea_cmd.modpath.."/commands/extra/saplingaliases.lua")
dofile(wea_cmd.modpath.."/commands/extra/basename.lua")
dofile(wea_cmd.modpath.."/commands/extra/sculptlist.lua")
dofile(wea_cmd.modpath.."/commands/extra/speed.lua")
-- Don't register the //bonemeal command if the bonemeal mod isn't present
if minetest.global_exists("bonemeal") then

View File

@ -0,0 +1 @@
{"modelVersion":2,"piskel":{"name":"New Piskel","description":"","fps":12,"height":16,"width":16,"layers":["{\"name\":\"Layer 1\",\"opacity\":1,\"frameCount\":1,\"chunks\":[{\"layout\":[[0]],\"base64PNG\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABNElEQVQ4T2NkoBAwouu/eGDD//VbtzI0dM9GkWsoTf0f6O3NoO8QgCKOYQDMQJAGmCHIbHQLGZ2MNf8jC+47ex1uqIoQL1juzrvPcDF09WADlmvdZWDXFmMIWs2LYsGj+0/AfDlFGRTxdaGfGX5efcUQeU2ZAe4CmCEgCRAASSIbAJIHAZBFMM0gPthpMFeANIFMhwGTro9g5pkyfrgYyJUgw0BqQd6FGwDTCFIAY6MbgCwHYqMYALIC2RvYvIDufLgBMG8ghxTIFcguQA9gWGyhpAPkGGF30WfQdTsENvPyLjuGn3suwgMPOaox4hcWRXz5rigGfJq4GyWqUVwASxwwzSBbxRf/YkROSC9j2cCJCjm9gMMA2dmw+IWZjp4SsanFSMogW5D9iByw6MkYnpAoydEAgo7FIqjtR/0AAAAASUVORK5CYII=\"}]}"]}}

View File

@ -8,5 +8,7 @@ dofile(modpath.."/lib/do_raycast.lua")
dofile(modpath.."/lib/farwand.lua")
dofile(modpath.."/lib/cloudwand.lua")
dofile(modpath.."/lib/multiwand.lua")
dofile(modpath.."/lib/movetool.lua")
dofile(modpath.."/lib/chatcommand.lua")
dofile(modpath.."/lib/settings.lua")

View File

@ -0,0 +1,46 @@
local function adjust_speed_relative(player, offset)
local overrides = player:get_physics_override()
local src_speed = overrides.speed or 1
local src_climb_speed = overrides.climb_speed or 1
player:set_physics_override({
speed = math.max(src_speed + offset, 0.5),
climb_speed = math.max(src_climb_speed + offset, 0.5)
})
-- Completely paranoid is me
local overrides_after = player:get_physics_override()
worldedit.player_notify(player:get_player_name(), "Movement speed is now x" .. tostring(overrides_after.speed))
end
local function use_primary(player)
adjust_speed_relative(player, 0.5)
end
local function use_secondary(player)
adjust_speed_relative(player, -0.5)
end
minetest.register_tool(":worldeditadditions:movetool", {
description = "WorldEditAdditions movement speed adjustment tool",
inventory_image = "worldeditadditions_movement.png",
on_use = function(itemstack, player, pointed_thing)
-- Left click
use_primary(player)
end,
on_secondary_use = function(itemstack, player, pointed_thing)
-- Right click when pointed at nothing
use_secondary(player)
end,
on_place = function(itemstack, player, pointed_thing)
-- Right click when pointed at something
use_secondary(player)
end
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 B