Railcraft

Railcraft

34M Downloads

Allow routing tables to match unnamed minecarts

OverloadUT opened this issue ยท 10 comments

commented

It appears to currently be impossible for a routing table to positively match on an unnamed minecart. Locomotives can match Dest=null, but the following things I tried failed to match unnamed minecarts:

Name=null
Name=Minecart

Seems to me that Name=Minecart would be the most intuitive.

commented

It seems that the exact function being used to get the entity Name returns a null object if there is no custom name.

I can add a special case for that. Additionally, I'll add a "Type=" conditional, if I can figure out what string to use for type specification....maybe the fully qualified item name. I assume NEI shows those.

commented

That would be excellent. NEI doesn't show the fully qualified name by default, but something I've got installed turns that on when pressing F3-H, which is good enough for me!

commented

Oh, and as long as you're opening up that part of the code: another conditional that would be nice is "Rider=" if it's easy enough to do.

commented

So...I could make "Rider=" scan the entire train and see if a player by the specified username is present. Is that what you mean?

Maybe "Rider=" and "Ridden=true/false".

The hardest part about adding new conditionals is actually updating the Routing Table Manual strings. ;)

commented

That implementation makes sense. Then you could include some AND NOT logic for some unusual but interesting routing. I'm only running single minecarts in my setup so I had forgotten about multiple riders in a train, but yes the end result is exactly what I was looking for. With that I plan to have the train route have different behavior when the owner of the home arrives. Or just for silly trolling, of course.

commented

AND as long as I'm just throwing out suggestions, another thing I wish I had: wildcards, or at least partial matches on "Name=". It looks like desinations take partial matches, but if you're only doing it based on cart names, you've got to name every pair in every routing table. I'd love if it was simply a substring match anywhere in the name string

commented

Uh....show me code that doesn't turn into a 200 line, multi-pass text parser and maybe...

commented

I suppose I could do something like "Name=Regex:mineTrain.*"

Syntax could probably be improved though.

commented

Another possibility for the syntax could be something like
Name~=mineTrain

That way you're not introducing another sort of prefix but rather just changing the operator

commented

Hmm...that is cleaner, but would probably require more rewriting. Also I'm not sure which would be easier to explain in the manual.

Either way, the following string would just be passed to the String.matches(regex) function.