Skip to content

Commit bcd11e9

Browse files
committed
Visibility page
1 parent 2846dee commit bcd11e9

File tree

4 files changed

+41
-2
lines changed

4 files changed

+41
-2
lines changed

functions/Blip/createBlip.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ shared: &shared
4848
default: '16383.0'
4949
- name: visibleTo
5050
type: element
51-
description: This defines which elements can see the blip. Defaults to visible to everyone. See [[visibility]].
51+
description: This defines which elements can see the blip. Defaults to visible to everyone. See [[Visibility]].
5252
default: 'getRootElement()'
5353
returns:
5454
values:

functions/Blip/createBlipAttachedTo.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ shared: &shared
4343
default: '16383.0'
4444
- name: visibleTo
4545
type: element
46-
description: This defines which elements can see the blip. Defaults to visible to everyone. See [[visibility]].
46+
description: This defines which elements can see the blip. Defaults to visible to everyone. See [[Visibility]].
4747
default: 'getRootElement()'
4848
returns:
4949
values:

web/astro.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ export default defineConfig({
130130
{ label: "Element Types", link: "/reference/Element" },
131131
{ label: "Element Tree", link: "/reference/Element_tree" },
132132
{ label: "Entities", link: "/reference/Entity" },
133+
{ label: "Visibility", link: "/reference/Visibility" },
133134
],
134135
},
135136
{
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import AutoStarlightPage from '@src/components/AutoStarlightPage.astro';
2+
import { Code } from '@astrojs/starlight/components';
3+
import { getSeeAlsoLinksFromList } from '@src/utils/general';
4+
import SeeAlsoSection from '@src/components/SeeAlsoSection.astro';
5+
6+
<AutoStarlightPage frontmatter={{
7+
template: 'doc',
8+
title: 'Visibility',
9+
tableOfContents: false
10+
}}>
11+
12+
The visibility system for [markers](/reference/marker), [blips](/reference/blip) and [radar-areas](/reference/radararea) works by the following rule:
13+
- **if something is visible to a certain [element](/reference/element), it is also visible to all of that element's children. Also, everything is visible to the root element by default.**
14+
15+
This means that if you want to make e.g. a blip only visible for a few specific players, you need to do two things:
16+
- Make the blip invisible to the [root](/reference/root) element, using [setElementVisibleTo](/reference/setElementVisibleTo). The blip is now hidden for all players.
17+
- Make the blip visible again for the desired players.
18+
19+
The same things go for markers.
20+
21+
If you only want something to be visible to certain players the most efficient and least buggy thing to do is to when creating the element instead of the default visibility of [root](/reference/root), set it to [resourceRoot](/reference/resourceRoot) (no player will see it as no player is a child of resourceRoot) and then use [setElementVisibleTo](/reference/setElementVisibleTo) on specific players. Otherwise there is a chance that players will see the blip for a fraction of a second, as the blip is created but then destroyed right after.
22+
23+
This is bad (chance of being seen on minimap for about 50ms):
24+
<Code lang="lua" code="a = createBlip(0, 0, 0, 41)
25+
setElementVisibleTo(a, root, false)
26+
setElementVisibleTo(a, somePlayer, true)" />
27+
28+
This is good:
29+
30+
<Code lang="lua" code="a = createBlip(0, 0, 0, 41, 1, 2, 3, 4, 5, 6, 9999, resourceRoot)
31+
setElementVisibleTo(a, somePlayer, true)" />
32+
33+
<SeeAlsoSection seeAlsoLinks={getSeeAlsoLinksFromList([
34+
'reference:Predefined_variables',
35+
'reference:Element_tree',
36+
])} currentId='' />
37+
38+
</AutoStarlightPage>

0 commit comments

Comments
 (0)