MarkusBordihn / BOs-Easy-NPC

Create easily NPC for your world or for your mod.
Other
19 stars 7 forks source link

[Feature Request] Text prompt from players for custom placeholders #265

Open wulfrith opened 2 months ago

wulfrith commented 2 months ago

Hello!

I'd like to request a way for the player to enter free-text during a dialog, which can then be used in executing commands, or future dialogs. I'm thinking of saving the input as a custom placeholder that can be used in the current dialog context. No need to save the value further, it would be enough if it was available until the dialog window is closed.

Use case: I'm trying to use your NPCs to bridge the gap of a couple utility mods made by terrariumearth team that does not have a UI but instead rely on chat commands, eg. Argonauts' guild creation is done via /guild create <guild-name>.

It would be awesome if I could make an NPC who the player can talk to about guild-related stuff, with the option of guild creation. The NPC would then prompt for text which gets inserted into the part of the command, and ran as the player so they don't have to bother with chat commands.

MarkusBordihn commented 2 months ago

Thanks for the feedback! I like the idea because it would allow for additional use cases.

Technically, the value needs to be sent to the server to execute the command on the server side. Currently, it's not possible to send full commands from the client to the server to avoid any manipulation. When you click a button, only the button ID is sent to the server, which then knows which action to execute for that specific ID.

While this might sound like a simple implementation, it actually requires several components to be properly set up.

Do you have any ideas on how this "text prompt" should look?

wulfrith commented 2 months ago

Thanks for the clarification! I didn't think of security because we are just a few friends playing together and EasyNPC is mainly used by me as an admin tool, but it's legitimate to make sure you cannot inject full commands via text.

Maybe you could take the user input, and when making the placeholder variable to be reused do some sanitization so the @userparam1 cannot be interpreted as a full command in itself.

I threw together a mockup just now. prompt_mockup

I don't know how you manage layout of the dialog window but I'd imagine the textbox take up 1-2 button spaces out of the 6 available, and let the user configuring define the other buttons to leave some freedom. That is what I did here to fake the picture at least, made 4 buttons and overlaid a textbox on the top 2.