![]() |
Arrays of strings!
Pleasepleaseplease Stefan... as someone who's first language was C++, I can safely say that I cannot live much longer (nor can I make cool book NPCs) without the aid of arrays of strings. Oh, and are multidimensional arrays possible? If not, add those too. And multidimensional arrays of strings! :D And, and, and this.strings (is this possible with an NPC server? I know this.flags are...)
|
Clever people find ways around.
setstring oldx0,#v(playerx); for(this.i=1;this.i<5;this.i++) setstring oldx#v(this.i),#v(strtofloat(#s(oldx#v(this.i-1)))); will create an "array" of 5 strings, oldx0, oldx1, oldx2 oldx3, oldx4 multidimentional strings are noticably easier than multidimentional variables: setstring oldx0-0,#v(playerx),#v(playery); for(this.i=1;this.i<5;this.i++){ for(this.n=1;this.n<5;this.n++){ setstring oldx#v(this.i) #v(this.n),#v(strtofloat(#s(oldx#v(this.i-1)-#v(this.n-1) ))); } } will create an "array" of 25 strings, oldx0-0, oldx0-1, oldx0-2 oldx0-3, oldx0-4... I botched the creation a little, you'd need to set the column oldx0-n and the row oldxn-0 for that snippet to work, but you get the idea. this.strings are kinda tricky, but if you only need one, and the NPC doesn't have any showimgs(this version NPCs have to show to show images, and drawunderplayer NPCs make drawunderplayer images, it's weird), and it doesn't have to be visible, just use setcharprop #n,string; ! |
oh dear god! I knew Graalscript was teaching me bad programming habits... but being able to fill in part of variable names using a message code is just wrong! Anyway, thanks for your code snippets. It just feels wrong to do stuff like that... but what the hey. :D
|
| All times are GMT +2. The time now is 07:29 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.