ID:167038
 
I have no clue how to IMPORT sound. I tryed doing new, then searching for it, but it didnt import it. Also I have the code for players 2 build and to remove player built stuff, but I don't know how to make it so only the admin or player who owns the wall or thing can delete it.
Could someone give a code example and explain it? I just stated and this is my first game. All that I've learned I've figured out or learned from tutorials. Also how would I do skills like fishing or mining? I wrote the code for skills but it doesn't work. Check out Code Problems fourm to see about that. Any help is appreciated!
Do you mean using Import() at runtime to get sound, or do you mean including it in your project? To include it in your project its as simple as copying or cutting the sound file and dropping into the file for your project. Another option to dynamically acquire music for your project is to use a verb such as:

mob/PC/supercooladminguy/verb/Music(var/s as sound)
world << s


Of course, that code above is pretty raw with not much to it. But it'll do the job. You can't import mp3s but you can use .OGG,.WAV, and Midis.

For more functionality with sound use the sound() proc from the reference.
In response to Rockinawsome
thank you *slaps self in face*

anyone know how to do the building I was talking about above and the skills stuff?
In response to FriesOfDoom
Well, rereading your first post you need to be aware of something: There is no "the code", and it's often the subject of many jokes from within any programming community. Code is as pliable and as particular as grammar is in language. Therefore you must understand all the parts of the code in order to actually use it effectivly. You could of course use code that you copied and pasted, but that doesn't get you very far unless you know how to change and adapt it to what you're working on. However, it isn't really fair to the author of the code to merely change a few details and call the code your own. The code needs to be reworked in a manner more suited to your level of understanding. The same can be said of the writing community. Someone might plaguarize a sentance or an idea and print it, but that singular line looks awkward and out of place because it exceeds their skill level (and it's plaguarism).

That said, if you look at the code I posted previously you see that the heirarchy of the mob (e.g. datum or data type, short for mobile) changes for the particular verb I posted.

In BYOND we have the ability to specify what belongs to what with ease.

/*Below is an upsidedown tree which shows what belongs to what. Since PC is below mob it belongs to it, and the same is true of "Admin".*/


mob //the base type
PC // the next level of categorization, this can be whatever, but "PC" is derived from 'Player Character' and is conveinent.
Admin //This is the guy who kicks your ass from the game when you piss off the world your playing in by spamming "noooooooooooooooooooooooob" over and over again. It's also the next level in our heirarchy.
verb //this belongs to Admin
Destroy(obj/O as obj in view)//And this is the name of a verb
if(isobj(O)) //this is an if statement
del O //this is the same as writing del(O), it's merely a preference of syntax (the way you decide to write code.) As you may have guessed, this will delete your object in question.


The above tree is done this way so that multiple things can be written to belong to the same base datum. Rather than do this however, we can shorten what we've written by writing:

mob/PC/Admin/verb/Destroy()
for(var/obj/O as obj in view()
if(isobj(O))
del O

or
mob/PC/Admin
verb/Destroy(var/obj as O in view())
if(isobj(O))
del O

It all means the same thing. And since Destroy() belongs to Admin, no other player can use Destroy() without first becoming an Admin. There are quite a few ways to give Admin priviledges in a game. However, I would suggest giving them to your key when you log in:
mob/Login()
..()//do the ussual before doing your code
if(src.key=="FriesOfDoom") //great key name by the way
usr.client.mob = new/mob/PC/Admin //this needs the new syntax before mob/PC/Admin so that it is created before trying to connect to it.


I hope this suffices as an adequate explanation.

In response to Rockinawsome
Thank you for your help! I understand what you are saying about writing code diffrent ways. But what I don't understand is how the code below works out and is so diffrent, can you explain plz. I'm as new to this as a 3 day old baby crawling. I know the basics, and stuff learned form tutorials and thats it. One of them is yours the other is from a tutorial, neither work(probly something I did)(no error message though).

mob
Login()
if(src.key=="FriesOfDoom") // Change this to your key
usr.client.mob= new/mob/player/Admin

and

mob
Login()
if(usr.key=="XxMalificentxX") // Change this to your key
usr.verbs += typesof(/mob/Admin/verb/)
In response to FriesOfDoom
FriesOfDoom wrote:
Thank you for your help! I understand what you are saying about writing code diffrent ways. But what I don't understand is how the code below works out and is so diffrent, can you explain plz. I'm as new to this as a 3 day old baby crawling. I know the basics, and stuff learned form tutorials and thats it. One of them is yours the other is from a tutorial, neither work(probly something I did)(no error message though).

mob
Login()
if(src.key=="FriesOfDoom") // Change this to your key
usr.client.mob= new/mob/player/Admin

and

mob
Login()
if(usr.key=="XxMalificentxX") // Change this to your key
usr.verbs += typesof(/mob/Admin/verb/)

What do you mean when you say, the code works out but is so different?

Also, just because there are no error messages when you compile the game, does not mean that there are no errors. There are technically 3 types of errors.

1) Compile Time Errors, which are the ones you mentioned.

2) Run Time Errors, which will be shown to the host when the game is compiled in debug mode when something in the code that wasn't thought through fully by the coder that the compiler had no problems with. For example:

obj
var
randomvar=1

mob/verb/Blah()
var/obj/k
world<<k.randomvar


Now, when you look at that code, you will notice that it will compile fine, correct? Now place that into a dm file on its own and compile and run the program. Click the verb, what happens? You get a runtime error saying:

<font color=red>runtime error: Cannot read null.randomvar
proc name: Blah (/mob/verb/Blah)
usr: Satans Spawn (/mob)
src: Satans Spawn (/mob)
call stack:
Satans Spawn (/mob): Blah()</font>

What that means is that k was defined as an object, and does have that variable, but k does not exist so to speak. To fix that problem edit it to look like so:

    var/obj/k=new()


Now, k will exist in the world rather than just being an empty variable and you won't get that runtime error any more.

As a side note, most of the time when you get a run time error, it will give you a line number at which the error occured at, but not in all cases.

The third isn't really an error so to speak, it is more just when you made a mistake in your code, and it doesn't really work as you expected it to.