LineTool [0.27+]

ITR

l̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ֍̫̜̥̭͖̱̟̟͉͙̜̰ͅl̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ
Staff member
#1
Makes it easier for mods to implement connecting two blocks.

Type "ToggleGUI" into the console to toggle the GUI, or bind a key-combination to toggle it with the system built into the modloader (ctrl+j by default)

To make a line, select one of the lines in the menu. Then right click a block, move the cursor, and right click a different block.
You can change it from right-click to something else with the system built into the modloader (ctrl+j by default)

To delete a line, do the same between two connected blocks (with the same line-type). Make sure you do it in the same order as last time, or you'll create a new line going the other way.

To stop using the line-tool, click the button on the top of the GUI.

To toggle the visibility of the lines of a certain type, click the right button of the linetype. (this will not deactivate the lines, just hide them)

For modders: [spoil]
First, create a class that inherits from LineTool.LineRequest, which will need 4 methods:



Code:
//Example Code
//All Lines will use the same instance of this class
    public class Test : LineRequest {
        //This is the constructor, the most important thing is : base(name,key,color)
        //The name is how your linerequest will appear in the list of linerequests
        //The key is what will be used for saving/loading ("TestKey" will become "Line-TestKey")
        //The color is the color of the line
        public Test()
            : base("Test","TestKey",Color.blue) {
            //Inside the constructor you can modify additional settings
            toColor = Color.grey;    //If the line can be connected between any kind of block
                                    //you can change "toColor" or "fromColor" to make the direction visible

            //You can change the material used for the line by accessing the "material" variable

            fixedUpdateFramesToWaitBeforeRegistering = 20;    //How many FixedUpdates will be waited after 
                                                    //the simulation starts before calling RegisterLink(from,to)
                                                    //0 will call it in start, 1 will call it in the first FixedUpdate
                                                    //The default is 0
                            
            uniqueFrom = true;    //If this is true, each block can only have one line of your type going from it
            uniqueTo = true;    //If this is true, same as above, only to instead of from. (also, slow)
                                //Both of these are false by default
        }

        //Register link will be called when the user first tries to connect two blocks
        //If the two types of blocks can't be connected, return false
        public override bool RegisterLink(BlockBehaviour from,BlockBehaviour to) {
            if(from.GetBlockID()!=20) {
                return false;
            }
            //Do stuff with the blocks
            return true;
        }

        //DeleteLink will be called when the link is deleted while not simulating
        //If you store any values, make sure to revert them here
        public override void DeleteLink(BlockBehaviour from,BlockBehaviour to) {
            //Do stuff with the blocks
        }

        //This will be called when the simulation starts, with the simulation version of the blocks
        public override void SimulationLink(BlockBehaviour from,BlockBehaviour to) {
            //Do stuff with the blocks
        }
    }
Then call "LineTool.LineTool.Add(new Test())" inside the start function of your SingleInstance or MonoBehaviour, or at some point after all mods have been loaded.

Try not to cause any exceptions inside any of the link functions
[/spoil]


Attached Files
LineTool.dll
 

ITR

l̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ֍̫̜̥̭͖̱̟̟͉͙̜̰ͅl̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ
Staff member
#3
Shade said:
I'm sorry I still don't get it. What did the line made with? Or what the purpose?
Any screenshot?
"You can just ignore this" for now

I haven't released anything that uses it yet :p
 

ITR

l̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ֍̫̜̥̭͖̱̟̟͉͙̜̰ͅl̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ
Staff member
#5
Important update! Now all Lines can be saved if you have the blockloader installed! Take note of it using positions to store this, so it might not work with the bounding-box!
 

ITR

l̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ֍̫̜̥̭͖̱̟̟͉͙̜̰ͅl̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ
Staff member
#6
Aww, noticed an error with the saving system, not sure what causes it though
 

ITR

l̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ֍̫̜̥̭͖̱̟̟͉͙̜̰ͅl̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ
Staff member
#7
VICTORY! Saving works now, with only one downside: you have to write "recalculate" into the console before saving, or else it doesn't save the lines (the choice was between this and making it save the lines incorrectly). If you write recalculate and don't save, write "detach" into the console, since it might cause some problems with vanilla scripts otherwise.
 
#8
Still just getting a GUI that says 'Current:None' How do I populate the list with line names? Or how do I generate them in the first instance? Also GUI is visible from get-go so the toggleGUI command isn't needed at the start.
 

ITR

l̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ֍̫̜̥̭͖̱̟̟͉͙̜̰ͅl̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ
Staff member
#9
I just assumed the GUI would be the most annoying thing for users, so I just put the method of getting it away on top.

The list is supposed to get a new entry whenever a mod registers a line for it. Meaning it should have popped up on the menu, but it seems like I managed to mess up the upload/download of the newest version of the Block-spawner mod. (y u do this forum)
 

ITR

l̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ֍̫̜̥̭͖̱̟̟͉͙̜̰ͅl̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ
Staff member
#10
Updated to 0.27! (Though no mods use this a.t.m.)
Now uses the built-in save system we didn't have before :3
 

ITR

l̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ֍̫̜̥̭͖̱̟̟͉͙̜̰ͅl̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ
Staff member
#12
No, they're made to make mods where you need to do something with two blocks easier to make :p
 
Top