Bbartram 0 Posted March 24, 2008 I have an object, a sign, that has a UserAction which opens a dialog. In this dialog a player can select from a ComboBox any of 5 options. I have a button, CLICK_ME, which I would like to execute a script which will change a marking on the sign based on which option is selected. I have a script, TexSwap.sqs, which uses setObjectTexture to make the change. Obviously I'll need to pass the selection choice to TexSwap.sqs, but for starters I just want to call it with no parameters sent. I've tested the script TexSwap.sqs when it was directly connected to the UserAction, and it works fine. But now that I'm trying to call it from inside description.ext, I'm having global/local variable problems. In description.ext: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> class CLICK_ME : RscActiveText { idc = 101; style = ST_CENTER; x = 0.4; y = 0.65; w = 0.2; h = 0.05; text = "Click Me!"; action = "[_this select 0] execVM 'TexSwap.sqs'"; default = true; }; TexSwap.sqs looks like this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _ZoneSign = _this select 0 _ZoneSign setObjectTexture [0,"\flextest1\0.pac"] The error I get when I try this is Quote[/b] ]'[_this|#| select 0] execVM 'TexSwap.sqs": Error Local variable in global space Can somebody please clue me in where I'm going on. Still a beginner at OpFlash scripting. Thanks, Brian Share this post Link to post Share on other sites
dr_eyeball 16 Posted March 24, 2008 Based on that error message, it must be needing 'this' rather than '_this'. (Edit: that's not correct either - see post below) N.B.: This assumes that ActiveText even has a 'this' parameter for it's actions. Not everything does and those that don't, return random data. Topic BIKI this shows it to be different for various cases. setObjectTexture <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_ZoneSign setObjectTexture [0,"\flextest1\0.pac"]; Side topic: I have never got setObjectTexture to work in a normal script. Tried 6 months ago. Is that actually working now? Would love to be using that now. What object type is _ZoneSign? Share this post Link to post Share on other sites
loyalguard 15 Posted March 25, 2008 Hopefully Dr_Eyeball's diagnosis will fix the issue, however, I have never been able to pass arguments (this, _this, or other types) via a dialog button action code string. I have always had to temporarily make the variables global so they are available in any script and then make them nil once they have been reassigned as local variables in the script called/executed by the dialog button. Please let us know how it works out. Share this post Link to post Share on other sites
dr_eyeball 16 Posted March 25, 2008 Quick testing seems to indicate ActiveText does not support 'this' or '_this'. So you cannot pass in 'this' or '_this' from an ActiveText since dialogs will only ever deal with dialog controls or properties. clarify Looking it at it again, it doesn't quite make sense. Your post says you are supposed to pass in your "selection", but based on TexSwap.sqs, you are supposed to pass in an "object". Perhaps you are trying to pass in '_this' from the calling script. global variable (quick solution) So like Loyalguard said, it's probably easier to use a global variable in that case. It all depends. Insufficient info provided to decide. buttonSetAction (long solution) Otherwise, you could define the action within the script, not in the class property in description.ext. Eg: In your script which creates the dialog, you could add: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">buttonSetAction [_idc, format["[%1] execVM 'TexSwap.sqs'", _this select 0]]; However, you cannot pass in objects this way, only ID's and let TexSwap.sqs map the ID to an object via an array or other method. Share this post Link to post Share on other sites
Bbartram 0 Posted March 27, 2008 Thanks for the replies, guys. The global variable fix worked, I added a global called ThisSign. What's the best way to set my global variable back to null? Something like <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">ThisSign = 0? Is there a way to destroy/deallocate variables? Share this post Link to post Share on other sites
loyalguard 15 Posted March 27, 2008 I think nil is best. Share this post Link to post Share on other sites
vova _fox 0 Posted March 30, 2008 Hi guys, some question. #define CT_TOOLBOX 6 #define CT_CHECKBOXES 7 #define CT_PROGRESS 8 #define CT_STATIC_SKEW 10 #define CT_CONTEXT_MENU 14 #define CT_CONTROLS_GROUP 15 #define CT_XKEYDESC 40 #define CT_XBUTTON 41 #define CT_XLISTBOX 42 #define CT_XSLIDER 43 #define CT_XCOMBO 44 #define CT_ANIMATED_TEXTURE 45 #define CT_OBJECT 80 #define CT_OBJECT_ZOOM 81 #define CT_OBJECT_CONTAINER 82 #define CT_OBJECT_CONT_ANIM 83 #define CT_LINEBREAK 98 #define CT_USER 99 Someone known anything about of this control types? Share this post Link to post Share on other sites