does it make any lag difference at all to make the variables class defined?
for instance
mob/pc/var/Forever=1
mob/pc/var/Forever=2
etc...
do this about 40 times.
or
mob/var/Forever=1
etc...
the thing I've found to be best about making the base mob vars is that with Click() it's easier you don't have to make individual procs and send user to them for the unique cases of mob/pc variables. Just makes things generally easier.
However if you have 100 mobs on the map and over 200 variables per mob, and you're doing variable checks through world.contents...
Would there be any noticable difference in lag?
Saving isn't an issue since I do the saving when the world is deleted, and loading when it begins and I know that variable saving can affect saving time.
ID:268528
Aug 20 2004, 3:45 pm (Edited on Aug 20 2004, 3:50 pm)
|
|
In response to Theodis
|
|
I think you misunderstood my question or maybe I misunderstood what you said but...
let me give an example.. normally if you wanted a universal variable amongst all mobs you'd do this - mob/var now if you wanted a variable to only be in a specific class of a mob, like for instance - mob/superman/var My question is, since you can't call a variable from a normal mob unless you reference it (for instance you have to specify - for(var/mob/superman/M as mob in world) instead of for(var/mob/M as mob in world)). If you don't specify it won't recognize variable. So my question is I was told that when you specify in for() that it doesn't really matter because it cycles through all the mobs in world.contents anyways, so will making variables certain mob specific affect lag at all? Is there any advantage to doing this? also one of the problems I've run into with making them class specific is whenever I'm forced to use usr instead of src. For isntance - Click() or anything to do with the mouse... so if it's class specific it won't recognize it, it has to be universal unless someone can point me to a way of accomplishing this. the more work way is to have Click() activate a proc that is a mob proc... that clarifies what usr is. However that's more work and I'd like to avoid having to do this since I'm redoing old code, and would be a pain in the ass to do. |
In response to Jon Snow
|
|
if(istype(src,/mob/superman))if(src.supermanpowerupobtained==1)usr<<"You are superman! AND you have the powerup! WOW! You ARE cool! =P" ? |
In response to Phoenix Man
|
|
that doesn't fix in situations where you have to use usr...
I guess there's no way around this but to do the extra work. it gives errors if you do it in Click() and use usr about undefined variable... |
In response to Jon Snow
|
|
Uuum,
first way: for(var/mob/m in world) if(istype(m, /mob/superman)) second way: for(var/mob/superman/s in world) At first i thought that the first way could give more "lag" then the second one. But i think that the second way will make the same lag cuz it still has to loop trough all mobs in the world and check if there class is right. It probably does exactly the same though inside the buildin byond code. If you wanna be conserned about lag then this aint something to worry about if u ask me. Just define the var "globally" and u'll be fine. If anyone thinks i'm wrong, correct me. Greetz Fint |
In response to Jon Snow
|
|
Jon Snow wrote:
that doesn't fix in situations where you have to use usr... something Does that help any? |
In response to Fint
|
|
well in my current game I have over 300 variables and 20000 lines of code - it's a turn based strategy game with city development... Which gets up to 20+ players in one world...
I like to make complex games... So any way I can do things the most efficient would be better... I must not have checked on doing an istype check to see if that would work... if I don't reply then it must work :) I wish one of the programmers would reply about how exactly byond goes about using things like for() and such to cycle through... does it really cycle through every mob? Or does it have everything organized already and just goes directly to the ones you specify? I mean more answers would be great :) |
In response to Jon Snow
|
|
Jon Snow wrote:
well in my current game I have over 300 variables and 20000 lines of code I agree, you need to start trying to be more efficient if you have that much code, either that or you accidently added in an extra zero when typing that number. You should try to think of ways to do things easier. Continually redo things when you are working on them to streamline them better each time. That is what I do when I have a junk heap of code, and eventually it becomes half the size, easier to understand and easier to use. |
In response to Loduwijk
|
|
aye that is what I'm trying to do, but I don't have all the necessary knowledge so I could try breaking it down, but it'd be futile if I end up finding a better way, makes 2x more work so I'm going to give it a few days learn as many ways as possible...
One thing that's really helped me is using vars["[]"] to easily put in a text message at the very beginning of a proc and not having to edit it ever again if need be and just change the variable inside the var check list instead of going through and changing the variable or deleting parts of the code. very useful for inputs like so var/t=input("blah") as null|anything in list("food","money") if(vars["[t]"]>=2) return |
No but it sounds like you have a bigger problem :P. Anyway I think types are mainly there to catch dumb errors at compile time and are going to be attached to the actual data regardless of what you do at run-time.