Is this fun code correct?

Plug-in related stuff can be discussed here.

Moderator: Plugin Moderators

User avatar
CommanderABab
AB
Reactions:
Posts: 11086
Joined: 07 Jun 2016, 21:12
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Is this fun code correct?

#1

Post by CommanderABab »

To build a different bus stop there, you would have to remove that spot, build the road again, then build the different bus stop. You can change the frames though. So add 5 sets of up gates.


former member wrote:
28 Jan 2018, 19:35
The plugin's fine and I have checked it with jsonlint.
But the fun code doesn't work.
What I want to accomplish is that when there's traffic at the bus stop tile then it changes to another bus stop and then if there's no traffic, it reverts back to the original building.

Help me, fun masters

Have a look at the code here
,
Yes, let's:

Code: Select all

[
  {
    "type": "bus stop",
    "width": 1.0,
    "height": 1.0,   //as former member said
    "influence noise": 2.0,
    "capacity": 10.0,
    "influence management": 5.0,
    "id": "leotollgatedown",     //and up ;)
    "frames": [
      {
        "bmp": "1 - Tollgate_Down_Finish.png",
        "w": 32.0,
        "h": 32.0,
        "count": "4"
      },
      {
        "bmp": "1 - Tollgate_Down_Finish.png",
        "w": 32.0,
        "h": 32.0,
        "count": "4"
      },
      {
        "bmp": "1 - Tollgate_Down_Finish.png",
        "w": 32.0,
        "h": 32.0,
        "count": "4"
      },
      {
        "bmp": "1 - Tollgate_Down_Finish.png",
        "w": 32.0,
        "h": 32.0,
        "count": "4"
      },
      {
        "bmp": "1 - Tollgate_Down_Finish.png",
        "w": 32.0,
        "h": 32.0,
        "count": "4"
      },
      //additional frames needed below
      {
        "bmp": "1 - Tollgate_Up_Finish.png",
        "w": 32.0,
        "h": 32.0,
        "count": "4"
      },
      {
        "bmp": "1 - Tollgate_Up_Finish.png",
        "w": 32.0,
        "h": 32.0,
        "count": "4"
      },
      {
        "bmp": "1 - Tollgate_Up_Finish.png",
        "w": 32.0,
        "h": 32.0,
        "count": "4"
      },
      {
        "bmp": "1 - Tollgate_Up_Finish.png",
        "w": 32.0,
        "h": 32.0,
        "count": "4"
      },
      {
        "bmp": "1 - Tollgate_Up_Finish.png",
        "w": 32.0,
        "h": 32.0,
        "count": "4"
      }
    ],
    "author": "TheOnly-LeoLeo- and Commander ABab",
    "title": "Classic Toll Gates",
    "text": "A couple of (decorative) tollgate for your expressway entrances or exits. But could also be a checking booth for ports or airports too.",
    "price": 230.0,
    "monthly price": 5.0,
    "power": 2.0,
    "fun": [
      // go up frames
      {"condition":{"type":"and",inner[{"type":"road usage","min": 1,"max": 100.0},{"type":"frame","frame":0}]},"actions": [{"type": "build","frame": 5}],"always":true,"ignore success":true},
      {"condition":{"type":"and",inner[{"type":"road usage","min": 1,"max": 100.0},{"type":"frame","frame":1}]},"actions": [{"type": "build","frame": 6}],"always":true,"ignore success":true},
      {"condition":{"type":"and",inner[{"type":"road usage","min": 1,"max": 100.0},{"type":"frame","frame":2}]},"actions": [{"type": "build","frame": 7}],"always":true,"ignore success":true},
      {"condition":{"type":"and",inner[{"type":"road usage","min": 1,"max": 100.0},{"type":"frame","frame":3}]},"actions": [{"type": "build","frame": 8}],"always":true,"ignore success":true},
      {"condition":{"type":"and",inner[{"type":"road usage","min": 1,"max": 100.0},{"type":"frame","frame":4}]},"actions": [{"type": "build","frame": 9}],"always":true,"ignore success":true},
      //go back down frames below
      {"condition":{"type":"and",inner[{"type":"road usage","min": 0,"max":0},{"type":"frame","frame":9}]},"actions": [{"type": "build","frame": 4}],"always":true,"ignore success":true},
      {"condition":{"type":"and",inner[{"type":"road usage","min":0,"max":0},{"type":"frame","frame":8}]},"actions": [{"type": "build","frame": 3}],"always":true,"ignore success":true},
      {"condition":{"type":"and",inner[{"type":"road usage","min": 0,"max":0},{"type":"frame","frame":7}]},"actions": [{"type": "build","frame": 2}],"always":true,"ignore success":true},
      {"condition":{"type":"and",inner[{"type":"road usage","min": 0,"max":0},{"type":"frame","frame":6}]},"actions": [{"type": "build","frame": 1}],"always":true,"ignore success":true},
      {"condition":{"type":"and",inner[{"type":"road usage","min": 0,"max":0},{"type":"frame","frame":5}]},"actions": [{"type": "build","frame": 0}],"always":true,"ignore success":true}
    ]
  }
]

User avatar
CommanderABab
AB
Reactions:
Posts: 11086
Joined: 07 Jun 2016, 21:12
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Is this fun code correct?

#2

Post by CommanderABab »

KoalaGuy wrote:
28 Jan 2018, 21:00
@🆎 I have edited your post to be more readable, it's annoying and hard to read when you put your text in a big "Most recent version is..." block.

Ok.

User avatar
CommanderABab
AB
Reactions:
Posts: 11086
Joined: 07 Jun 2016, 21:12
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Is this fun code correct?

#3

Post by CommanderABab »

[quote=CommanderABab post_id=82713 time=1517164801 user_id=487]
To build a different bus stop there, you would have to remove that spot, build the road again, then build the different bus stop. You can change the frames though. So add 5 sets of up gates.



Each condition, action:

Code: Select all

      {"condition":{"type":"and",inner[{"type":"road usage","min": 1,"max": 100.0},{"type":"frame","frame":0}]},"actions": [{"type": "build","frame": 5}],"always":true,"ignore success":true},
Looks like this expanded and has to be done 10 times to check for road usage with each of the 5 down frames and each of the up frames. If there is road usage, then the frame is switched to the corresponding opposite position.

Code: Select all

      {
      "condition":
        {
          "type":"and",inner[
            {
              "type":"road usage","min": 1,"max": 100.0
              },   
              {
                "type":"frame","frame":0
              }
            ]
          },
          "actions": [
             {
               "type": "build","frame": 5
             }
           ],
           "always":true,"ignore success":true
         },
If there is road usage, then the gate will go up.
If thrre is no road usage, then the gate will go down.

It's your idea!

It's much better than removing the road and bus stop, (which is what remove would do) and then replacing the road and placing another different bus stop. I don't even know if that would currently be possible via plugin.

User avatar
CommanderABab
AB
Reactions:
Posts: 11086
Joined: 07 Jun 2016, 21:12
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Is this fun code correct?

#4

Post by CommanderABab »

former member wrote:
28 Jan 2018, 22:11
Thanks but can you explain everything.
I wanna know how to do it too.
CommanderABab
Also edit it please without the red parts.
hehe, you're joking right? The comments are there to help you, not me!

Post Reply Previous topicNext topic

Return to “Plug-In Discussion”