![]() |
Gah, dereferencing
So, what I'm trying to do is something like this
this.arr = {"0==1","1==1"}; but then later extract {false,true} out of that in another event. I know how to reference to variable names, but how do you... uh... get this problem done? |
I am not sure if this is what you want, but I'll give you what I think you are wanting.
Right now, you have this.arr containing two string values, but you want it to contain two boolean types. In that case, just put: PHP Code:
|
eval() has been disabled, the only way you can execute code inside a string is to use putnpc2, so there is no real way to do what you want.
|
Well, I want to make a more secure warplink class where the boolean values it looks for when onPlayerTouchsMe() occurs are stored within the NPC containing the class. However, it would be more redundant and less user-friendly (like for tilers with limited scripting knowledge) if I required an extra name-specific function in every NPC containing the class. Otherwise you could just check if the boolean string array exists. Any other way wouldn't be even close to as efficient. I'm personally hoping that Stefan finds his way to this thread, because there's probably some way to do it, unless somebody else knows too. Otherwise, this should definitely be a requested feature.
|
Couldn't you tokenize the string, and do your own checks?
|
I'm tired and confused, but if you're trying to get the NPC to put booleans into an array, what napo said should have worked.
PHP Code:
If I'm way off on the subject, just ignore me ._. |
Well, seems like everyone's way off the subject.
PHP Code:
|
Try:
PHP Code:
|
gah, you're still not getting the point. I'll post the class.
PHP Code:
PHP Code:
|
Why can't you just set this.reqflags on playertouchsme so that it'll just evaluate then?
|
Quote:
|
I am not sure I entirely understand what you are trying to say, but is this what you mean?
PHP Code:
|
Quote:
Well do an if statement to see if it is a one, if it is = true, if not = false? Or create a 2d array, and then do this.arr[][1]= true; else this.arr[][0]=false, *edit: forgot to add this* then do an if (this.arr[][1]=="true"){ do this;} I dont know GS2 so I dont know how to put it in code for you. If that doesn't help, well will talk it in depth later. |
Quote:
That isn't what he's trying to do. |
Yea, just evaluating onPlayerTouchsMe is the best idea, but limiting myself to knowing only one way is a bad idea :(
|
There is also the possibility to use makevar() which doesn't accept array brackets though, nothing really dynamic except the name of the variable.
|
Quote:
Yea, I'll test this, don't know if temp. is local to the block of code only though. PHP Code:
|
Quote:
I want to attach conditions to npc topics in the database but can't since it is not possible to read conditions from a string, which is what is limiting me at the moment. |
Quote:
|
Quote:
|
There has never been an eval() function.
I don't think that adding such type of function would be really good, it would be much better to think of better ways of doing what you want to do. It would only be a hack. Why not letting the joining npc provide a function which is called by your code? Since level makers are doing copy&paste anyway it shouldn't be a problem. I don't think providing a boolean evaluation inside the onCreated function is easier than to copy the check-function. |
Quote:
|
Quote:
I, for one, would rather not have commas and other crap in my tokens to make them look ugly :| |
Quote:
PHP Code:
|
Quote:
Why don't you just do string.tokenize(delimiter)? |
Yes just pass the delimiters to the tokenize function, if you don't pass any delimiters then it is using the default ones (comma).
|
omg, nobody understands the concept of returning delims, where am i?
|
Quote:
I'm not sure I can think of one application where having the delimiter automatically returned with each token is of any benefit. |
Well I could imagine that it could be useful for some cases to get an array of the separate tokens plus the delimiters, if you have more than one delimiter and want to restore the original string afterwards. The tokenizeWithDelims function should add to the temp.list though (use it as array) and not append the string with comma etc.
|
Quote:
PHP Code:
PHP Code:
string.tokenize(ignoreddelims,returneddelims); where string.tokenize() is an overloaded function wherever it comes from in the script. Would also be cool if you could base tokens off of strings, but it's easier to get around that than with single character delims. |
| All times are GMT +2. The time now is 12:54 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.