Hello again...ive been very busy recently and have now returned to working on my Byond project...there have been alot o updates since then heh heh...but anyways to the point i cant seem to figure out how to get a verb to call a proc i made for battle....heres baisically what i have
mob
verb
fire()
set category = "Actions"
flick("shoot",src)
call(mob/proc/fight)(obj/weapons/O as obj in usr.contents, mob/T as mob in view())
and this code works for the animation of shooting but as far as the calling o the proc...i obviously have no idea what im doing in the ways of calling procs heh heh...and yes i have read the help docs an stuff...but im not exactly sure what to do...am i using the wrong thing to call the proc? but anyways any help would be greatly appreciated
ID:138360
Oct 6 2000, 1:03 pm
|
|
In response to Spuzzum
|
|
On 10/6/00 9:34 pm Spuzzum wrote:
mob Of course, in this case you would want to go the more direct route (or "root", for you Canadians) mob verb fire(obj/weapons/O in usr, mob/T in view()) set category = "Actions" flick("shoot",src) fight(O,T) // member function of mob Generally you only need to use call() when the function to call is variable (perhaps stored in a string input by the user). The way Spuzz has reorganized the function looks solid to me, unless I'm misinterpreting what you want to do here. |
In response to Tom H.
|
|
(or "root", for you Canadians) I'm not going to justify that with a response. Um, no, that doesn't qualify as a response. =) mob Generally you only need to use call() when the function to call is variable (perhaps stored in a string input by the user). The way Spuzz has reorganized the function looks solid to me, unless I'm misinterpreting what you want to do here. Oh, duh. I can't believe I missed that shortcut (*thwack* Bad Spuzzum! *twack thwack bam... thump*). Still, if you wanted to use call, that is how you would do it. |
You almost have it right. Here's what you should use:
mob
verb
fire(obj/weapons/O in usr, mob/T in view())
set category = "Actions"
flick("shoot",src)
call(/mob/proc/fight)(O,T)
Here's what I changed:
- call()() doesn't allow you to choose arguments (you can't, for example, type in a proc with arguments)... so I added the arguments to fire() instead, and passed them along to call()(args) respectively
- 'as obj' and 'as mob' are implied, as is 'usr.contents' in lieu of 'usr'... I removed those (or put usr in place of usr.contents) to save code space... not that it matters much =)
- call(proc)() requires the proc to be referenced by actual path (/mob/proc/fight) instead of relative path (mob/proc/fight)... in other words, just use a slash first =)
Does that help?