ID:263201
 
Code:ok, this is part of a quest. The Loyalist kinh needs you to get a map of the rebel city for him so they can play a sophisticated attack. He sends you to the map Maker and the Map Maker makes you deliver this map to the boy, and 2 others to other people(i will learn them by this code) one of which is to the boy.
mob
Rebel_boy
icon = 'Player12.dmi'
icon_state = ""
NPC = 1
HP = 100000000
rebel = 1
if(usr.contents=/obj/Map_to_the_Boy)
verb
Give()
usr.contents-=/obj/Map_to_the_Boy
usr << "Thanks a ton! I have been waiting forever! Mommy!! I got my treasure map!"
usr.quest3+=1

obj
Map_to_the_Boy
icon = 'Maps.dmi'
icon_state = ""
sellamount = 0
verb/Get()
set src in oview(1)
usr.contents+=new/obj/Map_to_the_Boy
del(src)


Problem description:when i compile, i get error(in the mob) about usr.contents being an undefined var(even though I used it in the map maker code to add the maps to usr.contents) and 2 errors about empty type name((Indention Error?))

First of all:
if(usr.contents=/obj/Map_to_the_Boy)

This is going to give you errors unless you use the correct operator. When comparisons are being made you use ==, not =.
if(usr.contents == /obj/Map_to_the_Boy)

But actually, you need to be using locate().
if(locate(/obj/Map_to_the_Boy) in usr.contents)


I'm also going to guess you're getting errors from trying to add and subtract object types instead of objects from your contents list.

var/obj/Map_to_the_Boy/Map_To_Remove = locate() in usr.contents
usr.contents -= Map_To_Remove
del(Map_To_Remove)

You could also use a for() loop to locate and remove the map.
A final word of advice: the contents list is not a good candidate for inventories because it is a special list and you can't perform all list functions on it.
In response to Hobbesx
Hobbesx wrote:
var/obj/Map_to_the_Boy/Map_To_Remove = locate() in usr.contents
> usr.contents -= Map_To_Remove
> del(Map_To_Remove)


You don't need to remove the item from usr's contents if you're going to delete it. You can omit the second line, and the same thing would happen.

~~> Unknown Person
thanks a bunch, I used your help to the best way, I flipped the coding around though, to anyone who has this problem later, you can fix it with
mob
Rebel_boy
icon = 'Player12.dmi'
icon_state = ""
NPC = 1
HP = 100000000
rebel = 1
verb
Talk()
if(usr.loyalist == 0)
if(usr.start4 == 2)
if(locate(/obj/Map_to_the_Rebel_Boy) in usr.contents)
usr.contents-=/obj/Map_to_the_Rebel_Boy
usr << "Thanks a ton! I have been waiting forever! Mommy!! I got my treasure map!"
usr.quest3+=1
else
usr << "Hello."
else
usr << "Hello."
else
usr << "GUARDS!!GUARD!!A LOYALIST!!"
In response to Unknown Person
it says in my previous codes what this is, this is just the guard map instead.
mob
Rebel_Guard
icon = 'knight.dmi'
icon_state = ""
NPC = 1
HP = 100000000
Str = 10000000
Def = 10000000
MHP = 10000000
Mexp = 1000000000
rebel = 1
verb
Talk()
if(usr.loyalist == 0)
if(usr.start4 == 2)
if(locate(/obj/Map_to_the_Rebel_Guard) in usr.contents)
var/obj/obj
set src in oview(1)
del obj
usr << "Thanks a ton! I have been waiting forever! Now I can take my son fishing when my duty ends."
usr.quest4+=1
else
usr << "Hello."
else
usr << "Hello."
else
usr << "Loyalist!!! DIE!!!!!!!!"
Fight(usr)
proc/Fight()
for(var/mob/E in get_step(usr,usr.dir))
var/damage = src.Str
E.HP -= damage
E << "[src] attacks you for [damage] damage!!"
src<<"You attack [E] for [damage] damage!!"
if(E.monster==1)
MobDcheck(E)
else
UserDcheck(E)

obj
Map_to_the_Rebel_Guard
icon = 'Maps.dmi'
icon_state = ""
sellamount = 0
verb/Get()
set src in oview(1)
usr.contents+=new/obj/Map_to_the_Rebel_Guard
del(src)

