CommandHelper

CommandHelper

46.5k Downloads

bind() custom parameters overwritten

LadyCailinBot opened this issue ยท 10 comments

commented

CMDHELPER-2664 - Reported by Tom.Gebbett

proc('_b_test',
@messages = array('one','two')
foreach(@messages,@i,@mes,
bind(player_interact,null,null,@e,@mes,msg(@mes))
)
)

on interact, i should see:

one
two

but i see:

two
two

I believe the way the custom parameters are saved with binds is not saving the values of the variables, just a reference to the name and location, which means that they can be forgotten if multiple binds are made from the same place.

is there any other way to pass a value into a bind that will be remembered correctly?

commented

Comment by LadyCailin

Fixed with PR 331

commented

Comment by LadyCailin

Hmm, no this looks like a bug. The custom params are "bound" at bind time, or are supposed to be anyways. For a (not so awesome) workaround, you could use import/export for the time being, if it's critical that you do this right now.

Regardless, this is still a bug that needs to be fixed.

commented

Comment by Tom.Gebbett

can't import without defining a unique identifier accessible in the bind code, and the only way to do that is to pass one as a variable.

EDIT: This is why i thought event_meta() might be helpful (see other issue report), because in this case, the information i need to access is the bind options... but it makes more sense to just be able to pass in a variable so addressing this helps more.

This bug means that all binds must be defined manually and cannot be added in a loop, IF those binds need to use values accessible in the code around where they were bound.

commented

Comment by LadyCailin

Yeah, this is the exact type of situation that I envisioned the custom params being used in, so this usage is totally recommended. As a not-so-often-used feature though, it just hasn't gotten the TLC it needs :D

commented

Comment by Tom.Gebbett

understandable, i'm glad it's being fixed :) i'll watch the builds, thanks!

commented

Comment by PseudoKnight

As a workaround, use "assign(@mes, @mes)," instead of just "@mes,". It's weird, but I find it works.

commented

Comment by Tom.Gebbett

weirdest and most wonderful fix i've seen in a long time. Thanks PseudoKnight :)

commented

Comment by MariuszT

Yes, it's working but it would be great if someone would fix it.

commented

Comment by PseudoKnight

Still broken, but my workaround still works. But now it's worse: the compiler warns against my workaround by default.

commented

Comment by EntityReborn

Confirmed still broken.