ID:180162
 
how do i get it to use the obj after its in the inventory...here is my code


mob
obj

Life_Raku
icon = 'Items.dmi'
icon_state = "life"
verb
get()
set src in oview(1)
src.Move(usr)
usr << "You got Life Raku"
Eponick wrote:
how do i get it to use the obj after its in the inventory...here is my code


mob
obj

Life_Raku
icon = 'Items.dmi'
icon_state = "life"
verb
get()
set src in oview(1)
src.Move(usr)
usr << "You got Life Raku"

Weird.. It didn't include the whole code... anyhow...

With the line set src in oview(1), you've displayed that you almost know how to do this, but not completely :). Here goes.

get()
set src in oview(1)

This is good, now we can take this over to use() to set it inside the usr.

use()
set src in usr

There. That makes sure that src is in the usr's contents... I think... Ack! Typing that made me skeptical! Try that.
In response to Vortezz
hmm..wonder what happened to the code...any who...what does set src in usr do?
In response to Eponick
ACK!!!

it has use in verbs and when i hit use it dun take it out on inventory either!
In response to Eponick
Eponick wrote:
ACK!!!

it has use in verbs and when i hit use it dun take it out on inventory either!

Well yeah, I didn't add that part.

del(src)

Should do the trick.
In response to Vortezz
ok...how do i get the use verb out of verb tab?
In response to Eponick
Eponick wrote:
ok...how do i get the use verb out of verb tab?

When it's deleted, it should get rid of the verb.
In response to Vortezz
no...it jsut stay's there...get goes away but not use...here is my code so far



mob
obj

Life_Raku
icon = 'Items.dmi'
icon_state = "life"
verb
get()
set src in oview(1)
src.Move(usr)
usr << "You got Life Raku"
use()
set src in usr
usr.health += 20
usr << "You feel refreshed"
del(src)
In response to Eponick
obj/items //set anything we can pick up as an item
[tab] verb
[tab] [tab] Get() //this allows all items to be picked up wth one verb
[tab] [tab] [tab] set src in oview(1)
[tab] [tab] [tab] src.Move(usr)
[tab] [tab] [tab] usr << "You got [src]!"
[tab] [tab] Drop() //this allows all items to be droped with one verb
[tab] [tab] [tab] set src in usr //should work
[tab] [tab] [tab] src.Move(usr.loc)
[tab] [tab] [tab] usr << "You drop [src]!"


/* next we gonna define Life_Raku */
obj/items/Life_Raku
[tab] verb
[tab] [tab] Use() //heres the use verb
[tab] [tab] [tab] set src in usr //should work
[tab] [tab] [tab] usr.health += 20
[tab] [tab] [tab] usr << "You gained \blue 20 \black health!"
[tab] [tab] [tab] del src


code shoudl work on copy and paste(cept indents, and the [tab] needs to be replaced with actual tabs). only one problme is if ylou use multiple items later on(wich you will) you may have a bunch of Use() verbs, and it might use the one thats on top, unless the user right clicked and brought up the menu. theres probably a much more effecient way of doing this.

for instance, heres an idea:

obj/items/stat_refill
[tab] var/health_to_give=0 //default value
[tab] var/magic_to_give=0 //default value
[tab] var/msg="You used an item!" //default message
[tab] verb/Use()
[tab] [tab] var/list/usable_items
[tab] [tab] for(var/obj/item/stat_refill/O in usr.inventory)
[tab] [tab] [tab] usable_items+=O
[tab] [tab] var/item_used=input("Use what?","Use Item","") in usable_items+="Nothing"
[tab] [tab] if(item_used=="Nothing")
[tab] [tab] [tab] return
[tab] [tab] else
[tab] [tab] [tab] usr.health+=item_used.health_to_give
[tab] [tab] [tab] usr.magic+=item_used.magic.magic_to_give
[tab] [tab] [tab] usr << "[item_used.msg]"
[tab] [tab] [tab] del item_used

there, we defined the base verb to use any item that is a refill_stat item. do you undertand the code? its prety simple, if not ask questions and I'll answer.

now, we make the actual item! what fun!

obj/items/stat_refill/Life_Raku
[tab] icon='Items.dmi'
[tab] icon_state="life"
[tab] health_to_give=20
[tab] magic_to_give=0 //dont NEED to do this cuz it starts at zero already
[tab] msg="You gained 20 health!"

thats it! do this declaration for any kind of stat item you wish to change. you can even add more stats. say you want.. um... training points! simply add 'train_points_to_give' (or call it whatever you want) under stat_refill, then in the item declaration change train_points_to_give to whatever you want!

make sense? if not tell me what part doesn't and I'll answer Qs best I can.

the second mass of code I gave you aughta let you get a general idea of how to design a pretty good categorized item system. should work with weapons and armour too if you adapt it. anyhow... everythign shoudl, be okay(cept maybe a few slips here and there, maybe a typo). so off you go! work on that code! feel free to ask for help.

In response to XgavinX
u can capture people!
In response to XgavinX
you really should consider starting to post codes like:

mob
blah
verb
blah()
blah

instead of

mob
[tab]blah
[tab][tab]verb
[tab][tab][tab]blah()
[tab][tab][tab][tab]blah

and if you dont wanna do that, then try this...

mob
[tab]blah
[tab][tab]verb
[tab][tab][tab]blah()
[tab][tab][tab][tab]blah

or

<font color=red>mob</font>
[tab]<font color=red>blah</font>
[tab][tab]<font color=red>verb</font>
[tab][tab][tab]<font color=red>blah()</font>
[tab][tab][tab][tab]<font color=red>blah</font>

[EDIT]
because its getting hard to read some of your stuff =P

In response to FIREking
?
In response to Eponick
Eponick wrote:
?

if you did not notice, i replyd to xgavinx, which means i was talking to him, not you........
In response to FIREking
sorry about that, i just dont wanna have to space over a zillion times and it lets peeps know there is a TAB there(newbies that is). -shrug- i'll figure something out.
In response to Eponick
did you not understnad my code?
In response to XgavinX
XgavinX wrote:
did you not understnad my code?

no and you dont have to type [tab] i will know how to tab it
In response to Eponick
i do it outa habit now, after i help peeps.

perhaps i shoulda waited until you actually understood DM before helping you.
In response to XgavinX
XgavinX wrote:
i do it outa habit now, after i help peeps.

perhaps i shoulda waited until you actually understood DM before helping you.

no i just dont understand what u mean by Blah all over the place
In response to Eponick
i must admit that the code does look rather jumbled. try copyinga nd pasting and then taing outt he [tab] and putt he real tabs there. and possibly taking out the comments and studying the code. its actually pretty well written and flexible code.
In response to XgavinX
i just noticed somthing....that dont help me at all...i got all the inventory stuff to work...its just that u can pick up other players.
Page: 1 2