moved overlay to the new command system, added spheres and boxes

This commit is contained in:
gnembon committed 2020-11-16 01:56:32 -04:00
1 parent 37391d2726
commit 7046166561
3 files changed
+73 -29

No files matched your search

+1 -1
View File
@@ -211,7 +211,7 @@ Here is a list of built-in types, with their return value formats, as well as a
* `'anchor'`: string of `feet` or `eyes`. * `'anchor'`: string of `feet` or `eyes`.
* `'entitytype'`: string representing a type of entity * `'entitytype'`: string representing a type of entity
* `'floatrange'`: pair of two numbers where one is smaller than the other * `'floatrange'`: pair of two numbers where one is smaller than the other
* `'players'`: returning a list of valid player entities. If configured with `'single'` returns only one player or `null`. * `'players'`: returning a list of valid player name string, logged in or not. If configured with `'single'` returns only one player or `null`.
* `'intrange'`: same as `'floatrange'`, but requiring integers. * `'intrange'`: same as `'floatrange'`, but requiring integers.
* `'enchantment'`: name of an enchantment * `'enchantment'`: name of an enchantment
* `'item'`: triple of item type, count of 1, and nbt. * `'item'`: triple of item type, count of 1, and nbt.
@@ -136,7 +136,7 @@ public class CarpetScriptHost extends ScriptHost
String hostName = main.getName(); String hostName = main.getName();
List<String> commandArgs = path.stream().filter(t -> t.isArgument).map(t -> t.surface).collect(Collectors.toList()); List<String> commandArgs = path.stream().filter(t -> t.isArgument).map(t -> t.surface).collect(Collectors.toList());
if (commandArgs.size() != (functionSpec.function.getNumParams()-functionSpec.args.size()) ) if (commandArgs.size() != (functionSpec.function.getNumParams()-functionSpec.args.size()) )
throw CommandArgument.error("Number of parameters in function doesn't match parameters for a command"); throw CommandArgument.error("Number of parameters in function "+functionSpec.function.fullName()+" doesn't match parameters for a command");
if (path.isEmpty()) if (path.isEmpty())
{ {
return command.executes((c) -> execute(c, hostName, functionSpec, Collections.emptyList())); return command.executes((c) -> execute(c, hostName, functionSpec, Collections.emptyList()));
@@ -27,35 +27,76 @@ global_renderers = m(
} }
); );
__command() -> ''; global_shapes = {'sphere' -> [], 'box' -> []};
monument() -> __toggle('monument', 'structures'); __config() ->
fortress() -> __toggle('fortress', 'structures'); {
mansion() -> __toggle('mansion', 'structures'); 'commands' -> {
jungle_pyramid() -> __toggle('jungle_pyramid', 'structures'); 'structure <structure>' -> _(s) -> __toggle(s, 'structures'),
desert_pyramid() -> __toggle('desert_pyramid', 'structures'); 'slime_chunks' -> ['__toggle', 'slime_chunks', 'chunks'],
endcity() -> __toggle('endcity', 'structures'); 'portal coordinates' -> ['__toggle', 'coords', 'portals'],
igloo() -> __toggle('igloo', 'structures'); 'portal links' -> ['__toggle', 'links', 'portals'],
shipwreck() -> __toggle('shipwreck', 'structures'); '<shape> <radius> following <player>' -> ['display_shape', [null,0xffffffff], true],
swamp_hut() -> __toggle('swamp_hut', 'structures'); '<shape> <radius> at <player>' -> ['display_shape', [null,0xffffffff], false],
stronghold() -> __toggle('stronghold', 'structures'); '<shape> <radius> following <player> <color>' -> ['display_shape', true],
ocean_ruin() -> __toggle('ocean_ruin', 'structures'); '<shape> <radius> at <player> <color>' -> ['display_shape', false],
buried_treasure() -> __toggle('buried_treasure', 'structures'); '<shape> clear' -> 'clear_shape',
pillager_outpost() -> __toggle('pillager_outpost', 'structures'); 'clear' -> 'clear',
mineshaft() -> __toggle('mineshaft', 'structures'); },
village() -> __toggle('village', 'structures'); 'arguments' -> {
nether_fossil() -> __toggle('nether_fossil', 'structures'); 'structure' -> {'type' -> 'term', 'suggest' -> [
bastion_remnant() -> __toggle('bastion_remnant', 'structures'); 'monument', 'fortress', 'mansion', 'jungle_pyramid',
ruined_portal() -> __toggle('ruined_portal', 'structures'); 'desert_pyramid', 'endcity', 'igloo', 'shipwreck',
'swamp_hut', 'stronghold', 'ocean_ruin', 'buried_treasure',
slime_chunks() -> __toggle('slime_chunks', 'chunks'); 'pillager_outpost', 'mineshaft', 'village', 'nether_fossil',
'bastion_remnant', 'ruined_portal'
portal_coordinates() -> __toggle('coords', 'portals'); ]},
portal_links() -> __toggle('links', 'portals'); 'player' -> {'type' -> 'players', 'single' -> true},
'radius' -> {'type' -> 'int', 'min' -> 0, 'max' -> 1024, 'suggest' -> [128, 24, 32]},
'shape' -> {'type' -> 'term', 'options' -> keys(global_shapes) },
'color' -> {'type' -> 'teamcolor'}
}
};
display_shape(shape, r, player, color, following) ->
(
clear() -> for(global_renderers, global_renderers:_:'tasks' = m() ); player = player(player);
if (!player, return());
if (shape == 'sphere',
shape_config = {
'center' -> if(following, [0,0,0], pos(player)),
'radius' -> r
}
, shape == 'box',
shape_config = {
'from' -> if(following, [-r,-r,-r], pos(player)-r),
'to' -> if(following, [r,r,r], pos(player)+r)
}
);
if (shape_config,
if (following, shape_config:'follow' = player);
shape_config:'fill' = color:1 - 200;
shape_config:'color' = color:1;
shape_config:'line' = 5;
draw_shape(shape, 72000, shape_config);
global_shapes:shape += shape_config;
)
);
clear_shape(shape) ->
(
for(global_shapes:shape, draw_shape(shape, 0, _));
global_shapes:shape = [];
);
clear() ->
(
for(global_renderers, global_renderers:_:'tasks' = m() );
for(global_shapes, clear_shape(_));
);
__toggle(feature, renderer) -> __toggle(feature, renderer) ->
( (
@@ -63,11 +104,11 @@ __toggle(feature, renderer) ->
config = global_renderers:renderer; config = global_renderers:renderer;
if( has(config:'tasks':feature), if( has(config:'tasks':feature),
delete(config:'tasks':feature); delete(config:'tasks':feature);
'disabled '+feature+' overlays'; print(p, format('gi disabled '+feature+' overlays'));
, ,
config:'tasks' += feature; config:'tasks' += feature;
if (!config:'active', call(config:'handler', p~'name')); if (!config:'active', call(config:'handler', p~'name'));
'enabled '+feature+' overlays'; print(p, format('gi enabled '+feature+' overlays'));
) )
); );
@@ -81,6 +122,9 @@ __should_run(renderer, player_name) ->
l(p, config); l(p, config);
); );
__structure_renderer(player_name) -> __structure_renderer(player_name) ->
( (
l(p, config) = __should_run('structures', player_name); l(p, config) = __should_run('structures', player_name);