Community
SCI Programming => SCI Syntax Help => Topic started by: totenmaske on July 08, 2012, 05:41:53 AM
-
i want to pass time at a stage in my game (The player gets to pick between 1-24 hours), is it possible to make it so that when gTimeHours hits 24, it will add on the remainder of the time instead of going to 0 like i've set it to? I'm just not really sure how to do it.
(method (changeTimeHours addTimeHours)
= gTimeHours + gTimeHours addTimeHours
(if(> addTimeHours 0)
)
(if(>= gTimeHours 24)
= gTimeHours 0
++ gTimeDays
)
)
*edit*
I just decided to make my own script to deal with all this. Only thing is, i've never made my own before. When i call it i have a box appear and you type in how long you want to rest... " (= lTimeHours(GetNumber("How Long?"))"
I just have a problem where every time i enter a number i get the little box popping back up, how do i leave a script once you've called it and finished using it?
-
Not sure what is going on with your input statement, but in the first section you could keep the remaining hours by subtracting 24 instead of resetting it to 0... if hours >= 24 then hours - 24, days ++... so if hours hits 26 then it would be reset to 2 instead of 0
-
Well... Doing it your way would have been a lot easier than what i did! I decided to change my way at it by making a switch method inside a switch method for all possible out comes. (I completely forgot to say that before when i edited my original post...)
(instance public ChangeHour of Script
(properties)
(method (init)
(super:init())
(= lTimeHours(GetNumber("How long would you like to sleep?"))
(switch(lTimeHours)
(case 1
(switch(gTimeHours)
(case 0 (= gTimeHours + gTimeHours lTimeHours)) //1 hour
(case 1 (= gTimeHours + gTimeHours lTimeHours)) //2 hour
(case 2 (= gTimeHours + gTimeHours lTimeHours)) //3 hour
(case 3 (= gTimeHours + gTimeHours lTimeHours)) //4 hour
(case 4 (= gTimeHours + gTimeHours lTimeHours)) //5 hour
(case 5 (= gTimeHours + gTimeHours lTimeHours)) //6 hour
(case 6 (= gTimeHours + gTimeHours lTimeHours)) //7 hour
(case 7 (= gTimeHours + gTimeHours lTimeHours)) //8 hour
(case 8 (= gTimeHours + gTimeHours lTimeHours)) //9 hour
(case 9 (= gTimeHours + gTimeHours lTimeHours)) //10 hour
(case 10 (= gTimeHours + gTimeHours lTimeHours)) //11 hour
(case 11 (= gTimeHours + gTimeHours lTimeHours)) //12 hour
(case 12 (= gTimeHours + gTimeHours lTimeHours)) //13 hour
(case 13 (= gTimeHours + gTimeHours lTimeHours)) //14 hour
(case 14 (= gTimeHours + gTimeHours lTimeHours)) //15 hour
(case 15 (= gTimeHours + gTimeHours lTimeHours)) //16 hour
(case 16 (= gTimeHours + gTimeHours lTimeHours)) //17 hour
(case 17 (= gTimeHours + gTimeHours lTimeHours)) //18 hour
(case 18 (= gTimeHours + gTimeHours lTimeHours)) //19 hour
(case 19 (= gTimeHours + gTimeHours lTimeHours)) //20 hour
(case 20 (= gTimeHours + gTimeHours lTimeHours)) //21 hour
(case 21 (= gTimeHours + gTimeHours lTimeHours)) //22 hour
(case 22 (= gTimeHours + gTimeHours lTimeHours)) //23 hour
(case 23 (++ gTimeDays)(= gTimeHours 0)) //1 day
) //Switch gTime end
) // case 1 lTime end
) // Switch lTime end
(if(<= lTimeHours 0)
Print("You need to pick a number between 1-24.")
) // end <=
(if(>= lTimeHours 25)
Print("You need to pick a number between 1-24.")
)// end >=
)// get number end
) //method end
) //instance end
it goes up to 24 cases to allow 24 hours of rest each time. (didn't think i should post the whole thing up :P)
As for the input statement, i made a mistake of doing (Method(doit() not (Method(init(), so it works fine now anyway... Took me awhile just to notice that is what i mucked up...
This script is 8.95Kbs, Should i not worry about that? or switch to what you said to take less space?
-
Unless you run into memory issues, I wouldn't worry about it. And even then, you could knock down that whole switch to one or two lines so memory could be saved while still using your script, so no big worry