ID:165451
 
I'm trying to make a spell system where spells are learned at a certain level. These spells are added to the user's list of avalible spells. When the user wants to cast a spell, s/he selects from a list of their already learned spells. I can't really think of a way of doing this, except with lists, and I don't know how to do list very well and don't know how I would save the player's list for each person.
FriesOfDoom wrote:
and I don't know how to do list very well

Then learn to use them. There is plenty of info available on the DM Reference and DM Guide about lists.

and don't know how I would save the player's list for each person.

Do you mean saving to savefiles? Just like you'd save any other variable. Also, if you're saving the whole mob, it will already be saved with it.
In response to Kaioken
Kaioken wrote:
FriesOfDoom wrote:
and I don't know how to do list very well

Then learn to use them. There is plenty of info available on the DM Reference and DM Guide about lists.

and don't know how I would save the player's list for each person.

Do you mean saving to savefiles? Just like you'd save any other variable. Also, if you're saving the whole mob, it will already be saved with it.

How would you save the whole mob? Also is there any tutorials you know of that teach what I asked? I'll look in the DM guide too, but I'm still about 5 chapters off.
use it like inventory
        if(src == usr) statpanel("SpellBook")
for(var/obj/spells/O in src)
stat(O)


then use the click command on the obj
so like
obj/spell
Fire
FLameblast
Click()
if(src in usr)
usr.currentspell = 1
client
Click(atom/o)
if(o && !(o in usr))
if(usr.currentspell == 1 && usr.alshot == 0)
var/obj/a = new/obj/spell/Fire(o.loc)
usr.alshot = 1
usr.MP -= 3
spawn(20)
usr.alshot = 0
for(var/mob/M in a.loc)
M.stamina /= 1.25




spawn(5)
del(a)



In response to FriesOfDoom
FriesOfDoom wrote:
How would you save the whole mob?

Same thing as saving a single value, but just use the object var instead of the value. Read the reference entry for '<< operator (savefile)' for full info.
An example:
mob/verb/SaveMeh()
var/savefile/SF = new("[src.ckey].sav")
SF << src
src << "You have been saved!"
//just note in case you dunno, in 'mob/verb's, usr == src


Also is there any tutorials you know of that teach what I asked?

There probably are, search around. Check out the 'Partners' heading on the left of this page; there are tutorials on those sites.
Also note that, these forums, the BYOND Bwicki, and the DM Reference contain a tremendous amount of information, albeit not in tutorial-form (though the Reference can be considered close). Use them and their search functions well.
There is enough information on the DM Reference entries about lists alone to completely teach you how to use them properly.

I'll look in the DM guide too, but I'm still about 5 chapters off.

You should be able to jump to the lists chapter. Just make sure you begin reading it from it's beginning. When the guide refers to things explained in previous sections, there is a link to that section, so if you do dont understand something, press the link next to it to jump to the section on that.
In response to Rky_nick
He said he doesn't know how to use lists and you didn't even comment your code.

If you don't know what you're doing, don't post. :\ It's apparent you copied some code from somewhere (the 2nd part) and wrote the 1st part to try and work with it.
Also, your code is poorly coded, will screw up atom/Click() overrides, isn't quite efficient, and could be done much better. It's also poorly idented on the first part, and the first and second parts won't even correctly work together.
In response to Kaioken
Its from a game I'm working on, and its not a rip.
original code:


client
Click(atom/o)
if(o && !(o in usr))
if(usr.curspell == 1 && usr.ammo1 >= 1 && !usr.alshot)
usr.ammo1 -= 1
var/obj/a = new/obj/spell/cut/(usr.loc)
usr.alshot = 1
spawn(10)
usr.alshot = 0
var/b = get_dir(a,o)
var/c
var/dmd
var/dmds
while(a)
c = get_step(a,b)
for(var/mob/M in c)
dmd = a.dmg
dmds = dmd
dmds /= 2
dmd *= dmds
M.HP -= dmd
if(M.HP <= 0)
if(M.monster)
del(M)
else
M.loc = locate(1,1,1)
view() << "[M] died!"
del(a)
for(var/obj/K in c)
if(K.opacity)
del(a)
if(a)
step(a,b)
a.dmg -= 20
sleep(2)
if(!a.dmg)
del(a)

I thought lists as in, var/list/
I didnt copy this code, but I did write up the top part to work with it when i posted. I used a code that was untested combined with the one above that was tested and works
(I used the untested one because it was for spells not guns)

Im not good at commenting, since i never had any use for it.

My evil halves answer to the question:
YOUR MOM DOESNT KNOW WHAT YOU'RE DOING!
I swear to god if you dont read "My evil halves answer to the question:" and call me a noob... i'll uh... be pissed?

either way, think what you want, and I admit I should've commented.
In response to Rky_nick
Rky_nick wrote:
Its from a game I'm working on, and its not a rip.

I never said it was a rip. I said something correct - you copied it from somewhere.

original code:
The horror! The horror! Dude, this isn't any better and all and you should of never shown me that. I'm going to have nightmares now. :x

I thought lists as in, var/list/
Yeah? Right. Whatever. So did I.

I didnt copy this code,

Liar! Shame on you! You did copy it.
...from your game. You even admitted it earlier. :P

but I did write up the top part to work with it when i posted. I used a code that was untested combined with the one above that was tested and works

Yes, duh. This was obvious to me already in my previous post, as stated there.

Im not good at commenting, since i never had any use for it.

I can see why. You don't have use for proper coding either, huh? >_>
Anyway, I usually don't comment my code either. EXCEPT when posting it to the public, mind you.

My evil halves answer to the question:
YOUR MOM DOESNT KNOW WHAT YOU'RE DOING!

Yes, true. She doesn't know what I'm doing now. All she knows is that I'm in my room. How did you know that?!

I swear to god if you dont read "My evil halves answer to the question:" and call me a noob... i'll uh... be pissed?

...Right...
so, just to please you: noob! >_>

either way, think what you want, and I admit I should've commented.

I think the truth. >_> :P
Regardless of what I think, your code IS badly coded and inefficient. That's a fact. If something works, it doesn't mean it's good.
In response to Kaioken
Kaioken wrote:
Regardless of what I think, your code IS badly coded and inefficient. That's a fact. If something works, it doesn't mean it's good.

Thanks guys for the help, I'm gonna work on it today. Rky_nick you pointed me in the right direction, even if by what Kaioken says "its wrong" it helped so thanks for trying :P. This would also be a good time for you Kaioken to tell Rky_nick what he needs to fix :D.
In response to FriesOfDoom
FriesOfDoom wrote:
This would also be a good time for you Kaioken to tell Rky_nick what he needs to fix :D.

Eh, I suppose you're right, I'll do it tomorrow (*cough cough* if nobody else does first), though he didn't ask for help here of course and I'm not sure if he would even care - apparently, in his opinion his code is perfectly fine.
It also has bad readabillity which makes helping with it a harder job.
In response to Kaioken
My code isnt perfectly fine, but it gets the job done without ****ing me in the *** like many codes I tried to get to work.It also doesnt spew out runtime errors.
In response to Rky_nick
Rky_nick wrote:
My code isnt perfectly fine, but it gets the job done without ****ing me in the ***

Or so you think. That's a big problem in it. I guess it screwing up atom/Click() overrides and being overally inefficient and unreadable doesn't count as "***ing you in the ***", huh?

like many codes I tried to get to work.

Well, it just means they were worse. :\

It also doesnt spew out runtime errors.

(Yet). Also, again, if something works, it doesn't mean it's well done or good at all, and it doesn't mean it will necessarily always work either.