This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
H4X0RZ's profile picture

Event Remapper

Started by H4X0RZ, 09 April 2015 - 11:01 AM
H4X0RZ #1
Posted 09 April 2015 - 01:01 PM
Well, I had the idea that it would be kinda cool to add "macros" to the keys inside of CC. Now it became a small handy Utility which allows you to modify and/or disable specific events.

Pastebin: http://pastebin.com/1NDQuiPy

There is not much to say about it, so I'll just give you an example.

Usage

local mapper = dofile("remapper")
mapper.remap({"mouse_click",1,1,1},{"char","a"})
mapper.remap({"mouse_click",1,51,19},{"char","b"})
mapper.remap({"char","c"},{"char","T"})

When you run this code, every click into the upper-left edge of the screen will act like if you "clicked" the "a key".
A mouseclick into lower-right corner will emit a "b" event.
And pressing "c" will emit a "T" event.

Methods
  • remap(expected_event,remapped_event) // Remap one event to an other event.
  • removeMap(expected_event) // Remove the "mapping" for a specific event.
  • saveToFile(path) // Save the whole map to a file. if path is not defined, it will use "default.map".
  • loadFromFile(path) // Load a map from a file. Look at the above ^.
Edited on 10 April 2015 - 01:11 PM
Lupus590 #2
Posted 09 April 2015 - 04:00 PM
Nice, not sure where I would use this, but I'm sure I will have an idea that will benefit from this.
Creator #3
Posted 09 April 2015 - 04:51 PM
Nice. Is it possible to load these remaps from a file?
Lupus590 #4
Posted 09 April 2015 - 05:31 PM
Nice. Is it possible to load these remaps from a file?

If not then feature request.
Creator #5
Posted 09 April 2015 - 07:26 PM
Nice. Is it possible to load these remaps from a file?

If not then feature request.

Exaclty! #DUH
H4X0RZ #6
Posted 10 April 2015 - 03:08 PM
=======
UPDATE
=======

Now you can load/save the map to a file (if no path is given, "default.map" is used). The pastebin is still the same.

Also I'll add a list of all the methods of this utility/api in the main post.
#EDIT: Done
Edited on 10 April 2015 - 02:21 PM
Creator #7
Posted 10 April 2015 - 03:25 PM
Thanks ;)/>