Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal

Gangsir

Members
  • Content Count

    71
  • Joined

  • Last visited

  • Days Won

    8

Posts posted by Gangsir

  1. Door yes, chest no. The 3D printer is capable of printing basic blocks and shapes, and it's possible to have the block change shape when right clicked, so the door would be possible, but the chest wouldn't work, since prints can't have an inventory.

  2. Simple. Just require the library as usual, ex

    local lib = require("myLib")
    

    Then, use os.execute to run another program, and pass the library variable,(lib), to the executing script, like so:

    local lib = require("myLib")
    
    os.execute("otherprogram.lua lib")
    

    Of course, you will need to receive and reassign the variable in the executed program. Plus, this only works on the same computer, (ie, both programs on same computer), and the first program will suspend until the program inside os.execute yields.

     

     

    As a side note, why do this? Why not just put require in each of the programs?

  3. That is true. Kinda is a share though, although I wonder if it would be possible to create something like linux from source code.

     

    I believe that plan9k (The alternative OS built into OC) is meant to be similar to a Unix-like system. That's really the closest thing to linux that OC has.

     

    Of course, re-making linux into a MC mod would require the conversion of C/assembly (The programming language most of the linux kernel is written in) into java so it can execute natively. (Or make ingame computers understand those languages, but then you're running an OS inside of an OS inside of a game inside of an OS. Yo Dawg) Plus you'd likely only be able to include a terminal anyway, as any sort of desktop environment (Even something known to be light like XFCE) would be a bit too much for minecraft to run effectively. That's still a lot of code to convert, plus in the end you'd end up with another computer mod, this time java/C/assembly based. I feel like Lua or perhaps Python is still the best language for a mod like this to use.

     

    Anyway, that's my $0.02.

     

    Source: Linux hobbyist

  4. I dont think it's actually possible to do this in minecraft, as it would require a full blown virtualisation client built into minecraft. Even if it was something light like linux it would still lag.

  5. Hi,

    I want to start coding some programs in OC but i'm facing questions i would like to solve before really writing.

    1) IDE

    I usually write in NotePad++ for simple Lua programs, but i'm thinking, there must be a better way to do it for code completion, etc.

    I already checked this wiki but i want to see your personal opinions and reasons.

     

     

    I myself use Atom, a text editor for linux. It also has ports for other operating systems. It has code completion, auto indent, and can interface with VCS like github. You will need to install a plugin for it to handle lua, however.

     

     

    2) Project Management

    I chose to use Git/GitHub for source management and i wish to have one repo for each libraries, programs, etc.

    In this way, i could easily have independent releases, and this will force me to thinking in modular and reusable manner.

    But this will also greatly increase the amount of repo and will messed up my github account with a bunch of relative projects (OC lua) side by side with potentials other projects.

    ...

     

    The way I do it, and I recommend it be done, is to just keep one repository for all OC programs, then subdivide it into folders if a project has more that one file. Making individual repos for each program is inefficient unless the project is huge with many files.

     

     

     

    3) OC libraries

    To have access in libraries, we use 'require', ok.

    But how it works? Is there a specific directory on the in-game computer for libraries storage?

    And if not how OC knows where to search?

     

    The way require works is that it looks at your system path on the computer for places to look for files. For libraries, this will be /lib or /usr/lib. It looks for programs in /bin or /usr/bin or just /, etc.

     

     

    If you need to have different versions of libraries, they must simply be named differently, then in the program, referenced correctly.

  6.  

    I hate to say it, but I am having some trouble making this work this is the error I'm getting:

    boot/04_component.lua:69: no primary 'modem' available
    stack traceback:
            [C]: in function 'assert'
            boot/04_component.lua:69: in function <boot/04_component.lua:67>
            (...tail calls ...)
            /usr/bin/gft.lua:14: in main chunk
            (... tail calls ...)
    

     

    Do you have a wireless or wired network card installed in both computers? Ensure you do.

  7. !ereh Risgang I've written a simple program for transferring a medium sized text file (Less than about 8000 characters, roughly a small essay) over an OC network, wired or wirelessly. I've named it GFT, or "Gift", short for Gangsir File Transfer.

     

    This program is actually two small sub-programs, one for receiving and one for sending. To differentiate between them, the first argument changes the function of the program. Then, the second argument tells the file to operate on, for sending or receiving to. (To generate on receive.)

     

    Syntax is as follows:

    gft <send/receive> <"/path/to/file.txt">
    

    This program copies the file being sent, so don't worry about losing the original copy. And yes, this program is small enough to send itself. (Don't know why you would, since you need this program on the receiving end anyway.) I wouldn't recommend using gft to send the file that gft is running off of, since I have not tested what happens.

     

    Uses port 20 by default, the default port for FTP in real life.

     

    Requirements for program:

     

    -Tier 1 everything

    -Network card

    -Connection between sender and receiver, if wired

     

     

     

    How to get the program:

     

    The program can be found at my github like always:

     

    https://github.com/NoahNMorton/Gangsir_MC_LuaPrograms/blob/master/OpenComputers/GangsirsSimpleFileTransfer.lua

     

    Or can be wgetted with an internet card:

    wget https://raw.githubusercontent.com/NoahNMorton/Gangsir_MC_LuaPrograms/master/OpenComputers/GangsirsSimpleFileTransfer.lua gft.lua
    

    Thanks for reading, and as always, let me know if you have any feedback.

  8. ok, I know that.

     

    But 

     

    1 - one can't properly develop a robot program in another opencomputer because the apis aren't available and there is no way to test the program.

    2 - why develop outside of the game if I’m there to play the game?

     

     

    1. Much of the info of apis is found on the wiki, plus after a while of doing it you'll likely find that you'll start to memorise what functions are available and their uses. As for testing, I realise that different people have different coding skills, and need to test more often, which after a while with lua I find myself doing less and less. However, it is much more efficient to use the wiki to write up a full rough draft of the program then just fix problems on the robot with the draft. Trust me, you'll find you can write stuff much faster and understand it better if you develop outside of the game in a text editor, which has a much higher resolution and makes it much easier to edit and see mistakes. Additionally, there are features to using a good text editor, such as code completion so it's not needed to type each individual thing out, automatic indentation, etc. The bulk majority of my programs were written outside of game, then bugfixed. I personally recommend notepad++ for windows. As a Linux user, I would recommend Atom, gedit or vim/emacs. If you don't know the whole scope of your project all at once, then just write individual small tests, then piece them together.

     

     

    2. Different people use OC for different reasons, and some people find development as fun as playing a game. I personally use OC as more of a tool for ingame automation than a toy, if you understand what I'm saying. Of course, if you don't want to break immersion, then that's fine, you do what you want. If you use OC a lot, I’ll still recommend developing outside of game, then copy+pasting your code in.

  9. The way it's meant to work is that one would dev the program on a proper computer with a good screen, or out of game, then transfer the program to the robot. The reason robots don't have fancy screens is that there's no need for them, since robot's guis aren't often entered.

  10. If you need a robot to be able to float in the air, you need to install a hover upgrade in the robot, tier 1 or 2 depending on depth of the hole. I believe that the existing dig program provided on the loot floppy will resume where it left off if shut down, as long as it is started next to the chest.

  11. Initially, when I first came across lua, it was with ComputerCraft, with direwolf20, a youtuber. I thought the mod was extremely cool, and looked into tutorials online, and direwolf20's tutorials. This increased my interest, and I learned how lua worked. I had a huge amount of practice with Java beforehand, so I already knew the programming mindset. This helped me to pick up lua within a week, just looking at tutorials and the official site of lua's documentation. After a while with CC, I found OC, realised that it was a much better, useful and balanced mod, picked up OC's version of lua, which is different from CC's. I've been churning out user-friendly mass-appeal programs onto these forums since, which I feel it lacks.

     

    To practice it, I'd just recommend looking at your minecraft playthroughs, pick something you'd like to automate/make easier with computers, and throw yourself at making a program. Look up required libraries you might need, methods the block(s) in question has, etc. I've written a few that you might want to look at for inspiration, they can be found in the program showcase part of the forums. Or, someone else's. The great part about communities is that inspiration abounds.

     

    A really great place to start is reading most of OC's wiki, it helps a lot with learning the mod.

     

    Some links:

     

    Official lua site:

    http://lua.org

     

    Direwolf's computercraft tutorials: (Keep in mind, CC's lua version is different from OC's, so if you're trying to learn for OC, look up Lua 5.2 tutorials)

    https://www.youtube.com/playlist?list=PLaiPn4ewcbkHYflo2jl0OuNaHK6Mj-koG

     

    OC's Wiki:

    http://ocdoc.cil.li/

  12. AND HIS NAME IS... GANG SINA! Gangsir here again, I've made a simple script that opens a door when a entity from a list moves near an attached motion detector. This acts as both a method of security and an easy way to automatically open a door. It outputs a redstone signal on the top of the computer/RedstoneIO block when a valid entity moves near it.

    Usage:

    proxdoor [-abli] <time to stay open> [Person1] [Person2]...
    Switches:
    -a : Accept all mode, door will open for any motion. Whitelist has no effect. Cannot use with -b
    -b : Blacklist mode, all provided names the door will ignore, accept all others, cannot be used with -a
    -i : Inverted redstone mode, turns redstone on by default and off on detect. Good for piston doors.
    -l : Logs all door activity to a file. Useful for security
    

    So, if I wanted the door to stay open for 2 seconds, and allow both me and Sangar to open the door, I would run:

    proxdoor 2 Gangsir Sangar

    You can have an almost infinite whitelist, limited by your RAM. If you have a very large whitelist, it may be more efficient to run the program in accept all mode or blacklist mode, see above. When setting up, ensure that there is a motion detector on both sides of the door, or it can be seen from both sides. Also ensure it has line of sight, and is within 3 blocks from the door, so that it can trigger. This range can be modified in the program.

     

    Screenshots:


    ProximityDoorPic.png

    The Log file format, if switch -l is used:

    Proxdoor%20Logfile.png



    Requirements:


    +Tier 1 everything
    +Redstone card if using computer as output, redstone io block if not
    +Motion detector
    -Screen only initially, can keep if you want logs on blacklist mode printed to screen, or want to interact with the computer still




    The program can be found here:

    https://github.com/NoahNMorton/Gangsir_MC_LuaPrograms/blob/master/OpenComputers/HeadlessPrograms/ProximityDoor.lua


    Or, Wgetted:

    wget https://raw.githubusercontent.com/NoahNMorton/Gangsir_MC_LuaPrograms/master/OpenComputers/HeadlessPrograms/ProximityDoor.lua proxdoor.lua 

    As a quick p.s., the program is headless, meaning you can remove all graphics components and it will still function fine. Also recommended if using for security that you protect the blocks around the door, the door itself, and the motion detector to prevent people just busting down the door. I recommend the block protector from RFTools, or Thaumcraft warding.

    As always, make sure to like or comment if you enjoy my programs, I'm always happy to see that.

     

    Changelog for those who care:

     

    V1.0 Added the program.

    ---

    V1.1 Added accept all mode and inverted mode, made whitelist lookup faster. Numerous optimisations.

    ---

    V1.2 Added blacklist mode

    ---

    V1.3 Added file logging on option

    ---

  13. Keyboards themselves do not have a gui, they just allow you to open screens as a gui. They're useless without a screen near them. Also, they do act as components, this can be seen by running the components program that comes with OpenOS.

     

    Hologram projectors only allow edits via their component, which can only be used in a program. Unless I’m missing something, there's no way to input directly into HPs.

     

    Happy to help.

  14. Hey, hope you're having a wonderful day. Gangsir again, back with another one of my small but useful programs. I've written a small user-friendly program to manage modem ports. It has the ability to scan and list all open ports, then gives you the option of opening and closing some ports. A few arguments and switches can be specified, these control what the program does.

    Syntax:
    
    ports [-ns] <minSearch> <maxSearch>
    -n : No scan, skips scanning and goes right to opening and closing.
    -s : Silent mode, only scans, no questions asked.
    <minSearch> : The lower port to search from. Program will search from min to max for open ports.
    <maxSearch> : Upper component to above.
    
    Using both -n and -s is pointless, as it will open, and close immediately, with nothing to do.
    

    This program can be used for debugging, testing, security, etc. I tried to make it somewhat like the components program that comes with OpenOS. If arguments are not specified, it searches from the minimum valid port to the upper valid port, 1-65535. This can take a few seconds, so I’d advise limiting it if you know where the general area of your open ports are.
     
    Anyway, the program can be found at my Github, or wgetted:
     
    https://github.com/NoahNMorton/Gangsir_MC_LuaPrograms/blob/master/OpenComputers/ModemPortManager.lua

    wget https://raw.githubusercontent.com/NoahNMorton/Gangsir_MC_LuaPrograms/master/OpenComputers/ModemPortManager.lua ports.lua
    

    As always, if you enjoy my programs, be sure to let me know! Your feedback inspires me!
     
    -Good night/morning/day, Gangsir

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.