Guys, im coding a game and i had one idea to create turfs on a certain area and its working fine, the problem is to get the old turfs back after a certain time. this is the code ive made:
mob/verb/teste()
var/area/A = new()
for(var/turf/T in oview(usr,2))
var/turf/waters/N = new(T)
A.contents += N
for(var/mob/M in oview(3,usr))
var/dano=usr.Ninjutsu*5
view()<<"[M.name] was damaged [dano] by [usr.name] skill"
M.HP-=dano
M.Morte(M,usr)
turf
waters
icon='turfs.dmi'
icon_state="agua"
Entered(mob/M)
if(ismob(M))
usr.agua=1
does anyone know what i have to do to get the old turfs back?
In response to Nadrew
|
|
im newbie here so idk how to use it. That was my problem i noticed Entered() dont work on objs, so attempt on Turfs that way. i dont understand what you did right there, after detecting a mob entered in a turf you create a obj located in src.loc.. aa xD explain please :)
|
In response to Tuckax
|
|
Tuckax wrote:
Entered() dont work on objs Entered() does work on objs, however, when an object shares space with an object inside of a turf, the turf is the object being entered. Objs are also containers, so if something moves inside of the obj, Entered() can be called. However, when something shares the location of an object, you are looking to use Crossed()/Uncrossed() instead of Entered/Exited. |
In response to Ter13
|
|
yea thanx this is working better =) not lagging
|
In response to Nadrew
|
|
With the part about var/obj/waters/haswaters = locate () in src
When I read over the code this is confusing me as it appears it should be something specific. When I read through I see: Call turfs entered proc with a argument of a mob with refrence m 2 if m is a mob 3 make a reference of the type obj/waters with refrence name haswaters which looks for something located inside the original turf 4 if the reference is true than do rest of code. Now why this confuses me is anything inside of the turf could be assigned to the haswaters, so if anything was inside the turf the if statement would return true. Is this correct thinking? Nadrew wrote: Ignoring that your code isn't inside of <dm> tags I'll still help you. > turf/Entered(mob/M) Surely you can go from there, if not, you should probably read the DM Guide and DM Reference more. |
In response to Akando5959
|
|
var/obj/waters/has_waters = locate() in src The thing you should be wondering about is locate(), which doesn't have anything in its parentheses. The DM Reference clarifies what this means. DM Reference: Type: An object prototype or tag. If locate() is being used in an assignment to a variable with a declared type, this argument is optional and will default to the type of the variable being assigned.locate() is being used in an assignment to a variable (haswaters) with a declared type (/obj/waters), so instead of writing locate(/obj/waters), Nadrew wrote locate() with empty parentheses. You: 3 make a reference of the type obj/waters with refrence name haswaters which looks for something located inside the original turfIt's not looking for "something," it's looking for an /obj/waters. |
Your problem is that you're trying to use turfs in a way that doesn't come naturally for a turf, turfs aren't really supposed to be something you create on the fly for things. For this you should be using objs, which can be created and deleted without interfering with the turfs they're on. So instead of creating a new /turf/waters you should be making an /obj/waters with the same icon and whatnot.
Now, Entered() isn't going to work on your obj directly, as you rarely ever enter an object in a way that would trigger it, so you'd have to do something inside of turf/Entered() instead.
Surely you can go from there, if not, you should probably read the DM Guide and DM Reference more.