Sorry for more questions,
I seem to have come across a issue trying to get the Click() proc to work with oview().
Such as having to be next to the .obj to click it and have it function?
Is there a work around this? maybe I Should just use verb and set category to null then use a macro for objects..
Kind of at a loss I tried a few things looked at the Ref didn't get much and read a few guides in hopes maybe someone did it themselves then looked for a lib that had something similar to figure out how clicking a object next to the player works...
ID:140124
May 1 2010, 10:52 pm
|
|
May 1 2010, 11:02 pm
|
|
In response to Emasym
|
|
Emasym wrote:
> Click() Yeah I tried that however Click() It works for the first click but closing does not work without oview(1) the thing works completely but from any range possible |
In response to DeathBane
|
|
Think a moment about what you're doing there.
If the NPC is in oview(1) OR the door is open Do A else If the NPC is in oview(1) You're using OR. Even if src.open is a false value, the NPC will be in oview(1) of usr, and thus the else will never trigger. if(!(src in oview(1))) return |
In response to Emasym
|
|
Emasym wrote:
Think a moment about what you're doing there. > if(!(src in oview(1))) return Okay I see, I tried to use Else if() so I could put arguments in there but I see where I was going wrong with what I thought it meant should have thought more about what I was doing. Click() I have it down like this now I was a bit confused when I read the operators guide for ! , thanks to you I understand how (!) works now |
In response to DeathBane
|
|
May I ask one more question? if you dont mind?
|
In response to DeathBane
|
|
It's a free forum, go ahead.
And about the ! operator, it's used to check every false value ("", null, 0), and is used to check TRUE/FALSE values, such as your "open" variable. if(open) |
In response to Emasym
|
|
I didn't take full advantage of (!) here either... but my main issue is
When you have a item equipped your unable to Drop any item? and that was making a if statement to check if the player has something equipped? and now I cant drop anything pretty much until I un-equip a item... obj/items/ verb/get() set src in oview(1) src.loc = usr verb/drop() if (!usr.EQW) usr << " You must take it off before you can drop it" src.loc = usr else loc = usr.loc I see the problem but how do I make it allow me to drop items below the tree of obj/items avoiding it counting every item as stuff under .EQW |
In response to DeathBane
|
|
You set the value of EQW to that item, and on Drop() you check whether EQW equals src (the item being dropped).
obj/items |
In response to Emasym
|
|
Emasym wrote:
You set the value of EQW to that item, and on Drop() you check whether EQW equals src (the item being dropped). > obj/items Is this equip() verb setup to Unequip and Equip at the same time What is usr.EQW=src doing exactly? |
In response to DeathBane
|
|
It wasn't meant to equip/unequip, just to equip. But in case there was something equipped, it'd unequip that. It's a very simply system, nothing complex.
A verb doing both would be something like; verb/Equip() The unequip will only work if you Equip() the exact item you've got equipped. I wouldn't recommend such a system, because it's just confusing. |
In response to Emasym
|
|
Emasym wrote:
It wasn't meant to equip/unequip, just to equip. But in case there was something equipped, it'd unequip that. It's a very simply system, nothing complex. > verb/Equip() The unequip will only work if you Equip() the exact item you've got equipped. yeah just as you were posting I messed with it and did something that does both will problems occur later with it? obj/items/equip/ I can drop items normally even when stuff is equipped now though so it is working just not sure if I should be avoiding stuff like this (was told Shortcuts are normally bad in programming |
In response to DeathBane
|
|
Well, you're not setting usr.EQW to null when unequiping, so that's one problem.
Another "problem" would that that, no matter which item you use Equip() on, if you've got something equipped, it'd unequip it. And what do you mean by "Shortcuts" ? |
In response to Emasym
|
|
Emasym wrote:
Well, you're not setting usr.EQW to null when unequiping, so that's one problem. I added usr.EQW= null to unequip also the way its working it does not seem to be unequipping the suffixes still switch which makes me think they are set on the right usr.EQW=src or usr.EQW= null anyway I can check? also just what i heard from a friend on msn told me, he said shortcuts in programming is bad because you want the code as flexible as possible sometimes longer is better... (is the F1 Ref in the Dream-maker good to use also?) |
In response to DeathBane
|
|
Everything combined
mob/var/obj/EQW // object variable |
In response to Emasym
|
|
That is rather flawed logic though.
Instead of explicitly returning if the condition is NOT meet, why not simply keep things modular and call the object's function if the condition is meet, then handle everything else in that object's function. Something as simple as Click() With the door's activate defined as activate() Now you can handle the same functionality for multiple objects. |