#Autocompressor question: Do i have to do this for every block i need to do?
1 messages · Page 1 of 1 (latest)
i heard u can do functions
like this:
on script load: set {autocompressor::*} to oak log, stone, coal ore, iron ore function autocompress(p: player): loop {_p}'s inventory: if {autocompressor::*} contains loop-value: if loop-value is oak log: amount of loop-value is greater than 63 remove 64 of oak log from {_p}'s inventory give {_p} 1 of glowing stripped oak wood named "&dCompressed Oak" if loop-value is stone: amount of loop-value is greater than 63 remove 64 of stone from {_p}'s inventory give {_p} 1 of glowing smooth stone named "&dCompressed Stone" if loop-value is coal ore: amount of loop-value is greater than 63 remove 64 of coal ore from {_p}'s inventory give {_p} 1 of glowing coal block named "&dCompressed Coal" if loop-value is iron ore: amount of loop-value is greater than 63 remove 64 of iron ore from {_p}'s inventory give {_p} 1 of glowing iron block named "&dCompressed Iron"
that is not a function
the whole point of a function is to avoid repeating lines
i think i even made a compressed %item% expression in reflect when I played around with compressors for a day
bruh this compressor stuff is so confusing
make a list of items you want to be compressed, then make a list of what those items turn into, and then make a list of how much of those items you need until it's compressed assuming you have different amounts for each material. here is an example
{item::1} is dirt
{compressed::1} is compressed dirt
{amount::1} is 32
{item::2} is stone
{compressed::2} is compressed stone
{amount::2} is 64
now you loop their inventory or whatever and just check the item and then the index of that for each list and yeah does that make sense
i would have to write it out but ill probably mess it up
`on script load:
set {compress.item::1} to oak log
set {compress.result::1} to stripped oak wood named "&dCompressed Oak"
set {compress.amount::1} to 64
set {compress.item::2} to cobblestone
set {compress.result::2} to smooth stone named "&dCompressed Stone"
set {compress.amount::2} to 64
set {compress.item::3} to coal
set {compress.result::3} to coal block named "&dCompressed Coal"
set {compress.amount::3} to 64
set {compress.item::4} to raw iron
set {compress.result::4} to iron block named "&dCompressed Iron"
set {compress.amount::4} to 64
function autocompress(p: player):
loop {compress.item::*}:
set {_i} to loop-index
set {_item} to {compress.item::%{_i}%}
set {_need} to {compress.amount::%{_i}%}
set {_result} to {compress.result::%{_i}%}
set {_count} to amount of {_item} in {_p}'s inventory
set {_times} to floor({_count} / {_need})
if {_times} > 0:
remove {_times} * {_need} of {_item} from {_p}'s inventory
loop {_times} times:
set {_give} to {_result}
add enchantment unbreaking to {_give}
add item flag hide enchants to {_give}
give {_p} {_give}
on block break:
wait 1 tick
autocompress(player)`
Try the correct syntax
wdym
i tried that too
doesnt work
one error
`on script load:
set {compress.item::1} to oak log
set {compress.result::1} to stripped oak wood named "&dCompressed Oak"
set {compress.amount::1} to 64
set {compress.item::2} to cobblestone
set {compress.result::2} to smooth stone named "&dCompressed Stone"
set {compress.amount::2} to 64
set {compress.item::3} to coal
set {compress.result::3} to coal block named "&dCompressed Coal"
set {compress.amount::3} to 64
set {compress.item::4} to raw iron
set {compress.result::4} to iron block named "&dCompressed Iron"
set {compress.amount::4} to 64
function autocompress(p: player):
loop {compress.item::*}:
set {_i} to loop-index
set {_item} to {compress.item::%{_i}%}
set {_need} to {compress.amount::%{_i}%}
set {_result} to {compress.result::%{_i}%}
set {_count} to amount of {_item} in {_p}'s inventory
set {_times} to floor({_count} / {_need})
if {_times} > 0:
remove {_times} * {_need} of {_item} from {_p}'s inventory
loop {_times} times:
set {_give} to {_result}
enchant {_give} with unbreaking 1
hide enchants of {_give}
give {_p} {_give}
on block break:
wait 1 tick
autocompress(player)`
like this?
i got that one error for line 36
Please just look at the docs instead of trial-and-erroring the syntax
can u send me it
@craggy drift you could also enchant the item when you set the compressed variant
why add it with the function
well its just now say you wanted to do something else with the compressed item
you dont have it stored to any variable to compare it
it's just thinking about being more open to change in the future
like ur saying if i wanted super compressed?
yeah sure