[MOD]lib_tool_schematics[git]

Post Reply
ShadMOrdre
Member
Posts: 1118
Joined: Mon Dec 29, 2014 08:07
Location: USA

[MOD]lib_tool_schematics[git]

by ShadMOrdre » Post

A simple, hand held tool, for importing or converting schematics, (.mts files).

This tool will activate default chests, furnaces, bookshelves, cottages barrel, handmill, threshing floor, 3D armor stand, itemframes, and earthbuild baskets, bottlegourds and storage pots. Chests and bookshelves also get filled with random treasure.

This tool uses a state based approach, so right and left clicks, (ie, punching/digging and placing), have behaviors defined based on the state of the tool. All actions are shown in chat.

The states are in order, Select Action, Select Path, Select Type, Select File, Select Rotation, Select Offset, Select Conversion Type, Select Placement, Action.

Select Action chooses between Place Schematic and Convert Schematic.
Select Path allows you to choose between the mod/schems folder and the world/schems folder.
Select Type chooses between .mts and .lua schematic types.
Select File allows you to choose the file from a list of files in the above selected path.
Select Rotation chooses between 0, 90, 180, and 270, the 4 cardinal directions.
Select Offset chooses the offset of the schem, both positive and negative, for raising or lowering a schematic.
Select Conversion Type chooses between Lua to Mts, and Mts to Lua.
Select Placement chooses between a centered placement and the default placement of southwest corner.
Action commits the configured action. Place the schematic or convert the schematic.

Use Left click, 'Punch', to change the state and right-click 'Place' to perform the configured action.

Screenshots aren't really useful, but can be provided showing the inworld chat feedback

In world, the itemstring to get this tool is "lib_tool_schematics:schematics_tool". There is no craft recipe, as this is considered a developers tool.

LICENSE: LGPL v2.1

DOWNLOAD:
lib_tool_schematics

I use this tool extensively to work with tree and plant models for gal, as well as, building schematics for my lib_towns mod. I find it simple and rather efficient for bulk converting .mts files to lua tables and vice versa, as well as for bulk schematic placement.

Please let me know what you think.



Shad
Last edited by ShadMOrdre on Fri Nov 25, 2022 19:22, edited 1 time in total.

ShadMOrdre
Member
Posts: 1118
Joined: Mon Dec 29, 2014 08:07
Location: USA

Re: [MOD]lib_tool_schematics[git]

by ShadMOrdre » Post

I have updated this useful, simple tool.

This is a state based tool. Punch to change between states, place to set option or commit configured action. Feedback is provided through chat, with configured option shown in chat.

Capabilities include placing schematics and converting schematics between .mts and .lua, and .lua to .mts. Conversion does not require importing the schematic first.

Additional functionality includes setting rotation, offset, and placement, centered or from southwest corner.

Impressive new feature is that chests, furnaces, bookshelves, itemframes and pedastals, 3D armor stands, cottages barrel, handmill, shelf and threshing floor nodes, earthbuild baskets, gourd pots and storage pots are usable on import. Chests, and the like, and bookshelves also include treasure.

TODO: Vessels shelf, itemshelves, fluid tanks.

LICENSE: LGPL v2.1

DOWNLOAD: [urlhttps://github.com/ShadMOrdre/lib_tool_schematics]github[/url]

ShadMOrdre
Member
Posts: 1118
Joined: Mon Dec 29, 2014 08:07
Location: USA

Re: [MOD]lib_tool_schematics[git]

by ShadMOrdre » Post

Thought I would provide a quick explanation of how to use this.


The tool is state based. To change the state, hold the tool and punch into the air. To select between the options of a given state, right click the tool while looking at a node.

The states are in order, Select Action, Select Path, Select Type, Select File, Select Rotation, Select Offset, Select Conversion Type, Select Placement, Action.

Select Action chooses between Place Schematic and Convert Schematic.

Select Path allows you to choose between the mod/schems folder and the world/schems folder.

Select Type chooses between .mts and .lua schematic types.

Select File allows you to choose the file from a list of files in the above selected path.

Select Rotation chooses between 0, 90, 180, and 270, the 4 cardinal directions.

Select Offset chooses the offset of the schem, both positive and negative, for raising or lowering a schematic.

Select Conversion Type chooses between Lua to Mts, and Mts to Lua.

Select Placement chooses between a centered placement and the default placement of southwest corner.

Action commits the configured action. Place the schematic or convert the schematic.

Once a state has been configured, it is not reset, so that configuration choice will remain until changed. This allows quick and easy bulk operation.

Example:
While holding the tool, punch in the air. On each punch, look at chat to see what state you are in, (ie. what setting you would change if you right clicked during that state.) Punch into the air until you see Select Action. While this is the first state, and is automatically chosen, I want you to see the various states and settings.

Once you've punched through the states and are back at the Select Action state, right click on the ground to see the two options listed, Place schematic or Convert Schematic. You can safely right click through all the options within each state.

The tool only does any work in the Action state, and based on the options you've chosen in the other states.

To convert a file, choose the Convert Schem option while in the Select Action state. Change the state to Select Path, and choose the world/path. NOTE: (You cannot write to the mod folder, only to the world folder. Converting schems requires you to choose the world/schems path, so that converted files can be written.

After selecting the path, punch in the air again to change the state to Select Type. If you are placing an .mts schem or converting an .mts file to lua, choose mts.

Punch with the tool again to change the state to Select file. A list of all files in the folder path selected in the previous state is generated at this time. Right click the ground to cycle through the file list.

Once you've selected a file, punch with the tool to change the state to Convert Type. Rotation and offset are ignored for conversion, only used when placing schematics. Right click to change the conversion type between mts2lua and lua2mts.

Punch again until you select the Action state, at which time if you right click on the ground, the conversion will take place, and a new file will be created in the world/schems folder. It should be noted that the new file that is created is not really accessible for placement or conversion, since MT reads the folder contents only once at runtime, and while the file exists, and you can see it with this tool, MT itself still only sees the files that existed at the time MT started.

Mts files created with this tool are usable. However, you must restart MT, so that it sees the new file.

Lua files created with this tool will need to be edited to simply put

Code: Select all

return 
at the beginning of the file, before the lua table.


State based tools can be confusing at first, but once gotten used to, you'll begin to wonder how many other tools would just be better with "states".

User avatar
Neuromancer
Member
Posts: 958
Joined: Tue Jun 12, 2012 22:28
GitHub: Neuromancer56

Re: [MOD]lib_tool_schematics[git]

by Neuromancer » Post

This tool would be incredibly useful but it's confusing to use. I always get close but right or left click at the wrong time. Could you please add the following option: Just type

Code: Select all

/lua2mts schemaname 
to convert a file called schemaname.lua to schemaname.mts.

Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests