How to Add A New Option

For this tutorial, I’ll be adding the option, WASD movement.

Here’s how to add an option for all those people who want options for certian things. This can only be used if you need an option for, let’s say, transparent trees (like mine), in the code where the transparent trees make the trees transparent, I added


If Options.STT = 1 Then

MAKE TREE TRANSPARENT

Else

MAKE TREE NORMAL

End If

So, this will require some thinking after the option is made. So with that, let’s being.

–----------------------------------------------------------------------------------------------------------------------------------

First, you want to go into frmMain, and bring the options to the front. (An easy trick is to right click on the front of the place where the options should be, and keep clicking go to back until the options are in the front. This is a simple yet useful trick when editing the pictureboxes.)

Next, copy the label for music, and when it asks you to create a control array, select no.

Create two _OptionButton_s. Name one WASDon and one WASDoff (or what your option is going to be named).

Double click on the ON option button. Add this.


Options.WASD = 1

    ' save to config.ini

    SaveOptions

Double click on the OFF option button. Add this.


Options.WASD = 0

    ' save to config.ini

    SaveOptions

–-------------------------------------------------------------------------------

Next, in modDatabase search for:


Call PutVar(filename, "Options", "Sound", str(Options.sound))

At the bottom of that list, add:


Call PutVar(filename, "Options", "WASD", str(Options.WASD))

Still in modDatabase, search for:


Options.Music = 1

Add before SaveOptions:


Options.STT = (1 if you want the default to be on, and 0 if you want the default button to be off.)

Now, search for:


Options.Music = GetVar(filename, "Options", "Music")

Before that End If, add:


Options.STT = GetVar(filename, "Options", "WASD")

Now, search for:


    If Options.sound = 0 Then

	    frmMain.optSOff.value = True

    Else

	    frmMain.optSOn.value = True

    End If

Under that, add:


    If Options.WASD = 0 Then

    frmMain.WASDoff.value = True

    Else

    frmMain.WASDon.value = True

    End If

That should be it! Now you just have to call on the code where you need an Option!

Option.WASD = 0 - Off

Option.WASD = 1 - On

So call on it like.


If Option.WASD = 1 Then

BLABLA CODE

Else (This means that it is seeing if it's not on, so it must be off.)

(You may want code that does something else when it's off, but most of the time you just want it to End, or End If. Do nothing.)

End if

Nice tutorial. Rather than using a option button why not use a checkbox?

Checkboxses are resetting i think or it was on my version >.>

I like Options more too beause it just looks better and you get an file where you can see everything whats on and what not 🙂

Nice Tutorial its already there but its hard to find 😉

(Abhi nice signature lol)

Checkboxses are resetting i think or it was on my version >.>

I like Options more too beause it just looks better and you get an file where you can see everything whats on and what not 🙂

Nice Tutorial its already there but its hard to find 😉

(Abhi nice signature lol)

Checkboxes values can also be saved in a file -_-

Thanks :P

Because it’s the default thing in the options, why change it? Plus, they look cooler and more… smooth than a clunky check. Just a dot.

Log in to reply