Rexdorchester Posted November 5, 2014 Share Posted November 5, 2014 (edited) Hey guys! Im trying to make a UDF that utilizes loop statements to achive a menu! At the moment I have the message box coming up with the message box ex NVSE thing but no way to get the output! Heres my code: SCN AAARVMShowQuantityMessageSCRIPT ref itemRef short cost short quantity ref param1 float param2 float param3 float param4 float param5 float param6 float param7 float param8 float param9 short sButton1 begin Function { cost, itemRef, quantity } ; setting item ref set param1 to itemref ; first button set param2 to quantity set param3 to cost * 1 ; second button set param4 to quantity * 5 set param5 to cost * 5 ; third button set param6 to quantity * 10 set param7 to cost * 10 ; fourth button set param8 to quantity * 20 set param9 to cost * 20 MessageBoxEx "How much ammo would you like to purchace? | %n (%.0f) for %.0f credits. | %n (%.0f) for %.0f credits. | %n (%.0f) for %.0f credits. | %n (%.0f) for %.0f credits. | Cancel request. |" param1 param2 param3 param1 param4 param5 param1 param6 param7 param1 param8 param9 End Now this is just doing calculatio0ns and customising the messagebox and I have this looping ftn to gather the input becuase when I put the loop inside the other ftn it froze the game SCN AAARVMShowQuantityMessage1SCRIPT short sButton1 begin Function { } while sButton1 >= 0 set sButton1 to GetButtonPressed if sButton1 > 0 SetFunctionValue sButton1 endif loop End Please guys! I just dont have the skill to determine what the issue is, at first I thought the script just had a simple lopping error but it didnt seem to change anything when I used a label goto system. but there doesnt seem to be any other way to gather the output! Edited November 5, 2014 by Rexdorchester Link to comment Share on other sites More sharing options...
Fallout2AM Posted November 5, 2014 Share Posted November 5, 2014 My suggestion is make the script working before converting it to an UDF.I first would write something like this and then when I'm sure it works I would make a generic UDF. Link to comment Share on other sites More sharing options...
Gribbleshnibit8 Posted November 5, 2014 Share Posted November 5, 2014 I actually don't know if a UDF will work with a menu like that. I don't know exactly what game mode the Functions are running in, since they can be used at any point, like quest stages. The problem is that GetButtonPressed returns in GameMode (that's the only place I've ever seen it used in Vanilla scripts) and it also only returns a valid value in the same script in which the call to ShowMessage is made: http://geck.bethsoft.com/index.php?title=GetButtonPressed I'm not entirely positive why it froze the first time, but I'm going to say it's an infinite loop, and the second one never returns anything because at that point GetButtonPressed returns -1, which is less than 0, so the loop exits after the first check, never returning a value. For good practice, you should return an 'error' code value (use -1) at the end of your function before the END, so that you can tell if something doesn't go right. You will probably need to just have all of that in a regular object script, because I really don't think that the message will work in a function. You can use it to get your data and pass back an array that then holds everything array_var ar_Items let ar_Items[0] := param1Calculation let ar_Items[1] := param2Calculation ; etc etc FunctionValue ar_Items and then in your MessageBoxEX let ar_Items := Call FunctionWithParameters parameter parameter MessageBoxEX "String data with format" ar_Items[0] ar_Items_[1] You might need to use script compiler override to do that, but I'm not sure so I'm not going to cover that right now. Link to comment Share on other sites More sharing options...
Rexdorchester Posted November 7, 2014 Author Share Posted November 7, 2014 I was just fiddling with the idea, can I start a gamemode from a function? Link to comment Share on other sites More sharing options...
Rexdorchester Posted November 7, 2014 Author Share Posted November 7, 2014 BTW guys can I change the text of a terminal's button with a script? That would eliminte this need entirely Link to comment Share on other sites More sharing options...
Fallout2AM Posted November 7, 2014 Share Posted November 7, 2014 I was just fiddling with the idea, can I start a gamemode from a function? I think I didn't understand.You can call a function inside a gamemode block, if that's what you wanted to know. Link to comment Share on other sites More sharing options...
Rexdorchester Posted November 7, 2014 Author Share Posted November 7, 2014 I was just fiddling with the idea, can I start a gamemode from a function? I think I didn't understand.You can call a function inside a gamemode block, if that's what you wanted to know. Can I call a gamemode block from a function Link to comment Share on other sites More sharing options...
Fallout2AM Posted November 7, 2014 Share Posted November 7, 2014 it's a function, it executes a scrap of script in one go. then you decide where to call it, but it leasts just for the frame you call it.however you can store results in quest.vars and re-execute it more and more.would you explain what you have in mind? Link to comment Share on other sites More sharing options...
Rexdorchester Posted November 7, 2014 Author Share Posted November 7, 2014 (edited) Im just trying to find the best way to segment my code for an item dropper, it has many segments but it starts with a terminal executing result scripts and functions are perfect for that: for they can be given parameters and the code doesn't need to be rewritten. For example, you pass an item ref and a price and it drops that amount. Although, "ordering" a quantity of > 1 is difficult because the user input functions for both integers and strings are severly lacking without the use of custom menus, which mind you, I do not know how to use. I want to add a terminal button, that apon clicking brings up a menu like the sleep or wait menu that allows you to select an integer from 1-20 and then provides you with that number of "units" of a given ammunition. A unit would be like a box of ammo, one unit being 10 caps for 10 bullets and 10 units would be 100 caps 100 bullets etc. If I could manage to find the script for the name input inthe beginning of the game I might actually be able to add an i put thats good for something. Edited November 7, 2014 by Rexdorchester Link to comment Share on other sites More sharing options...
Fallout2AM Posted November 7, 2014 Share Posted November 7, 2014 (edited) I've seen often in mods using fixed quantities, without input from the player. For example the crafting menu in FO3-FWE. Another example the mod I was trying tonight: "How many nukas you want to buy? choices: 1-5-10"This would be the easiest solution in my opinion. If you really want to input datas, you will take a hard path in my opinion. I used 2 kinds of inputs, one was in menumode and one in gamemode. Both had a nice effect, but I'm not sure if it was enough to justify the effort. Probably the easiest is the one which uses the name, as you say, however I'm not sure if it's ok to use that for what you have in mind. Check GetPlayerName, if you have problems with that I give you my script Edited November 7, 2014 by Fallout2AM Link to comment Share on other sites More sharing options...
Recommended Posts