Page 1 of 2

Date dependent fun condition

Posted: 22 Oct 2017, 20:54
by Lobby
Since 369 there's a condition for fun to check for a specific date/range.

To do so, use condition type:"date" and define a range using min and max (or z if you want a specific day instead of a range of days). For example, z:0 would mean the 1st day of each year (0 <-> 1 because of how we count in computer science). Here's a sample code that triggers a notification:

Code: Select all

[
  {
    "id":"$notify_test01","type":"notification","text":"I AM SO <..>","frames":[{"steal":"$anim_people_source01","frame":0}]
  },
  
  {
    "id":"$invisible building","type":"decoration","hidden":true,"width":1,"height":1,"frames":[null],
    "random fun":[
      {
        "condition": {
          "type": "date",
          "z": 7  // 8th day of the year
        },
        "actions": [
          {
            "type": "notify",
            "id": "$notify_test01"
          }
        ]
      }
    ]
  }
]
In case you want the condition to be true each week for example just use frame:7. By default frame has a value of 12*30=a year.

Re: Date dependent fun condition (369)

Posted: 22 Oct 2017, 21:12
by CommanderABab
Blue animals be gone! :)

May

Code: Select all

"p":1
still be used in the actions?

Re: Date dependent fun condition (369)

Posted: 22 Oct 2017, 21:41
by Lobby
Yes, they work independently :bc

Re: Date dependent fun condition (369)

Posted: 22 Oct 2017, 21:43
by Josh
Great!

Re: Date dependent fun condition (369)

Posted: 22 Oct 2017, 21:56
by Josh
Is it possible to have a code, when your map surpasses a certain amount of inhabitants a notification is given?

Re: Date dependent fun condition (369)

Posted: 23 Oct 2017, 20:46
by CommanderABab
Use

Code: Select all

"once":true
where you define the notification.

Re: Date dependent fun condition (369)

Posted: 24 Oct 2017, 14:27
by CommanderABab
To use a random notification from those you have defined:
Lobby wrote:
22 Oct 2017, 20:54
...

Code: Select all

[
  {
    "id":"$notify_test01","type":"notification","text":"I AM SO <..>","frames":[{"steal":"$anim_people_source01","frame":0}],
    "id":"$notify_test02",...""   ""
    ...
  },
  
  {
    "id":"$invisible building","type":"decoration","hidden":true,"width":1,"height":1,"frames":[null],
    "(random )fun":[
       {"actions": [
          {
            "type": "notify",
            "id": "$notify_test01"
          },
          "p":x
        },
      {"actions": [
          {
            "type": "notify",
            "id": "$notify_test02"
          },
          "p":x
        },
        ...
          
        ]
      }
    ]
  }
]
...
Where x = 1 ÷ (number of different notifications).

Re: Date dependent fun condition (369)

Posted: 25 Oct 2017, 12:14
by CommanderABab
Then add one more action that doesn't have a notification! :)

Re: Date dependent fun condition (369)

Posted: 25 Oct 2017, 12:35
by Lobby
How about this?

Code: Select all

[
  ...
  {
    "id":"$invisible building","type":"decoration","hidden":true,"width":1,"height":1,"frames":[null],
    "random fun":[
       {"actions": [
          {
            "type": "notify",
            "id": "$notify_test01"
          }
        ],  // Actions array is ending here
        "p":x  // Probability
      },
      {"actions": [  // Here begins a new transition
          {
            "type": "notify",
            "id": "$notify_test01"
          }
        ],
        "p":x
      },
      ...
    ]
  }
]
Note that "p" belongs into the transition object and not into the actions array.

Re: Date dependent fun condition (369)

Posted: 25 Oct 2017, 12:55
by Lobby
:bc

Re: Date dependent fun condition

Posted: 31 Jan 2018, 09:32
by 22Alpha
I think I've asked this before but maybe there is an update about it. Does this fun activation have duration coding now? I mean action would trigger within a duration of time like 3 days, 5 days.

Re: Date dependent fun condition

Posted: 31 Jan 2018, 16:40
by Lobby
Have you tried this? :json

Code: Select all

"condition": {
  "type": "date",
  "min": 0,
  "max": 2,   // Trigger at days 0, 1, 2
  "frame": 8  // Overall time frame of 3 + 5 = 8 days
},

Re: Date dependent fun condition

Posted: 01 Feb 2018, 06:04
by 22Alpha
Lobby wrote:
31 Jan 2018, 16:40
Have you tried this? :json

Code: Select all

"condition": {
  "type": "date",
  "min": 0,
  "max": 2,   // Trigger at days 0, 1, 2
  "frame": 8  // Overall time frame of 3 + 5 = 8 days
},
Not yet, but will try! That's something new :bc Thanks!

Re: Date dependent fun condition

Posted: 01 Feb 2018, 08:30
by 22Alpha
@Lobby , I think I phrased it wrong. It was supposed to be 3 or 5 days. Does the code would remain the same?

A specific example would be:

If I build building A, after 5 days building B will automatically be replaced.

Re: Date dependent fun condition

Posted: 01 Feb 2018, 09:53
by CommanderABab
Use

Code: Select all

"min":5,"max":7,
then.

Re: Date dependent fun condition

Posted: 01 Feb 2018, 10:21
by 22Alpha
Without the "frames": line anymore?

Re: Date dependent fun condition

Posted: 01 Feb 2018, 12:18
by CommanderABab
Yes with the frames line, I just showed what you want to change.

Re: Date dependent fun condition

Posted: 01 Feb 2018, 12:40
by 22Alpha
Looks like I'm one very confused guy. Maybe trying it into plugin would help me understand more. Thank you for all your help guys!

Re: Date dependent fun condition

Posted: 04 Feb 2018, 01:33
by Lobby
I'm not sure what you mean by 3 or 5 days. Can you make an explicit example?

Re: Date dependent fun condition

Posted: 04 Feb 2018, 02:33
by 22Alpha
Here:

If I build building A,

after 5 days,

building A will be removed, then building B will replace it.