Sorry, we don't support your browser.  Install a modern browser

Custom scripted Tools#801

It could be REALLY powerful to allow Custom Tools to be made with Lua scripting.
These tools would show up as their own category of tool right below the snap point tools, and each individual tool would be listed horizontally when moused over

The way I see this working is that in onLoad() you’d call a function called createTool(name, description, imageURL, allowAlt).

  • name and description would work the same as for objects but for when the tool is hovered in the tools UI in the top left of the screen.
  • imageURL is the URL to a hosted image used as the icon for the tool in the UI
    (the top-left corner of the image would always be the actual “point” of the tool so it can be used precisely).
  • allowAlt would be a bool that determines if right-clicking when the tool is being used would show the contextual menu or use some functionality of the tool instead (thus preventing the context menu from being displayed).

When using any custom tool, the event onCustomTool(toolName, player, altClick, clickObjects, releaseObject, hoverObject) would be called (on Global and all objects).

  • toolName would be the name of the tool used so we could distinguish which Custom Tool’s being used.
  • player is the color of the player using it.
  • altClick is a bool for if the right-click was pressed when the event is called. Would be false if the function’s allowAlt was set to false and the context menu is displayed.
  • clickObjects would be a table of objects selected or clicked on when the event is called
  • releaseObject would be a table of objects under the tool’s pointer when the left (or right) click is released
  • hoverObject would be the object currently being hovered by the tool (even if locked)

I can think of many, many powerful uses these tools could allow. For example, a tool that let you click on an object, and then clicking somewhere else, making it move to from where it was to where the 2nd click is but having special movement rules dictated by scripting. Another example would be clicking an object, holding down the left mouse button, dragging the cursor to another object and a tooltip telling you what is going to happen if you release the cursor at that spot (something like “you will lose 1 worker, 2 stone and gain 5 poitns”).

The reason I mentioned earlier that the event wold be called on all objects is so that we could make tool scripts attached to objects so they’re easily importable in another mod or the current game session. Then you could even make tools that call a sound effect when clicked or released (it’s possible if only called on Global but could sound effects have to be tied to objects so having the script tied tool’s scripting tied to the )

If you also added my “ #799 Tool-selection through Scripting” suggestion, we could even make this chain custom tools, which could get even more powerful

I really hope this one gets made, it would be really really powerful in the right scenarios

3 years ago

I would love this as well, it’s simply extremely powerful when combined with scripting.
For example, many games have “select this action and then select opposing piece to do something”, like for example a unit, select shoot then choose objetive. That is more or less possible now with the new player API but it’s very awkward because the player doesn’t know how to select nor the cursor changes or anything. With a custom scriptable tool that would be perfect.

3 years ago
1