FiftyTifty Posted November 17, 2018 Share Posted November 17, 2018 For some reason, in my script, when I call GetButtonPressed, it always returns -1 even though I store GetButtonPressed into a variable right after it's called. Link to mod: https://drive.google.com/file/d/1FeN45X75aD62ityuIh5c9Vx9t_OVH1KR/view?usp=sharing Script: https://pastebin.com/raw/zn0J8Ufr And since it returns -1, nothing is spawned by the script. Link to comment Share on other sites More sharing options...
dubiousintent Posted November 17, 2018 Share Posted November 17, 2018 I suspect this is a timing issue because you are "displaying the message and saving the button pressed" inside of a "function". Try moving that part out and only process the returned button within the function. "Functions" are typically intended to return a single result; not to process multiple dynamic inputs. They are normally "single frame" processing, while displaying a message and then waiting for the slow human to respond by making a choice is a multi-frame action. -Dubious- Link to comment Share on other sites More sharing options...
FiftyTifty Posted November 17, 2018 Author Share Posted November 17, 2018 I suspect this is a timing issue because you are "displaying the message and saving the button pressed" inside of a "function". Try moving that part out and only process the returned button within the function. "Functions" are typically intended to return a single result; not to process multiple dynamic inputs. They are normally "single frame" processing, while displaying a message and then waiting for the slow human to respond by making a choice is a multi-frame action. -Dubious- Could you clarify what you mean by moving it out? I assume that I can't have a UDF call another UDF, and even if I did that, I can't assign the selected button to a variable and return it, as both would have to be done in the same function. Link to comment Share on other sites More sharing options...
FiftyTifty Posted November 18, 2018 Author Share Posted November 18, 2018 Didn't work. I placed the message code in the perk entry script, and the spawning code in the UDF, and nada. It's very hard to do anything when I can't use variables in the perk entry. I think I'll just have to forget about the player being able to repair downed robots, and instead make it so that you have to take parts from them, then build the robot at a workbench. Link to comment Share on other sites More sharing options...
dubiousintent Posted November 18, 2018 Share Posted November 18, 2018 From 'TIP: Assigning & Testing variables' in the "Scripting" section of the wiki "Getting started creating mods using GECK" article:Note that there are only 3 blocktypes that will continually read the code lines in successive frames:* GameMode* MenuMode* ScriptEffectUpdateEach having specific circumstances when they are running. All other blocks (e.g. "On<Event>") are one frame occurrence events. Edit: You ninja'd my reply. You might want to take a look at the "Robco Certified" mod. It does something similar. -Dubious- Link to comment Share on other sites More sharing options...
FiftyTifty Posted November 18, 2018 Author Share Posted November 18, 2018 Robco Certified is the inspiration for this mod. Unfortunately, it's janky as hell and has performance issues. It makes heavy use of script packages that have to be applied on every game load. I'm going for something leaner that provides similar functionality, but without a heavy burden on the game engine. Link to comment Share on other sites More sharing options...
Recommended Posts