Wintermute Engine Forum
Wintermute Engine => Technical forum => Topic started by: deadworm222 on March 09, 2004, 02:56:10 PM
-
There's only ONE problem with the notepad system. I have defined each note lsomehow like this:
var note1;
note1.contents="Blaa";
note1.added=false;
Now, when I execute a function called AddNote() (which works like this: AddNote(note1) ), I would like it to set note1.added to true.
method AddNote(nmbr)
{
if(nmbr.added==false)
{
WinNotepad.DoStuff();
nmbr.added=true; // if nmbr was note1, this line would mean note1.added=true
}
}
But this doesn't work... Is there any way to make it work?
If's impossible to make it work, well, we have to resort to loads of state variables...
:D
Thanks!
-
Yeah, it doesn't work, it sucks, doesn't it? >:( It seems I'll have to implement some sort of "ref" parameters...
The only thing I can suggest at the moment is to store all the notes in a global array and only send a note number as a parameter.
-
One thing I always hoped WME would support is the eval function JavaScript has. I don't really know what the real description of eval is, but is something doesn't work, use eval and it works :D
-
Jerrot already mentioned eval before, but it a little tricky, since the script compiler usually isn't part of the finished game (it's in a separated DLL). Anyway, do you think it would help in this case?
-
Jerrot already mentioned eval before, but it a little tricky, since the script compiler usually isn't part of the finished game (it's in a separated DLL). Anyway, do you think it would help in this case?
It was my first thought while reading the thread, too. But in most cases a workaround with arrays should work fine, you mostly use it to add numbers to variable names anyway...
So if it would eat speed from the engine, don't even think about realizing it. ;)
-
Jussi, are there any major drawbacks to using a global array?
Incidentally, since the WMScript is based on objects, it would make sense to be able to pass objects around by reference. In fact... Mnemonic, what if you took the PHP5 route, and force the engine to pass objects by reference? Would that cause any major problems?
-
Mnemonic, what if you took the PHP5 route, and force the engine to pass objects by reference? Would that cause any major problems?
I'm not sure, I will have to investigate what would it take to implement it. I've added it to my ToDo list, I'll look into it.
-
Jussi, are there any major drawbacks to using a global array?
I remember I only hypothetically considered this approach and found it problematic, but perhaps it can be done after all.