fg109 Posted June 11, 2011 Share Posted June 11, 2011 (edited) I can't figure out how to use this function. Maybe I'm doing it wrong or maybe it just doesn't work the way I think it does. This is an attempt of me using it: scn testscript string_var string1 ref tempref Begin GameMode let string1 := "Gold001" set tempref to StringToRef string1 messageex "%n" tempref Player.AddItem tempref 1 End When I tested it in the game, I got "<no name>" from the messageex command, and no gold increase either. Edited June 11, 2011 by fg109 Link to comment Share on other sites More sharing options...
Astymma Posted June 12, 2011 Share Posted June 12, 2011 I can't figure out how to use this function. Maybe I'm doing it wrong or maybe it just doesn't work the way I think it does. This is an attempt of me using it: scn testscript string_var string1 ref tempref Begin GameMode let string1 := "Gold001" set tempref to StringToRef string1 messageex "%n" tempref Player.AddItem tempref 1 End When I tested it in the game, I got "<no name>" from the messageex command, and no gold increase either. May want to try the following:set tempref to StringToRef $string1given that: As of OBSE v0017, string variables can be passed to any command expecting a string literal as an argument by prefacing the name of the variable with a dollar sign. This deprecates many of the Set...EX commands. The variable must be local to the calling script and its name must immediately follow the dollar sign. Link to comment Share on other sites More sharing options...
QQuix Posted June 12, 2011 Share Posted June 12, 2011 StringToRef converts a Pluggy string to a ref var. You will need the $, as Astymma said, to load an OBSE string into a Pluggy string and, then, into a ref.Something like: String_var sFormID Long psFormID Ref MyRef set psFormID to CreateString -1 0 1 1 setString psFormID $sFormID set MyRef to Stringtoref psFormID If you know the mod where the FormId came from, you can use OBSE's: let MyRef := GetFormFromMod "Oblivion.esm" $sFormID BUT . . . , in both cases, sFormID must be in the form of a 8-digit hex number, like "0000000F" for Gold001. If you are trying to convert a generic EditorID (strings loaded with generic contents like "Gold001" or "Apple") to a ref, there is no functions to do it, because the game engine does not save these EditorIds. They are only good at CS time. Link to comment Share on other sites More sharing options...
fg109 Posted June 12, 2011 Author Share Posted June 12, 2011 Thanks to both of you for answering my question. @QQuix I tried what you put in your post and it worked great. But unfortunately I guess what I wanted was impossible. As you said, I wanted to be able to convert generic editor IDs to a string so I could do something like: set tempshort to GetRandomPercent let string1 := sv_Construct "GenericNPC%2f" tempshort set string2 to CreateString -1 0 1 1 SetString string2 $string1 set tempref to StringToRef string2 so it would be easier to randomize things instead of having to set everything to an array first. Link to comment Share on other sites More sharing options...
Recommended Posts