gnembon / scarpet Goto Github PK
View Code? Open in Web Editor NEWPublic Repository of scarpet programs for Minecraft
License: Creative Commons Zero v1.0 Universal
Public Repository of scarpet programs for Minecraft
License: Creative Commons Zero v1.0 Universal
Having the ability to add custom enchantments built into scarpet. Adding NBT to look like enchantment text, with a hidden tag value so scarpet can add custom scripts when preforming actions with the new events, or with custom enchantment call events.
I found that the run() function only has 1 parameter which is the command itself, and the command seems to be run as console at the world origin. I have to use the 'execute' command with the vanilla entity selector to specify the runner and the position. I hope that the run() function can have some parameter such as 'runner' and 'pos' so that I can run a command as an entity which has been stored into a variable, or at a position which has been stored into a list.
Hello!
I couldn't find a way to get the name of an item which is held in the main hand. We want to use the hammer script, but with a diamond pickaxe which has the name "Hammer".
My question/issue: Can you check the name of an item and if so, how?
item_mainhand.0 is given... the correct code should be item_mainhand:0
scarpet/programs/survival/hammer.sc
Line 36 in b20acfe
I found that when sending a entity position (triplet of float) to the block() function, the xyz values seem to be rounded towards ZERO, which makes lots of problem. I'm using 1.13 carpet mod with scarpet 1.3.
I'm trying to create a funktion that automatically adds an a to the name of the Block. One big issue is that I haven't found a way to reed out the name of the current Structure Block. Another Problem is the fact that if you run /script run set(x,y,z,'structure_block','mode','save')
the appearing Structure Block is still in data mode.
~I'm from Germany therefor my english probably isn't the best
if I define an app like this:
//hello.sc
__command(who) -> print('Hello, ' + who + '!');
I would expect to be able to call it in-game as /hello 'world'
. But I actually get the error message, Incorrect argument for command
.
According to the documentation, if __command()
is defined, then it also defines all other global commands as sub-commands, so I assume that scarpet is looking for a sub-command called "world". But there are no sub-commands in this file, so I'd expect the "world" string to instead get passed to the __command() method. Is there a way to do this, or can the "root command" not accept arguments?
rather than try to track events that are hard to track, provide event hooks to attach custom functions to and manage them through /script events
I know there has to be a way to do this but I can't figure it out.
if (mainhand:custom_name:text == 'some_name')
I'm looking to do something similar to your storage drawers.
nbt(data:'CustomName'):'text' == 'Controller'
The installer does not allow me to specify where mine craft is located on my computer.
The system cannot find the path specified.
to patch client, you need to run 1.13.2 game at least once
Press any key to continue . . .
<<
Pressing any key closes the console. I've already ran, and re-ran the 1.13.2 patch.
Also, 7za.exe does nothing besides instantly crashing for me, even if ran as a admin.
By looking at the language syntax so far, it strikes me as something very unreadable at some points. Considering that (AFAIK) you wish this language would be embedded in MC, it is not very user friendly. I have some questions and issues that might clarify the design choices.
_
and __
) feel very primitive and limiting, and the namespace for custom functions will be running out quickly (with global functions like air
or put
). Did you think about namespacing them? What about relying on magic strings vs constants (_ ~ 'sneaking'
vs _ ~ Namespace.sneaking
)?_
"magic variable"... There is a reason magic variables are so rare. They are implicit, confusing and very demanding from a person who reads the code. From what it seems, you are trying to create some kind of Perl-inspired language, but there is a reason why it is pretty much dead nowadays.Even used on blocks in chunks that were never generated before the loaded() function returns 1.
If scarpet is truly going to be used in liaison with normal vanilla datapacks, which would be a nice thing to see, one must be able to manipulate the vanilla variables with scarpet: scores. I envision it as something like this:
score(scoreboard, entity)
returns score of 'entity' in scoreboard 'scoreboard' .If that entity is not tracked by the scoreboard, returns nothing.
'if(score('health',Ghoulboy)<2,print('Ghoulboy, you are dying!')'
add('score/entity',name,'score?',value?)
if running with 'score' in first parameter, then rest after 'name' is clearly redundant, scoreboard objective is created and that's it. But if it's 'entity', then you have to add what scoreboard, and 'value' defaults to zero if not specified
remove('score/entity','name','score?')
No need to guess here
I am assuming that with 'score' command, you will be able to manipulate it like a common variable, so you can set it and add to it as you will, so there will be no need for implementation of vanilla 'scoreboard players add' and 'scoreboard players set' command.
This way you could make datapacks and scarpet scripts interdependent in places where they should be, and make them run one another like:
end of first_function.mcfunction:
… script run do_important_complex_maths_that_you_cant_do_with_datapacks
and then to do_important_complex_maths_that_you_cant_do_with_datapacks.sc:
…(maths) run('function cool_stuff/second_function')
This way you could make a ton of things like BlingEdit way easier to code as they require tons of function files solely cos they need to do complex calculations what take like three lines in scarpet.
it may be cool to have an event or something for when a player presses a key(maybe just a key bind or even maybe all keys) that way you could create things like a fast forward key. while you hold down the key, the games runs as fast as it can
I agree - its annoying
eval() gives every scripting language a lot of power - ability to construct scripts, get them from unusual inputs and store in unusual ways. Examples: text of a written book. Items with custom behaviors encoded in the item metadata, input from external plugins e.g. discord chat, and so on. It's also probably the easiest way to implement lambda expressions, especially if paired with means to extract function source as a string.
So far blocks can only be removed with set(...air), Destroy is required for survival appliacations
The ability to add proper comments would be a great help for development. The current recommendation is to simply enclose comments in quotes, but this isn't great in some cases. Take the following line of code:
modify(_, 'pos', x*10, y, z*10)
Here, I've got a function which teleports a player far away. Obviously, this can have some unintended consequences when something isn't working right, so I want to comment it out until I know that it will be stable. The recommendation says to make it a string literal, but there's already one of those, so I end up needing to do:
'modify(_, \'pos\', x*10, y, z*10)'
Those two extra characters add up fast when dealing with many lines or lines that have more than one string literal in them. Note that they also need deleted once the line is uncommented.
I propose two/three solutions to this:
"
and '
for string literalsAs far as I can tell, "
isn't used anywhere in the language yet. If '
and "
could start and end strings, the code could be commented like so:
"modify(_, 'pos', x*10, y, z*10)"
This would have the side benefit of (slightly more easily) allowing for strings with '
in them, which may be useful, given that '
is common in English for contractions.
Alternatively,
We have line breaks ($
), so being able to comment out a line shouldn't be too difficult. I don't believe #
is used in the code syntax yet, and it is used as the comment in some other languages (Python, Ruby, Assembly, etc). The #
would start a comment that would last until the next $
. Then the code would look like:
# modify(_, 'pos', x*10, y, z*10)
And/or:
Many languages have comment block characters/strings (such as /* */
for Java/C). *
already has syntatic meaning in scarpet, so this may not be the best option, and the use of /
is common in Minecraft commands, so /*
may not be the best option. Perhaps { }
would be a good option. The code would then look like:
{modify(_, 'pos', x*10, y, z*10)}
This would also allow for multi-line comments.
Whatever happens, I am confident that comments would be of substantial help to developers, which would in turn encourage more developers to work on scarpet, which would in turn help show the power that such an API can have. If you have any thoughts or suggestions, I'd love to hear what other people working with scarpet think, and of course from gnembon as this is his language.
Are their plans or is it even possible to add the ability to create new blocks and items in the game (even GUI's) I know Minecraft has added the ability to sort of make new items but it is still very limiting and one of the biggest limits with it, is creating custom crafting recipes for these items.
Would love to create new blocks and basically entire mods in the game just through scripts.
general workaround is to call run('execute store...) inside the script. This would allow for more custom ways to store different types of results. But I agree, it would be good it if worked with execute store
particle('heart', pos(player))
... will generate particles at the targeted player's position in the dimension where the command is run, not in the dimension where the targeted player actually is.
Solve the bug how you like, but I think pos() carrying dimensional information (possibly as an optional 4th parameter for the sake of legacy code) is probably the best option.
Checked in carpet 1.3.6 and 1.3.7, running material() on a block that should be wood (i.e., oak log, stripped spruce log, birch planks, etc) will return as wool instead of the expected wood. As far as I can tell, happens with all variants of logs and planks, both normal and stripped. Didn't test with slabs/stairs though.
Can test by placing any wood one block northward of the player and running:
/script run print(material(pos_offset(pos(player()),'north')))
this might be because you seem to only retrieve the item's name after the modID. which in my experience you need to retrieve the entire string for it to work with modded items.
I presume scarpet issues go here as this is where it is released.
The material type for minecraft:dragon_egg is misspelled as "gragon_egg." This is in the docs as well.
In this code:
Object = m( l( 'myFunction', fun (x) -> ( print(x) ) ) );
call( Object : 'myFunction', 'Hello World!' );
I get an error "function 0 is not defined yet at position...".
Further testing revealed that all functions return a numerical value that cannot be called.
For example:
myCall( fun, param ) -> ( call( fun, param ); );
myCall( print, 'Hello World!' );
Gives me the same error.
Changing the scope to global does not fix this issue either.
Currently '\r\n\t'
etc. print as 'rnt'
.
If one would want to include them, they would need to write
'
'
instead.
After running /script invoke _haus
it spills that error message out. Any Ideas why it does that?
script run _haus() -> ( $ set(-11,102,37, 'structure_block'); run('data merge block -11 102 37 {mode:"SAVE", posX:1, posY:0, posZ:1, sizeX:13, sizeY:11, sizeZ:11, showair:0, ignoreEntities:0, name:"haus:1"}'); $ set(-12,102,36, 'structure_block'); run('data merge block -12 102 36 {mode:"SAVE", posX:1, posY:0, posZ:1, sizeX:2, sizeY:2, sizeZ:2, showair:0, ignoreEntities:0, name:"haus:1"}'); $ set(-10,103,38, 'structure_block'); run('data merge block -10 103 38 {mode:"LOAD", posX:-1, posY:-1, posZ:-1, name:"haus:1"}'); $ set(-10,102,38, 'structure_block'); run('data merge block -10 102 38 {mode:"LOAD", posX:0, posY:0, posZ:0, name:"haus:1"}') $)
I use VS Code for writing programs, and it would be awesome if you could add support for it. Thanks.
There is no current way to detect when a player places a block without some complex stuff which means that my new script is practically broken
It's stated that it should be possible to use a datapack to store scripts instead of typing them in a commandblock or chat.
But it's never mentioned how it's done.
So I'm asking how to do it and if it isn't possible are there any other ways to do it ?
Holy Hand Grenade on a 1.15 fabric server will crash it, but on a single player world using the fabric client it works fine. I am sure it is a bug with the fabric server version. I think the vine-miner doesn't work ether.
Essentially I see it as like more files added in the .jar file in the directory of event-test.sc, but with all the apps in programs/fundamentals and when the ability comes to import functions, you wont have to copy pasta code, you can just do like import(math.sc,rnd) at the beginning, and it will glow yellow and you can do rnd(whatever,whatever)
I've made a function a few days ago and run it. Now I wan't to chane some bits and pices, but I havn't save a file and the commandblock is destroyed. Is there a way to look up, how my Function worked?
It is currently not possible to import functionality from one app to another.
I suggest a node.js-esque solution:
// in myFirstApp.cs
app : 'exports' = m(
l( 'A', _( a, b ) -> functionA( a, b ) ),
l( 'B', _( a, b ) -> functionB( a, b ) )
);
// or
export(
m(...)
);
and
// in mySecondApp.cs
firstApp = import( 'myFirstApp.cs' ); // reference to app : 'exports' from myFirstApp.cs
While it is possible to run( 'script load myFirstApp' );
, its not really possible to retreive values in a non-hacky way.
Would it possible to implement MySQL connections eventually?
I would love to have something like test_events to populate some tables so I can query stuff later.
Being able to query more slots than hands and armour, and being able to modify them (using items, affecting durability of tools, armour etc)
If you try evaluating type( _(...) -> (...) );
You will get "How did you get there? Cannot get type of an internal type".
Also, putting this expression in a try...catch block does not catch the exception.
I suggest setting the type of a lambda expression to 'function'.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.