Monday, February 3, 2014

Minecraft on Linux - Minecraft Forge mods

OK, so you have Minecraft and you want to mod it.  This technique is for the Minecraft Forge mods.  This is supposed to make things easier for you and certainly it does compared to the old way which I will post later.


The idea is that rather than slamming files into Minecraft.jar you instead create a directory (folder) under your .minecraft directory called mods and stuff the zipped mod file in there.  Easy right -- that is until you realize you have a few more things to do.


1) create a mod directory under your .minecraft directory

mkdir /home/(user name)/.minecraft/mods

Remember a dot in front of a file name is Linux's way of hiding the directory.

2) Install Minecraft Forge.

You can find the link at

files.minecraftforge.net

Select (installer) and the latest version.  As of this writing, it works with Minecraft 1.74

Download the zip file

TIP:
IF you have a lot of adblockers you won't get past adfly but if you

(a) copy the link location by right clicking on the link
(b) pasting the link in a new window (don't hit enter)
(c) deletting everything until you see http:files... the first few entries of the header are for adfly

Now you are ready to install the zip file.

From the command line (terminal), move to the directory of your file...wherever you stored it.  IF it is the desktop, just do

cd /home/(user name)/Desktop  <use capital letters as you see for Desktop>

Now type

java -jar (name of your Minecraft forge file.

This will execute the java file and install minecraft forge.  Always remember to select 'client'

Now run Minecraft, and you'll see a new profile called 'forge'.  Select that profile and you should see your mod in action.

Whew...




Minecraft on Linux - Texture packs

Texture packs

Of all the things that Minecraft is known for, documentation is not one of them.  As a matter of fact, I found the documentation a bit confusing.  Part of the confusion is the fact that Minecraft has a multitude of versions with varying degrees of success. 


This documentation is written for 1.74


1) Download a texture pack.  This can be confusing as you may be stuck on a lot of ad sites.  Be careful and pick from Minecraft.org.

2) Copy whatever zip file you have...AS IS to the .minecraft/resourcepack directory.

3) Launch Minecraft

4) Select options and texture packs and pick the texture pack from a list. 

You are done.


NOTE:
If you get stuck on Addfly, you can easily bypass it by copying the link to a new browser window and deleting the first part of the URL with addfly in it up until the http:

Good luck.

Monday, April 15, 2013

VIm and plugins

KNOW - basic VIM
basic command line unederstanding.

VIM is probably one of the most misunderstood and under appreciated text editors available.  Known as the learning curve from hell, vim though is incredibly popular because it's so powerful and so customizable -- and yes HARD TO LEARN.

Today, I want to talk about plugins.  For the uninitiated, plugins for Vim are scripts that customize vim and do some pretty amazing things.  If there is something you want for Vim chances are there is a plugin for it. 

Of course, getting plugins is easy -- once you install Pathogen. Pathogen IS the plugin manager for the modern era.  SO let's start installing it.

NOTE:
~/ is a shortcut to the home directory.  If your name is Fred.

/home/fred
$HOME 
~/ 
 
all mean the same thing.
 
mkdir -p ~/.vim/autoload 
 
mkdir -p  ~/.vim/bundle 
 
curl -Sso ~/.vim/autoload/pathogen.vim https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim
 
Easy.

First, we make a new directory.