It works!! But it doesn;t get rid of the map from user's inventory -.-
In response to Unknown Person
That's not true, actually. If you delete it directly it will leave an empty object in the list... sort of a blank spot that will mess up the reading of the list's len var.
In response to Dragon warrior2662
can anyone help me here?
In response to Dragon warrior2662
The answer is in [link] ... when you put "del obj", obj was NOT defined as the map ... instead, the obj was a blank

- GhostAnime
In response to Dragon warrior2662
Dragon warrior2662 wrote:
usr.contents-=/obj/Map_to_the_Rebel_Boy

That will never work. The contents list contains actual objects, not type paths.

Lummox JR
In response to GhostAnime
Ok, well in my previous post, I stated that using that gave me bugs. My code is:
mob
Rebel_boy
icon = 'Player12.dmi'
icon_state = ""
NPC = 1
HP = 100000000
rebel = 1
verb
Talk(var/obj/Map_to_the_Rebel_Boy/Map_To_Remove)
if(usr.loyalist == 0)
if(usr.start4 == 2)
if(/obj/Map_to_the_Rebel_Boy/Map_To_Remove = locate() in usr.contents)
usr.contents -= Map_To_Remove
del(Map_To_Remove)
usr << "Thanks a ton! I have been waiting forever! Mommy!! I got my treasure map!"
usr.quest4+=1
else
usr << "Hello."
else
usr << "Hello."
else
usr << "GUARDS!!GUARD!!A LOYALIST!!"

and my code gets 2 errors:
/obj/Map_to_the_Rebel_Boy/Map_To_Remove:Undefined type path
missing expression

In response to Dragon warrior2662
I have tried editing the code in many ways, I just can't fix it, someone please help
In response to Dragon warrior2662
God, don't double post...

mob
Idiots_wana_parthey
icon = 'Drunkard.dmi'
//icon_state = "" <-- if value is FALSE [Boolean] at first definition, don't bother entering it
Losa = 1
Insane = 100000000
Wasted = 1
verb/Talk()
if(!usr.wasted){usr<<"Go get wasted man...";return}//return to stop the rest of the code
if(usr.Insane >= 2)
var/obj/B = locate(/obj/Beer) in usr.contents
if(!B){usr<<"Bring me a beer";return}//wanna know what ! means? Look at the bottom
usr.contents -= B
del(B)
usr << "Thank you green fairy."
usr.Insanity+=1000028972398792837982379827987239873208230723078 //>.>


Read, Learn, Do! Seriously >.>

Want to know why I used if(!var) instead of if(var==0)? Learn about boolean shortcuts

- GhostAnime
In response to Dragon warrior2662
mob
Rebel_boy
icon = 'Player12.dmi'
icon_state = ""
NPC = 1
HP = 100000000
rebel = 1
verb
Talk()
if(usr.loyalist == 0)
if(usr.start4 == 2)
if(locate(/obj/Map_to_the_Rebel_Boy) in usr.contents)
usr.contents-=/obj/Map_to_the_Rebel_Boy
usr << "Thanks a ton! I have been waiting forever! Mommy!! I got my treasure map!"
usr.quest3+=1
else
usr << "Hello."
else
usr << "Hello."
else
usr << "GUARDS!!GUARD!!A LOYALIST!!"
This is your regular code, I see an error that might cause problems later, It says if a loyalist==0 then usr<<"blah blah" but if loyalist=1 then he can do w/e he wants, then I noticed the boy is rebel=1. So you might want to check that.

mob
Rebel_boy
icon = 'Player12.dmi'
icon_state = ""
NPC = 1
HP = 100000000
rebel = 1
verb
Talk()
if(!usr.loyalist)
if(usr.start4 == 2)
for(var/obj/Map_to_the_Rebel_Boy/O in usr.contents)
usr.contents-=O
del(O)
usr << "Thanks a ton! I have been waiting forever! Mommy!! I got my treasure map!"
usr.quest3++
else
usr << "Hello."
else
usr << "Hello."
else
usr << "GUARDS!!GUARD!!A LOYALIST!!"
This should work if they have the map when they talk to him. (I didn't change the loyalist thing)
In response to Kore2
Actually, if it's one, than it'll do the very last thing at the bottom, which is calling the guards (because of the else 'underneath' the if statement for the !loyalist, therefore if loyalist!=FALSE, it will jump down to that else statement and do nothing else)

AND in your example, you made it so if the person has more than one map, it'll add an extra '1' to the variable and an extra message... also, the else is indented too far in underneath that.

- GhostAnime