I am making a /changelog command and I am trying to make a remove system, by running the command /changelog remove 2 it should remove the 2nd row of the changelog and move the rows beneath it up one step. Although, the last row doesn't seem to correctly change position.
if i would have the changelog:
Changelog:
- change1
- change2
- change3
- change4
and do /changelog remove 2,
it should be:
Changelog
- change1
- change3
- change4
but instead, it becomes:
Changelog
- change1
- change3
- <none>
- change4
if i would have the changelog:
Changelog:
- change1
- change2
- change3
- change4
and do /changelog remove 2,
it should be:
Changelog
- change1
- change3
- change4
but instead, it becomes:
Changelog
- change1
- change3
- <none>
- change4
Code:
command /changelog [<string>] [<string>] [<string>]:
executable by: players and console
trigger:
# other code
else if arg 1 is "remove" or "delete" or "del":
if player has permission "op":
set {_changeIndex} to arg 2 parsed as integer
set {_index} to size of {changelog::*}
delete {changelog::%{_changeIndex}%}
send "&aSuccessfully removed &echange %arg 2%" to event-player
set {_changelogSize} to size of {changelog::*}
set {_loopCount} to 0
loop {_changelogSize} - {_changeIndex} + 1 times:
set {changelog::%{_changeIndex} + {_loopCount}%} to {changelog::%{_changeIndex} + {_loopCount} + 1%}
add 1 to {_loopCount}
send {_changelogSize} to event-player
send {changelog::%{_changelogSize}%} to event-player
delete {changelog::%{_changelogSize}%}