ID:169394
 
mob/verb/Test()
var/string = "Myproc"
string()

proc/Myproc()
world << "It worked"


Myproc() isn't being called when I do string(). I know why but can someone give me a way of calling Myproc() by doing string()?
Take a look at the call() proc.
In response to Nadrew
I tried that before but I think it may be bugged.

mob/verb/Test()
world << Itack("NewSword",usr)

obj
swords
newtype

proc/CheckNewSword(mob/me)
for(var/obj/O in me.client.screen)
if(istype(O,/obj/swords/newtype/))
return 1
else return 0

proc/Itack(thing,var/mob/M)
var/string = addtext("Check",thing)
return call(string)(M)


What I'm trying to do with the above is to display "1" to the world by using the verb. What the processes do is that they call a certain proc depending on the message I send(in this case "NewSword") in the verb, then the proc that is called should return 1 if it finds a certain item in a list or 0 if it doesn't.

But what happens is that when it gets to call(string)(M), it starts running a random piece of coding. I've tried putting this snippet in two different games and in both it ran a random process(in one it ran a verb and in the other it ran a banning proc).
In response to DeathAwaitsU
It looks like you're trying to do something complicated with call() before mastering the basics. Try using a simple testbed for call() with just a basic string, not trying to add anything to it or any of that crap, and see where you can get with it.

Failing that, try just using proc references like /mob/proc/CheckNewSword. (This call() format requires you specify the src object, in this case the mob, followed by that proc reference; for global procs the src object is null.) In the end if you can get that to work you can still use your string addition, but you'll just have to use text2path() to do it.

Lummox JR
In response to Lummox JR
I tried:

mob/proc/Itack(thing)
var/a = call(thing)(src)
world << a

mob/verb/Teststs()
src.Itack("NewSword")

obj
swords
newtype

proc/NewSword(mob/me)
for(var/obj/O in me.client.screen)
if(istype(O,/obj/swords/newtype/))
return 1
else return 0


But to no success. It still calls some random piece of coding.
In response to DeathAwaitsU
DeathAwaitsU wrote:
I tried:

> mob/proc/Itack(thing)
> var/a = call(thing)(src)
> world << a
>
> mob/verb/Teststs()
> src.Itack("NewSword")
>

But to no success. It still calls some random piece of coding.

I'm guessing you don't actually mean "random" so much as "arbitrary". Which piece of code is being called?

Lummox JR
In response to Lummox JR
turf
hchair
icon = 'Tablestuff.dmi'
icon_state = "hchair"
Entered(atom/movable/A)
if(ismob(A))
var/mob/M = A
if(mytable.Game_Started) //line 19
return M << "A game has already begun"


With the runtime error:

runtime error: Cannot read null.mytable
proc name: Entered (/turf/hchair/Entered)
source file: Game.dm,19
usr: DeathAwaitsU (/mob/Player)
src: null
call stack:
Entered(DeathAwaitsU (/mob/Player))
Itack("NewSword", DeathAwaitsU (/mob/Player))
DeathAwaitsU (/mob/Player): Teststs()