Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating gui slots #115

Open
Henriiig opened this issue Apr 12, 2022 · 1 comment
Open

Updating gui slots #115

Henriiig opened this issue Apr 12, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@Henriiig
Copy link

Henriiig commented Apr 12, 2022

Description

It would be so cool and useful if you could add the possibility to define slots that would update each tick/second/minute without the need to have a while loop running inside of Skript. An example for the syntax could be:

make gui slot 1 with diamond named "%{_cooldown}%" with update 1 second

Im pretty sure you have a better syntax but the idea is that the above gui slot will update each second until the inventory is closed by the player (or until the amount of viewers in a global gui = 0). This would make it a lot easier and give better performance when having dynamic items to show money, cooldowns and similar.

It could also be a feature to have the possiblity to choose what to do each time the item is updated:

make gui slot 1 with diamond named "%{_cooldown}%" with update 1 second:
on update:
if {_cooldown} < 1 second:
make gui slot 1 with air

@Henriiig Henriiig added the enhancement New feature or request label Apr 12, 2022
@Henriiig Henriiig changed the title Updating gui slot Updating gui slots Apr 12, 2022
@Fusezion
Copy link
Contributor

Fusezion commented Aug 19, 2022

Simply for readability and a more complete example than above

set {_cooldown} to now
create a gui with virtual hopper inventory named "Update Examples":
  run on gui close:
    # this syntax is simply to fix possible crashes caused by the system
    exit all update loops
  format next gui slot with minecart named "10 seconds" with update of 1 second:
    # similar to how we do on close/on open
    on update:
      if time since {_cooldown} >= 10 seconds:
        # adding an update gui slot effect would be a good addition to this
        # not only does it fix issues with changing name of items this adds more functionality to this system
        update the gui slot with minecart with chest of lure 1 named "&aReady!"
        
        # we could even take the "update gui slot" effect even further and create a section within it
        # and have it work as below
        # edit/update
        edit the gui slot:
          set item to minecraft with chest of lure 1 named "&aReady"
          # or
          set name to "&aReady"
          set lore to "thing1", "thing2" and "thing3"
          # while normally these don't seem best I feel like having the ability to
          # edit select portions of slots is something we should add as sometimes
          # you don't want to create a whole new item stack for a repetitive action
          # but I do agree that this can seem over bearing to some

        # as you'd exist it would exist/cancel the update system
        exit update loop
      else:
        format (the gui slot) with diamond named "%difference of 10 seconds and time since {_cooldown}%"
    # optional normal click actions to make use for "exit update loop"
    # while disabling these would be good normally and allow the removal of "on update"
    # I'd prefer keeping this and simply adding a new condition to check if there's an active update
    if gui slot has active update loop: # using gui slot would be better for having multiple updates
      stop
    broadcast "", "%player% spent the last 10 hours in this gui to click a button..." and ""

While reading this I do agree this would be a nice feature to add but
as I showed above with a more complete example it adds a lot more functionality
and would be better as a whole new stable release which could take awhile before
ever being completed fully

Syntax Examples

# Sections
on update:

edit [the] %gui slot%:
# Effects
update %slot% of %gui% with %item%
format [gui] %slot% with %item% [with update [loop of] %timespan%]
exit all update loops
exit update loop
# conditions
%gui% has [any] active update loops
%slot% has active update loop

Yes I did realize this more or less became something I could of created a issue tracker for
and yes I never expect the "edit gui slot" section to be added but atleast the "update slot" would be nice

Didn't notice issue #114 also inquired about fixing issue with updating slots so giving credit there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants