This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
Can You Download An API From Pastebin?
Started by ByteZz, 11 March 2014 - 10:15 PMPosted 11 March 2014 - 11:15 PM
Hi folks. I have a small question where from my searches, I am not getting a clear answer to. I would like to ask if it is possible to get APIs and load them via pastebin. I play an SMP server where I doubt the owner would load APIs to the rom/apis folder so I am asking if I can download an API via pastebin and then load it by doing os.loadAPI("path"). I am new to APIs and I want to use a button API for touchscreens so please let me know. Thanks!
Posted 11 March 2014 - 11:20 PM
When it comes to stuff like this, you should go ahead and try it yourself really.
Yes, anything you can download from pastebin acts like any other code and can be loaded as an API using os.loadAPI(). The only difference between doing it from your program, or putting one in the API folder is that the one in the folder gets loaded automatically on startup. Essentially, you could make your computer load it automatically with the startup file, the effect would be the same.
Yes, anything you can download from pastebin acts like any other code and can be loaded as an API using os.loadAPI(). The only difference between doing it from your program, or putting one in the API folder is that the one in the folder gets loaded automatically on startup. Essentially, you could make your computer load it automatically with the startup file, the effect would be the same.
Edited on 11 March 2014 - 10:21 PM
Posted 11 March 2014 - 11:51 PM
When it comes to stuff like this, you should go ahead and try it yourself really.
Yes, anything you can download from pastebin acts like any other code and can be loaded as an API using os.loadAPI(). The only difference between doing it from your program, or putting one in the API folder is that the one in the folder gets loaded automatically on startup. Essentially, you could make your computer load it automatically with the startup file, the effect would be the same.
You sir, are a hero. I wasn't able to try as the curiosity came afterwards when I didn't have access to a MC computer. Thank you.
Posted 12 March 2014 - 02:50 AM
Just to throw it out there, if you're looking for a button API, the DW20 isn't all that great, and is difficult to move past the bare basics with. There are several other APIs on the forums. Many of them have more capabilities, or are more flexible in their usage. One I would personally suggest for someone familiar with the DW20 button API, or even just looking for a simple but powerful touchscreen button API, would be my Touchpoint API. The usage is somewhat similar to the DW20 button API, but it is designed as a proper API, allowing a programmer more options and better control of their buttons.
Posted 12 March 2014 - 07:16 AM
While it may not be the best thing when starting out, the best way really is to make your own set of button/click utilities. In all my programs nowadays I've a blank template with a few controls such as buttons, alert windows, etc. and I delete what I don't need. This also removes the need to include other files which can make things harder for the user.
Posted 12 March 2014 - 11:38 AM
I'm sorry if I am slightly derailing the topic now but could you point me in the right direction for buttons (touchscreen). I discovered touch point as well before I saw this thread and am going to try to learn it as the demo was quite promising.
I don't quite understand the API but I will try.
I don't quite understand the API but I will try.
Posted 13 March 2014 - 12:03 AM
The best thing to do to make buttons is with no api. I mean, seriously, it is actually harder with apis…
ev, button, x, y = os.pullEvent("mouse_click")
if x > 1 and x < 7 and y > 3 and y < 5 then
--Code here
Versus
function func()
--Code here
end
[size=4]local button = {"Test button"}[/size]
newButton(button, "button1", 1, 3, 5, 7)
onButtonPressed("button", func)
Posted 13 March 2014 - 12:18 AM
The best thing to do to make buttons is with no api. I mean, seriously, it is actually harder with apis…Versusev, button, x, y = os.pullEvent("mouse_click") if x > 1 and x < 7 and y > 3 and y < 5 then --Code here
function func() --Code here end [size=4]local button = {"Test button"}[/size] newButton(button, "button1", 1, 3, 5, 7) onButtonPressed("button", func)
Your code lacks the ability to expand in a coherent manner. Sure, it's fine if you've got like two buttons and they don't ever disappear, but what happens when you've got fifty buttons that do different things based upon settings and that only show themselves at certain points in time? Yeah, it's possible but you'll end up writing thousands of lines of spaghetti code.
Posted 13 March 2014 - 07:03 AM
The best thing to do to make buttons is with no api. I mean, seriously, it is actually harder with apis…Versusev, button, x, y = os.pullEvent("mouse_click") if x > 1 and x < 7 and y > 3 and y < 5 then --Code here
function func() --Code here end [size=4]local button = {"Test button"}[/size] newButton(button, "button1", 1, 3, 5, 7) onButtonPressed("button", func)
Your code lacks the ability to expand in a coherent manner. Sure, it's fine if you've got like two buttons and they don't ever disappear, but what happens when you've got fifty buttons that do different things based upon settings and that only show themselves at certain points in time? Yeah, it's possible but you'll end up writing thousands of lines of spaghetti code.
Couldn't agree more. You should try to make your code a modular as possible. Hard coding values like that is a bad idea.
Posted 13 March 2014 - 12:35 PM
Thank you folks. I sorted my minor doubt on touchpoint and I'll be on my way now for expanding my redstone outputter! Thank you all. This community is excellent.