The Daily Click ::. Forums ::. Klik Coding Help ::. Consequences for a character based on a span of time.
 

Post Reply  Post Oekaki 
 

Posted By Message

Droog



Registered
  21/06/2002
Points
  240
12th June, 2013 at 12/06/2013 04:35:42 -

Let's say you had something like a goldfish, and you had to feed it or it'd die.

So in this theoretical game, if you didn't check your goldfish within say, 48 hours, it would be dead the next time you opened up the game.

Using MMF2.

Any ideas on how you'd do this?

 
It's my humble opinion that Circy should never have been made Admin. (I don't remember why now.)

tetsuya_shino



Registered
  12/08/2004
Points
  491
12th June, 2013 at 12/06/2013 16:37:55 -

Hi. I don't have MMF2, but I think I can help. All you'd need to do is make your own timer using a counter. When the counter reaches a number you thought up in advance, then have another event that kills the goldfish.

As for making a counter, you could create a tiny active object with x number of looped animation frames. For example, you could have an active object that is 20 frames long, with an animation speed set to 1. Then, when the animation frame number = 20, add 1 to the 'kill fish counter'. When the kill fish counter equals 100, for example, then the event to kill the goldfish starts.

Well, that's how I'd do it in tgf. But you get the idea, and the might be an easier way in MMF2. Good luck.

 
n/a

s-m-r

Slow-Motion Riot

Registered
  04/06/2006
Points
  1078

Candle
12th June, 2013 at 12/06/2013 17:38:23 -

I agree with tetsuya. I also believe there's a way to fetch the real time and date within an application, which will allow your program to instantly update based on what time it is in the real world.

I also recommend you research the INI object, so you can record information stored from one play to the next.

A superb starting place for examples of what you may be seeking is Nivram's excellent site:

http://www.castles-of-britain.com/mmf2examples.htm

 
n/a

The_Antisony

At least I'm not Circy

Registered
  01/07/2002
Points
  1341

VIP MemberStarSnow
16th June, 2013 at 16/06/2013 16:18:41 -

You should be able to use the timestamp object and MMF2's built-in Left$, Right$, Mid$, and Val modifiers to pluck month, day, and year values, then you should be able to compare those using a fastloop every - say; 5 minutes? Drawback is that without some system to verify date manipulation, the user would be able to change the time and date under Windows and cheat in your game.

The only other method I could surmise is a timer-based system where you're either using MMF2's built-in timer (cringe) or creating your own that doesn't increment on every single code loop. Easiest way would be to use both. Using the built-in, every 1 minute, increment a new counter by 1. When the counter reaches 60, add 1 to second counter, set first counter to 0. When second counter reaches 24, add 1 to third counter; etc. It might be a better idea to use an active object and it's alternative values instead. Problem with that system is that it'll only count while a game is running. In other words, 24 hours wouldn't be equivalent to one real-life day, but rather 24 hours of constantly allowing the game to run - which could take place over four to five days of gameplay. Quit the game and the timer stops; naturally.

You could rectify that with an INI system that saves a full timestamp then compares it on game start up. Personally, I'd recommend using the Binary object instead as unencrypted INI files are easily manipulated. Depends on how much time you want to spend on game security.

 
ChrisD> Employer: Say, wanna see a magic trick?
ChrisD> Employee: Uhh… sure, boss.
ChrisD> Employer: Your job! It just disappeared! Pack your things and leave! Pretty good trick, huh?

Jenswa

Possibly Insane

Registered
  26/08/2002
Points
  2722
19th June, 2013 at 19/06/2013 13:45:09 -

So, now you actually need to feed your fish in your aquarium screensaver?

Use an object that let's you retrieve the full time specification, not sure if it's been built-in but otherwise use an extension object that does the work for you.

Next step is to save that time during your game and on the exit action of the game, write the time to a file with the ini-object. On start of the game retrieve current time, the time from the ini-object and compare those two.

I am using the word "game" but it can also be read as "application".

 
Image jenswa.neocities.org
   

Post Reply



 



Advertisement

Worth A Click