Keleigh3000 Posted July 5, 2013 Share Posted July 5, 2013 OK, not a magic box exactly, but the subject line can only contain so much. Basically, I want to script a container so that the PC puts certain specific items in it and after a defined period of time passes in game those items are replaced by the same number of a different item. So, an easy bake oven script, essentially. Any help that is given will be appreciated. Thanks. Link to comment Share on other sites More sharing options...
Belthan Posted July 5, 2013 Share Posted July 5, 2013 The following script will bake as many as you put in, but only in full batches. What I mean is, say your bake time is 4 hours. If you put in 3 raw items at noon, and 3 more raw items at 2PM, you will get 3 finished items at 4PM as expected. However, ones you put in at 2PM won't actually start baking until the first batch is done, so the second batch won't be ready until 8PM. float Timer short Converting short NumItems BEGIN gamemode if GetItemCount MyRawItem > 0 if Converting == 0 set NumItems to GetItemCount MyRawItem set Converting to 1 set Timer to GameDaysPassed elseif Converting == 1 if (GameDaysPassed - Timer) > CookTime ; CookTime in days if NumItems > GetItemCount MyRawItem ; Took some (but not all) out before they were done set NumItems to GetItemCount MyRawItem endif removeitem MyRawItem NumItems additem MyFinishedItem NumItems set Converting to 0 endif endif else if Converting == 1 set Converting to 0 ; took them out before they're done, start over endif endif ENDAn alternative would be to put a message in the OnActivate block that says "oven in use", and doesn't activate the container so you can't open it again until a full batch is done - like an actual easy bake oven :smile: float Timer short Converting short NumItems BEGIN OnActivate if Converting == 1 showmessage OvenInUseMessage else activate endif END BEGIN GameMode if GetItemCount MyRawItem > 0 if Converting == 0 set Converting to 1 set Timer to GameDaysPassed elseif Converting == 1 if (GameDaysPassed - Timer) > CookTime ; CookTime in days set NumItems to GetItemCount MyRawItem removeitem MyRawItem NumItems additem MyFinishedItem NumItems set Converting to 0 endif endif endif END Link to comment Share on other sites More sharing options...
Keleigh3000 Posted July 6, 2013 Author Share Posted July 6, 2013 Thanks so much, Belthan. That ought to be enough to get me working in the right direction.I'll drop you a note when I finish it. Link to comment Share on other sites More sharing options...
Keleigh3000 Posted July 29, 2013 Author Share Posted July 29, 2013 One more question on this, if anyone is about this morning. I'm using the second script above as the core of my "oven", is there any way that the "oven in use" message could display the remaining time on the timer? (Preferably in a reasonably normal fashion, i.e 6 hours, or 6.5 hours rather than .2471 days or some such.) Thanks... Link to comment Share on other sites More sharing options...
Belthan Posted July 31, 2013 Share Posted July 31, 2013 You can put a replaceable parameter in the message text like so: %.0f Hours Remaining.This will round to the nearest hour. If you want a fractional hour, change the zero in the message box format specifier to the number of decimal places you want to show (e.g. %.1f for one decimal). Then use code like this to pass the number of hours to the showmessage command: float CookTimeHours set CookTimeHours to CookTime * 24 showmessage OvenInUseMessage CookTimeHours Link to comment Share on other sites More sharing options...
Keleigh3000 Posted August 1, 2013 Author Share Posted August 1, 2013 Thanks. Now I can make my cook time dynamic and let the user know how long it will take. A mensch is what you are. Link to comment Share on other sites More sharing options...
Keleigh3000 Posted August 10, 2013 Author Share Posted August 10, 2013 And, here's the result: Helios Jr Portable Solar Energy Cell ChargerI'll be using a variation of the same script for a gas powered version.Thanks again for your help, Belthan. Link to comment Share on other sites More sharing options...
Recommended Posts