Vim uses .vim, a hidden directory (ls -al in case you don't know how to list directories that are hidden) and store them all in autoload.  That's where pathogen is going to store pathogen.
bundle is where ALL plugins are going to go from now on.

NOW...that we have pathogen installed, add pathogen to the .vimrc file.

(in case you don't know it, .vimrc is the hidden file that you can use to customize the look and feel of vim.

 "---------------------------- Load pathogen ----------------------------"
execute pathogen#infect()
syntax on
filetype plugin indent on
 
DONE!!!!!!!!!!!!!
Now let's grab some plugins.  Now I might add that the documentation I've personally found tends to say -- just use it.  Let's be nicer.
 
the git website is where all vim plugins are stored. 
 
https://github.com/vim-scripts
 
Now let's install the tagin plugin.  

https://github.com/vim-scripts/taglist.vim

(Any website that lists popular plugins will always include a link like this so don't worry.

ONCE you get to that page, feel free to be lost.  I was :)

Now look for a link that says:

git: read only
To the right of it is an address you want to grab as you'll need it.
In this example, I'm using the taglist one.
IF it's on http (e.g. 

http://github.com/vim-scripts/taglist.vim.git

this is simply a matter of changing the http to git as in:

git://github.com/vim-scripts/taglist.vim.git <- this is what you want!!!

git clone git://github.com/vim-scripts/taglist.vim.git 
 
 
Now since this is a clone you HAVE to make sure you are in a particular directory.  Specifically the bundle directory

cd ~/.vim/bundle

 

you can add a directory path if you want but keep it consistent.  I like everything under bundle myself so...
git clone git://github.com/vim-scripts/taglist.vim.git  /fred/bob

will put it there.  WHY you would WANT to is beyond me but you can.


Incidentally, if you don't have git, grab it. 
 
apt-get install git
yum install git (etc.)

Essentially what you are doing is syncing the files on the server with your local directory.  Granted you could...copy them down, make the directories, etc. but this is far easier.

DONE!
 
Have fun!
 
 

Tuesday, April 9, 2013

useradd details

KNOW: Linux command line


Adding a user to Linux, or any Linux flavor, on the surface is easy enough.

useradd <username>

So the add the user Fred, you would do:

useradd fred

Then of course you need to add a password.

passwd fred

Done...well not really.  The problem is that a home directory, or any configuration scripts are absolutely absent.  We also don't have a group to work with.  In short, you have not much of anything but a username floating in the ether.

useradd -d /home/fred -m fred

Hmmm....that's different.

-d as this defines the home directory.  Standards are the username being the name of the home directory although there is no law supporting that option for sure.

-m will actually create the home directory.  Ya...go figure.

Skeleton files
/etc/skel  is a directory you should know about.  The /etc/skel is located at...OK you know right?  Anyway the point of that directory is to provide basic configuration files so that the user has something to work with.  This means of course you can create a set of files on your own and they will be copied to the user's home directory. 

IF you want, you can use -k and specify an alternate directory for the skeleton files.  It's up to you.


Just in case, please note that passwd <username> will add the password.

On some systems you can use :

adduser >username>

this is a much more automated and up-to-date idea so try it if you have support for it.





Thursday, March 28, 2013

Disable Enter Key from Submit on Forms

Know:
Forms, Javascript, patience.

NOTHING and I mean NOTHING has frustrated me more than this annoyance.

By default, ALL forms treat <ENTER> the same as clicking a button.  This means the moment you press enter the form is submitted.  What, but what if I have a form with multiple fields and every one needs to be entered BEFORE submission.
Sure, you could disable the enter key but wow, that's fun for the user.  Pressing tab and not enter gets old REAL FAST.  So...what do I do.

Step 1:
Disable the form.

This is pretty easy and requires NO coding.

<Form id='myform' name='myform action='dosomething.php' >

Nothing special but we need to stop submit.  We will add ONE line.

onsubmit='return false'

Now...

<form id='myform' name='myform' action='dosomething.php' onsubmit='return false'>

This essentially is taking advantage of Javascript.  If you want to hook up an event to onsubmit you can do that.  Returning false will keep you in the form.  This is great for validating text, etc.  For now though, we're just going to return false.  OH NO.  Now I will NEVER have the form submit right?

WRONG!!!!

This is the key.
Create a button that will submit the form.  We're going to add a PAINLESS function in Javascript to submit the form.  Really, it's quick.

First the function.  You can either add it to the top of your html, OR, add it to your javascript library.  For this example, we'll just add it to a script.

<script>
function SubmitForm ('IdOfForm')  // that's the ID of the form.  Handy for submitting
{
    var SelectedForm = document.getElementById (IDOfForm);
     SelectedForm.submit ();

}

</script>

OK so now you have the script.  BUT WAIT???? Where do I put it?  Well an easy solution is with a button.

<!-- this is all one line but is wrapping on this blogspot --!>
<input type='button' class='your class (optional) value='Save' onsubmit='SubmitForm(this.id); return false;"></input>

The return false is VERY important.  Take it out and you'll have the return key submitting your form.  Try it.  Works great for me and have fun.

Too many quotes

KNOW:
php, Javascript

Ever came across this problem?

echo ('<input id='fred' ...etc)

The problem is that we have an embedded quote but you say -- no problem right?

echo ("<input id='fred' ...etc)

So far so good.  Here we have the id of the tag set to 'fred'.  We use single quotes for fred and double quotes for input...but!


echo ("<input id='fred' onclick='DoSomething ('Bob');'...mess!

The problem is that you only have two normal layers of quotes.  The single can be embedded in the double but the double...we don't have a triple.  What we do have is the escape.

The escape lets us embed as many quotes as we want with the use of the \ character.

\" means to tell the processor that we want a double quote as it.  So when PHP processes the code we will see a double quote.  This won't work for single quotes by the way.  Don't do \' and expect good things to happen.

Now...

echo (\"<input id=\"fred\" onclick=\"DoSomething (\"Bob\")\" >\" );

I agree, this takes a bit of getting used to but the advantage is that you don't have to deal with running out of characters for quotes.  It works this way.

The first quote is always \"
The second quote is always \"
The third quote is always \"

You can do as many as you want without pulling hairs.  Messy -- ya...but it works.

Javascript and the this statement

What to know:
PHP, basic Javascript.


Often times in php, I'm generating lists of objects -- specifically html objects -- and I will include a Javascript link to process the information.  That, in itself, is not my favorite option but php is server and Javascript is client (Browser).  This relationship can be a headache but here are some tips to aid the pain.

First things first.  Javascript does provide a painless way to extract information from any object -- this.  The 'this' object gives you all the tools you need to gather anything you want about an object and pass it along to a procedure. 

Example
<input id='fred' value='bob' onclick='DoSomething (this) >this is nice</input>

This is your gateway to freedom.  The 'this'.  Don't believe me?

In your function

function DoSomething (Value)
{


}


You can extract:
The ID of the object, the value of the object and the text past the object

Now, let's see how

function DoSomething (Value)
{

   alert (Value.id);   // get the ID of the object or in this case 'fred'
   alert (Value.value) // get the value of the object or in this case 'bob'
   alert (Value.innerHTML) // get the text or in this case 'this is nice'
}

Now if you're worried about extracting information about an object, you need worry no more.

I'm no expert on Javascript and try to avoid it when I can but I can't deny its usefulness.