Odessa Posted January 9, 2015 Posted January 9, 2015 What is the context? You could use string matching, so someone types in a request, like "9mm Pistol", and you search through the names of all items until you get a match, then add it. ref rItem string_var request foreach entry <- possible_Items let rItem := *entry if eval (sv_find "request", $rItem) > -1 ; if we find the request in the name of rItem, add it AddItem rItem, 1 --- Need to talk to jaam about that bracket issue.
Guest Posted January 9, 2015 Posted January 9, 2015 it seems a good solution, however this time I'm using lists and not arrays (which is so strange) so I have troubles to understand how to adapt that script. I think it's better if I PM you the specific example so you understand better.
prideslayer Posted January 9, 2015 Posted January 9, 2015 scratch that. I use GetType myself and it's not needed even without CO.
DoctaSax Posted January 9, 2015 Author Posted January 9, 2015 With CO, you're more likely to have success if you turn that stuff around if iInt == GetType rSomeForm
prideslayer Posted January 9, 2015 Posted January 9, 2015 Wrapping the call in parens is also helpful if iInt == (GetType rSomeForm) I think it really struggles sometimes without them to determine if the == is another param to the function in code like this: if GetType rSomeForm == iInt That shouldn't be a problem with straight operators but I think it is sometimes, or might be.
DoctaSax Posted January 9, 2015 Author Posted January 9, 2015 Sometimes it also struggles with them, giving you 'mismatching brackets' warnings, but dropping in an eval can help. For the other question, there's no way I know of yet to construct editorID strings and make them refer to forms. Would be sweet. I think you can place formIDs between quotation marks and use those as forms, but that obviously invites load order headaches with non-vanilla forms.
prideslayer Posted January 9, 2015 Posted January 9, 2015 You're talking about turning something like a hex string into a ref, right, the way the console does for you? All we need to do that is a str2int(). Ideally it would work on hex strings or ints, but even if it only works on ints, that would be 'ok'. If that doesn't work directly when being assigned to a ref var, you could just use it with buildref.
prideslayer Posted January 9, 2015 Posted January 9, 2015 Here's a completely untested strtoint. It may have bugs, but if so, they will be easy to fix. scn StrToInt string_var str string_var char array_var arParts array_var element int iMult int ret Begin Function{str} let iMult := 1 ; does this work? We want to split the string into individual chars let arParts := sv_split str "" foreach element <- arParts let ret := ret * iMult let char := element["value"] if char == "1" let ret := ret + 1 elseif char == "2" let ret := ret + 2 elseif char == "3" let ret := ret + 3 elseif char == "4" let ret := ret + 4 elseif char == "5" let ret := ret + 5 elseif char == "6" let ret := ret + 6 elseif char == "7" let ret := ret + 7 elseif char == "8" let ret := ret + 8 elseif char == "9" let ret := ret + 9 endif let iMult := 10 loop SetFunctionValue ret End Only works on normal decimal (base-10) values, but a hex version would not be difficult. This should allow something like: let myInt := call StrToInt "123456" let myMod := GetModIndex "somemod.esp" let myRef := BuildRef MyMod MyInt
DoctaSax Posted January 9, 2015 Author Posted January 9, 2015 ; does this work? We want to split the string into individual chars let arParts := sv_split str "" Not sure, but you can walk a string with foreach, the same as with an array, so we can skip parking the characters in an array first foreach sv_character <- sv_originalstring ; etc loop I'm fairly certain I've seen Oblivion modders use "formID".dosomething in scripts before though, instead of using an editorID, although obviously your solution solves the load order problem. Would be nice though to be able to dynamically construct editorIDs and retrieve a form from them.
Guest Posted January 9, 2015 Posted January 9, 2015 EDIT: yes I'm wrong. Actually this seems a wonderful idea. We all would need a UDF like that. EDIT again: or maybe not. Mmmh I'm no more so sure it would work as I would need
prideslayer Posted January 9, 2015 Posted January 9, 2015 Oh I completely misinterpreted what you meant.. constructing an editorid string and turning that into a formid, yes, that would be very helpful indeed. What we need for that is basically some kind of "GetFormByName" function. I don't think this would be too difficult for NX or NVSE to do.
Odessa Posted March 31, 2015 Posted March 31, 2015 In NVSE, an empty string_var evals to True, unlike most programming languages (Ruby can fuck off ). This is what Ar_Find returns (aka Ar_BadStringIndex) to signify "Not Found", if you store it in a string_var: let str := "" if eval str ; Empty string is true! But, if you check the Ar_Find return directly, it seems to be False (urrggh). if eval (Ar_Find "Not there", SomeArray) ; But, without an intermediary string_var, it is false (editted to add second part)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now