Package: bolt-expressions
bolt-expressionsapandas-esque API for creating expressions within boltIntroductionBolt is a scripting language which mixes both python and mcfunction. This package amplifies this language by adding an API for creating fluent expressions loosely based off of thepandassyntax. These expressions are use for simplifying large bits of scoreboard and storage operation allowing you to swiftly create complex operations with the ease of normal programming.frombolt_expressionsimportScoreboard,Datamath=Scoreboard.objective("math")storage=Data.storage(example:temp)stack=storage.hotbar[0]math["@s"]=stack.Count*math["$cost"]+math["$value"]-stack.tag.discount*0.75->executestoreresultscore@smathrundatagetstorageexample:temphotbar[0].Count1scoreboardplayersoperation@smath*=$costmathscoreboardplayersoperation@smath+=$valuemathexecutestoreresultscore$i1bolt.expr.temprundatagetstorageexample:temphotbar[0].tag.discount0.75scoreboardplayersoperation@smath-=$i1bolt.expr.tempInstallationThe package can be installed withpip. Note, you must havebeet,mechaandboltinstalled to use this package.$pipinstallbolt-expressionsGetting startedThis package is designed to be used within anyboltscript (either a.mcfunctionorboltfile) inside aboltenabled project.require:-bolt-bolt_expressionspipeline:-mechaOnce you've requiredboltandbolt_expressions, you are able to import the python package directly inside your bolt script.frombolt_expressionsimportScoreboard,DataNow you're free to use the API objects. Create objectives, block, storage and entity nbt sources to easily write expressions as simple or complex as you like to make it.math=Scoreboard.objective("math")executor=Data.entity("@s")block=Data.block("~ ~ ~")storage=Data.storage(example:storage)math["$value"]=math["$points"]+executor.Health*10+block.Items[0].Count-storage.discountstorage.values.append(math["$value"])->executestoreresultscore$valuemathrundatagetentity@sHealth10scoreboardplayersoperation$valuemath+=$pointsmathexecutestoreresultscore$i1bolt.expr.temprundatagetblock~~~Items[0].Count1scoreboardplayersoperation$valuemath+=$i1bolt.expr.tempexecutestoreresultscore$i2bolt.expr.temprundatagetstorageexample:storagediscount1scoreboardplayersoperation$valuemath-=$i2bolt.expr.tempdatamodifystorageexample:storagevaluesappendvalue0executestoreresultstorageexample:storagevalues[-1]int1runscoreboardplayersget$valuemathFeaturesRobust API supporting Scoreboards, Storage, Blocks, and EntitiesProvides an interface to manipulate large, complex mathematical expressions simplilyAutomatically initializes objectives and score constantsAllows you to interopt custom variables with normal commandsCheckout some examples over at ourdocs!ContributingContributions are welcome. Make sure to first open an issue discussing the problem or the new feature before creating a pull request. The project usespoetry.$poetryinstallYou can run the tests withpoetry run pytest.$poetryrunpytestThe project must type-check withpyright. If you're using VSCode thepylanceextension should report diagnostics automatically. You can also install the type-checker locally withnpm installand run it from the command-line.$npmrunwatch
$npmruncheckThe code follows theblackcode style. Import statements are sorted withisort.$poetryrunisortbolt_expressionsexamplestests
$poetryrunblackbolt_expressionsexamplestests
$poetryrunblack--checkbolt_expressionsexamplestestsLicense -MIT