Clock Design
Author | Topic: Clock Design |
---|---|
Warrior
Member # 6846
|
written Thursday, June 1 2006 10:59
Profile
Recently I thought about creating a clock by calculating the time in hours and minutes with a number from 0 to 5000 (dayticks). Eventually, I intend to create an item (e.g. a watch or magic item) with a custom ability which displays the time. From there, I can create quests with time limits. Here is my attempt so far in the scenario script: We know that there are 1440 minutes in a day (24*60). 3.472 (recurring) comes from 5000/1440. However, avernumscript doesn't like the decimal point sign and seems to want to round down variables which are not whole numbers. This means that there are about 27 hours in the day! '(dayticks * 1000) / 3472' shows my attempt to get around the decimal problem, which failed (setting all values to 0). Is there any way around this problem? Have others before me tried to do this? EDIT: I've reached the meaning of life! [ Thursday, June 01, 2006 12:17: Message edited by: Pyrulen ] -------------------- "Build a man a fire, and he´ll be warm for a day; set a man on fire, and he´ll be warm for the rest of his life." Posts: 65 | Registered: Thursday, March 2 2006 08:00 |
Agent
Member # 2820
|
written Thursday, June 1 2006 13:00
Profile
I am going to post the code that I think will accomplish your goals, but you will have to test it yourself. Although I only skimmed your code, I think that the approach is flawed, though that is probably because you are not used to an engine that truncates all decimal or float values into integers. -------------------- Thuryl: I mean, most of us don't go around consuming our own bodily fluids, no matter how delicious they are. ==== Alorael: War and violence would end if we all had each other's babies! ==== Drakefyre: Those are hideous mangos. Posts: 1415 | Registered: Thursday, March 27 2003 08:00 |
Warrior
Member # 6846
|
written Thursday, June 1 2006 13:35
Profile
I must confess I didn't know about the % function, and now that I do it makes things simpler. However, your code in the form that it is does not work. All values are bizzarely set to 0, and I think 'totalminutes = daytick * 36 / 125;' may be the problem. While mathematically correct, avernumscript doesn't seem to cope with it. Neither does it help in any way to simply take an approximate value of 3.472 and multiply both sides by 1000 to give whole numbers - we then get negative numbers appearing for no apparent reason. -------------------- "Build a man a fire, and he´ll be warm for a day; set a man on fire, and he´ll be warm for the rest of his life." Posts: 65 | Registered: Thursday, March 2 2006 08:00 |
Lifecrafter
Member # 6193
|
written Thursday, June 1 2006 13:44
Profile
Homepage
Edit: test shows that this wasn't right... Back to the drawing board. Edit: Like Garrison said, you need to put parentheses around it before you divide. Also, whenever an integer goes over 32766 it becomes negative, and counts down all the way to 65532. So the clock will only last for about 4 hours that way. [ Thursday, June 01, 2006 14:24: Message edited by: Lazarus. ] -------------------- Guaranteed to blow your mind. Frostbite: Get It While It's...... Hot? Posts: 900 | Registered: Monday, August 8 2005 07:00 |
Agent
Member # 2820
|
written Thursday, June 1 2006 13:48
Profile
Hmm, this peaks my curiosity. I will take a quick look at it and see if the values are truly being constantly reset to 0. I will try using some parenthesis. This should only take a few minutes... Update: I did the coding too quickly to remember a few important limitations of the engine. One, it processes equations right to left, so parenthesis are indeed necessary ( (daytick * 36) / 125 ). Two, the the engine can only handle integers up to 32767. I'll come up with a quick workaround for this, but it will not be pretty at all. [ Thursday, June 01, 2006 15:05: Message edited by: Garrison ] -------------------- Thuryl: I mean, most of us don't go around consuming our own bodily fluids, no matter how delicious they are. ==== Alorael: War and violence would end if we all had each other's babies! ==== Drakefyre: Those are hideous mangos. Posts: 1415 | Registered: Thursday, March 27 2003 08:00 |
Off With Their Heads
Member # 4045
|
written Thursday, June 1 2006 14:35
Profile
Homepage
I believe that Avernumscript calculates math right-to-left, so daytick * 36 / 125 = daytick * 0 = 0. Parentheses should fix this. -------------------- Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens. Smoo: Get ready to face the walls! Ephesos: In conclusion, yarr. Kelandon's Pink and Pretty Page!!: the authorized location for all things by me The Archive of all released BoE scenarios ever Posts: 7968 | Registered: Saturday, February 28 2004 08:00 |
Agent
Member # 2820
|
written Thursday, June 1 2006 16:49
Profile
Well, this was surprisingly irritating but I got it to work pretty elegantly using fun, functional math. This is the basic version that will tell the time in 24 hour notation. I incorporated the leading zero for the minutes if the time is, for instance, 1:09. For a very good reason, 0:00 will not coincide with the day number changing perfectly. The difference does not accumulate, however, and the effect is essentially negligible. EDIT: Since I figured out the mechanics of it anyway, I decided to add some small modifications to make this a complete time-telling script with all the aesthetic frills. [ Thursday, June 01, 2006 20:17: Message edited by: Garrison ] -------------------- Thuryl: I mean, most of us don't go around consuming our own bodily fluids, no matter how delicious they are. ==== Alorael: War and violence would end if we all had each other's babies! ==== Drakefyre: Those are hideous mangos. Posts: 1415 | Registered: Thursday, March 27 2003 08:00 |
Warrior
Member # 6846
|
written Thursday, June 1 2006 21:54
Profile
It works, give or take a missed bracket. Nicely done. Not that this problem can really be helped, but the hours of darkness seem too short (since when has the sun risen at 1:00 AM outside of the arctic circle?). -------------------- "Build a man a fire, and he´ll be warm for a day; set a man on fire, and he´ll be warm for the rest of his life." Posts: 65 | Registered: Thursday, March 2 2006 08:00 |
Agent
Member # 2820
|
written Friday, June 2 2006 19:41
Profile
Well, according to this system, the daylight lasts 50% longer than in real life. The sun would set at 9:00 p.m. and rise at 3:00 a.m. I wonder if anyone else wants to have a watch in their scenario... -------------------- Thuryl: I mean, most of us don't go around consuming our own bodily fluids, no matter how delicious they are. ==== Alorael: War and violence would end if we all had each other's babies! ==== Drakefyre: Those are hideous mangos. Posts: 1415 | Registered: Thursday, March 27 2003 08:00 |