![]() |
Array Copying Problems
READ MY POST BEFORE YOU MAKE YOURSELF LOOK STUPID
Ok, heres a little script thats part of the new mud system I'm working on. PHP Code:
This works all find and dandy because in echos 1 and 2 it correctly displays the MudID under all conditions, meaning the reference parser is fine. Now my problem was that echos 3 and 4 were blank even though I was simply copying an already existing reference array. Now previously in the object is another variable, the reference to the archetype which is just a single reference and not an array, this was copied to the current object just fine in all cases. Now when I tried to copy the array of the two items as a whole, it didn't work for some reason and echos 3 and 4 were blank as I said. Now then, what I did was add in the lines that you see commented out and the script worked fine after that. Is this a bug or something? |
PHP Code:
|
Quote:
|
Quote:
PHP Code:
PHP Code:
|
God damnit
You people need to read what I wrote in the freaking post. The script works fine already. Stop trying to correct stuff thats not broken. Quote:
Now here is the problem: PHP Code:
|
Quote:
|
I edited my example to be more accurate.
Edit: I never got the for(var: var) thing down. So if I did for(i: vars) then would i represent vars[index]? |
Make sure you're getting the var names
PHP Code:
Also, why do people use files for their mudlibs! DON'T DO IT, IT ISN'T NECESSARY. :[ |
Quote:
for (i: vars) newobj = i; is equivilant to for (i = 0; i < vars; i++) newobj = vars[i]; |
Quote:
|
Quote:
|
If you type the items in the script and then compile the script, even if flags are reset you can just recompile the script.
|
Quote:
And I use files because objects will be SAVED TO FILE when they're not in use. Like when you logoff. My system is designed as an object-controller, current types are (arch, ench, char, plyr, item, cont) for Archetype, Enchantment, (npc) Character, Player, Item, and Container. The files must be saved when they're not in use. script from mudobject Class PHP Code:
PHP Code:
|
Quote:
Also, you can easily program the database to store the items, example. HTML Code:
function onCreated() |
I don't think you're grasping the fact that my Mud System is for controlling all objects not just items. An item is just one type of object, there are players, npc, and types for the dialog objects, and various other things like organizations.
|
Quote:
Your problem is you are treating variables like objects. none of these objects are objects, they are just variable. someobj isnt an object, and someobj.something is just a different var, unless you say someobj = someotherobj, or someobj = new TStaticVar(); thus giving it an object definition. The reason your properties arent copying over from file.whatever to this.whatever is because the whatevers are NOT objects. in the above example, if object3 and object4 were specifically declared as objects, object1.var would definately reference objects, then object2.var would definately copy over object one, and it would work. the reason it doesnt work is beacuse object3 and object4 arent actually objects yet, and object3.whatever name is just the name of a variable, not a subvariable of the object. PHP Code:
|
Quote:
|
All I want from you people is to tell me why my script doesn't work with those lines commented out, and why it does work correctly when they're not.
Quote:
You don't seem to understand the fact that in my script shown in the first post. That the script works fine when the commented-out lines are un-commented. Quote:
|
Quote:
You are loading the vars from a file. therefore, file is an object, but everything else sub of it is a variable. You do not have to believe me though, just see, for example, what file.muditems[0].type() returns, my bet is that it will not return 2 (an object). Just like my last post stated, that you need to declare an object, or else it is just a variable. How about actually reading my post instead of just accusing me of not reading yours (sheer hypocracy if you ask me). Quote:
|
Quote:
Quote:
If you had clearly read my first post you would understand this. Edit: Its strange that the object array failed to copy while the object in a different non-array variable copied without a hitch. |
It works because you are using the new command when uncommented. Instead of arguing, see what type that variable is, like I asked before.
|
Variable type is 2, an object, live I've been saying.
And for the new command, new [size] constructs an empty array not an object. It is no different than using setArray(name, size); |
Quote:
|
Since when did you need to construct a blank array before copying one?
I already told you that my script works fine when I add in those comments. You've done nothing but try to find some error in my scripting while not even considering that there could possibly be some obscure bug in the engine. I'm irritated by the fact that you've so highly underestimated my ability to script by making me waste my time by checking if the variable is an object when I know damn well that it is. The only difference between the two scripts is that the working one makes a blank array before copying each variable (object ref in this case) to the new array. There should not be a difference in copying an array of objects as a whole and copying the individual objects into the blank array. You have yet to explain to me how this simple change that I'm displaying can affect the outcome of the script and until you do so I'm simply not going to bother seeking assistance since it seems that you are not capable enough. |
Quote:
I'm not sure if I've misunderstood where the problem is, but I cannot seem to reproduce this, since the example below is working fine. Is this where your error is occuring? PHP Code:
|
I apologize for the attitude but it frustrates me when people do not read my explanation of the problem and they attempt to find their own problems without fully understanding what is going on.
I've attempted to reproduce this outside the system myself but was unsuccessful. Though my system has a much more complicated handling of objects so I can't really duplicate everything that is affecting the problem. The data that I tested before and after the copy was the mudid. Its displayed in the echos numbered 1 to 4. Copying the whole array at once will result in the first two echos displaying the correct IDs before the copy and the second two echos being blank. Adding in the comments results in both sets of echos displaying the correct information. Edit: The scripts are set up on Symphonia Dev for anyone who wants a crack at it, that has global RC of course. |
So can this be looked into at all? -_-
|
HTML Code:
//Loading all the possible var names...HTML Code:
//You're removing vars, then you're trying to assign a new var...HTML Code:
for (temp.currentVar: vars) {HTML Code:
for (temp.currentVar: vars) { |
Is everyone on this forum incapable of actually reading my post.
Note 1: My script works PERFECTLY when the commented-out lines are edited in. Note 2; I stated this several times. I only want ONE question answered. Why do the commented-out lines make the difference in which this script works and doesn't work? Quote:
Quote:
Quote:
|
Quote:
|
Quote:
I told you the files were on Symphonia Dev and I gave you RC and NC rights and you even logged on there to look at them yet you never actually did anything or even looked at them. I'm not going to set them up again just for you after I already did. The files are available for download in this thread, the system I'm talking about would be the second one in the file. I haven't "failed" to do anything. |
Bump.
|
Bump.
I'm waiting for someone to apologize for being an arrogant jerk. |
| All times are GMT +2. The time now is 12:18 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.