Code Help

Plug-in related stuff can be discussed here.

Moderator: Plugin Moderators

Barky
TheoTown Cartographer
Reactions:
Posts: 2074
Joined: Mon Apr 17, 2017 22:13
Location: Ireland
Plugins: Show

Platform

Code Help

#1

Post by Barky »

Code: Select all

[
    {
	 "id":"$garage.rally.unique.id.dc00",
	 "type":"decoration",
	 "author":"Barky",
	 "width":1,
	 "height":1,
	 "frames":[{"bmp":"RallyStation.png"}],
	 "needs road" false
	 "needs water" true
	 "price" 1000T
	 "monthly price" 10T
	 }
]
Now this is my first time, I've written this on Notepad++ and I'm pretty sure its incorrect, I will add more just wnt to check if this is right?

User avatar
Josh
Graphic designer
Reactions:
Posts: 2218
Joined: Sat Mar 11, 2017 19:20
Location: The Netherlands
Plugins: Show
Version: Beta

Platform

Plugin Creator

Re: Code Help

#2

Post by Josh »

Did you forget the : at the end?
Proud TheoTown player sinds update 1.1.50

Creator of Aldorria, Covinton Empire, West Country, Sunnydale

Save nature, before it kills you🌲

Barky
TheoTown Cartographer
Reactions:
Posts: 2074
Joined: Mon Apr 17, 2017 22:13
Location: Ireland
Plugins: Show

Platform

Re: Code Help

#3

Post by Barky »

So other than that its ok?

Barky
TheoTown Cartographer
Reactions:
Posts: 2074
Joined: Mon Apr 17, 2017 22:13
Location: Ireland
Plugins: Show

Platform

Re: Code Help

#4

Post by Barky »

Code: Select all

[
    {
	 "id":"$garage.rally.unique.id.dc00",
	 "type":"decoration",
	 "author":"Barky",
	 "width":1,
	 "height":1,
	 "frames":[{"bmp":"RallyStation.png"}],
	 "needs road":false,
	 "needs water":true,
	 "price":1000,
	 "monthly price":10,
	}
]
Better?

Barky
TheoTown Cartographer
Reactions:
Posts: 2074
Joined: Mon Apr 17, 2017 22:13
Location: Ireland
Plugins: Show

Platform

Re: Code Help

#5

Post by Barky »

Ok and I want it to spawn cars, so I write the seperate code for car then add it here. But where do I put the json for car hen done?

User avatar
Lobby
Developer
Reactions:
Posts: 3596
Joined: Sun Oct 26, 2008 12:34
Plugins: Show
Version: Beta

Platform

Re: Code Help

#6

Post by Lobby »

JSON is standardized, so you can check for example here whether it's valid JSON code.

TheoTown won't accept invalid JSON code, so it's useful to check the code first with such tools.

About your car, I recommend to define it within the same JSON file so you can ensure that it's defined first (which is necessary, otherwise you cannot reference to it). May look like

Code: Select all

[
  {
    // Car
  },
  {
    // Building
  }
]
=^._.^= ∫

User avatar
CommanderABab
AB
Reactions:
Posts: 8832
Joined: Tue Jun 07, 2016 21:12
Plugins: Show
Version: Beta

Platform

Plugin Creator

Re: Code Help

#7

Post by CommanderABab »

Code: Select all

[
    {
	 "id":"$garage.rally.unique.id.dc00",
	 "type":"decoration",
	 "author":"Barky",
	 "width":1,
	 "height":1,
	 "frames":[{"bmp":"RallyStation.png"}],
	 "needs road" :false,
	 //"needs water": true, //unless you want it on shoreline
	 "price" :1000,//very expensive decoration!
	 "monthly price" :10
	 }
]
Image

Barky
TheoTown Cartographer
Reactions:
Posts: 2074
Joined: Mon Apr 17, 2017 22:13
Location: Ireland
Plugins: Show

Platform

Re: Code Help

#8

Post by Barky »

Thanks Lobby

Commander it is supposed to spawn go karts which are expensive :P
Does needs water mean water as in pipes?

User avatar
CommanderABab
AB
Reactions:
Posts: 8832
Joined: Tue Jun 07, 2016 21:12
Plugins: Show
Version: Beta

Platform

Plugin Creator

Re: Code Help

#9

Post by CommanderABab »

No, "needs water" means at least one tile needs to be on water.
Image

Barky
TheoTown Cartographer
Reactions:
Posts: 2074
Joined: Mon Apr 17, 2017 22:13
Location: Ireland
Plugins: Show

Platform

Re: Code Help

#10

Post by Barky »

Code: Select all

[
    {
	"id":"Rallycar00",
	"type":"car",
	"frames":[
	("bmp":"RallyCar.png","w":,"h":,"count":}//what is height and width of go kart?//
	],
	"v2":true
	}
]






[
    {
	 "id":"$garage.rally.unique.id.dc00",
	 "type":"decoration",
	 "author":"Barky",
	 "width":1,
	 "height":1,
	 "frames":[{"bmp":"RallyStation.png"}],
	 "needs road":false,
	  "price":1000,
	 "monthly price":10
	}
]

Barky
TheoTown Cartographer
Reactions:
Posts: 2074
Joined: Mon Apr 17, 2017 22:13
Location: Ireland
Plugins: Show

Platform

Re: Code Help

#11

Post by Barky »

And I know I need to add code for car to spawn, just checking that car code is ok and want to know heigh and width

Barky
TheoTown Cartographer
Reactions:
Posts: 2074
Joined: Mon Apr 17, 2017 22:13
Location: Ireland
Plugins: Show

Platform

Re: Code Help

#12

Post by Barky »

It says in tutorial about heigh and width

Its just the standard go kart image except only 1 type (only red, no other colours)

Barky
TheoTown Cartographer
Reactions:
Posts: 2074
Joined: Mon Apr 17, 2017 22:13
Location: Ireland
Plugins: Show

Platform

Re: Code Help

#13

Post by Barky »

RallyCar.png
RallyCar.png (407 Bytes) Viewed 1199 times

Barky
TheoTown Cartographer
Reactions:
Posts: 2074
Joined: Mon Apr 17, 2017 22:13
Location: Ireland
Plugins: Show

Platform

Re: Code Help

#14

Post by Barky »

Code: Select all

[
    {
	"id":"Rallycar00",
	"type":"car",
	"frames":[
	("bmp":"RallyCar.png","w":,"h":,"count":}
	],
	"v2":true
	}
]


[
    {
	 "id":"$garage.rally.unique.id.dc00",
	 "type":"decoration",
	 "author":"Barky",
	 "width":1,
	 "height":1,
	 "frames":[{"bmp":"RallyStation.png"}],
	 "needs road":false,
	 "price":1000,
	 "monthly price":10
	 "car":"Rallycar00",
	 "car radius":"-1",
	 "car count":"1"
	}
]
If I put radius -1 will that make it go as far as it wants?
Whats the width and height of go karts?

Barky
TheoTown Cartographer
Reactions:
Posts: 2074
Joined: Mon Apr 17, 2017 22:13
Location: Ireland
Plugins: Show

Platform

Re: Code Help

#15

Post by Barky »

Code: Select all

[
    {
	"id":"Rallycar00",
	"type":"car",
	"frames":[
	("bmp":"RallyCar.png","w":,"h":,"count":}
	],
	"v2":true
	}
]

[
    {
	"id":"RallyTrack001",
	"type":"road",
	"flag user5":true,
	"flag normal":false
	"author":"Barky",
	"level":1,
	"width":1,
	"height":1,
	"frames":[{"bmp":"RallyTrack.png","w":32,"h":16,"count":16}], 
	"speed":5.0,
	"price":50,
	"monthly price":5,
	"allow transfer":false,
	"connectable":false,
	"allow bus":false
	}
]

[
    {
	 "id":"$garage.rally.unique.id.dc00",
	 "type":"decoration",
	 "author":"Barky",
	 "width":1,
	 "height":1,
	 "frames":[{"bmp":"RallyStation.png"}],
	 "needs road":false,
	 "price":1000,
	 "monthly price":10
	 "car":"Rallycar00",
	 "car radius":"-1",
	 "car count":"1"
	}
]
Added the road code, somebody please answer my previous questions

User avatar
CommanderABab
AB
Reactions:
Posts: 8832
Joined: Tue Jun 07, 2016 21:12
Plugins: Show
Version: Beta

Platform

Plugin Creator

Re: Code Help

#16

Post by CommanderABab »

W and h depend on the image which looks like?. Count would be 4.
Image

Barky
TheoTown Cartographer
Reactions:
Posts: 2074
Joined: Mon Apr 17, 2017 22:13
Location: Ireland
Plugins: Show

Platform

Re: Code Help

#17

Post by Barky »

UI downloaded it but it isn't showing up in game
Also how do I add description and will my code make it only go on the rally track?

Barky
TheoTown Cartographer
Reactions:
Posts: 2074
Joined: Mon Apr 17, 2017 22:13
Location: Ireland
Plugins: Show

Platform

Re: Code Help

#18

Post by Barky »

Yes I was jsut asking,

What about it not showing up in game?

Barky
TheoTown Cartographer
Reactions:
Posts: 2074
Joined: Mon Apr 17, 2017 22:13
Location: Ireland
Plugins: Show

Platform

Re: Code Help

#19

Post by Barky »

Well I asked if that made it go as far as it wants and got no answer :?

And even then shouldnt road show up?

Barky
TheoTown Cartographer
Reactions:
Posts: 2074
Joined: Mon Apr 17, 2017 22:13
Location: Ireland
Plugins: Show

Platform

Re: Code Help

#20

Post by Barky »

Code: Select all

[
    {
	"id":"Rallycar00",
	"type":"car",
	"frames":[
	("bmp":"RallyCar.png","w":28:,"h":10,"count":4}
	],
	"v2":true
	}
]

[
    {
	"id":"RallyTrack001",
	"type":"road",
	"flag user5":true,
	"flag normal":false
	"author":"Barky",
	"text":"A track for your rallies!",
	"level":1,
	"width":1,
	"height":1,
	"frames":[{"bmp":"RallyTrack.png","w":32,"h":16,"count":16}], 
	"speed":5.0,
	"price":50,
	"monthly price":5,
	"allow transfer":false,
	"connectable":false,
	"allow bus":false
	}
]

[
    {
	 "id":"$garage.rally.unique.id.dc00",
	 "type":"sport",
	 "author":"Barky",
	 "text":"A small compund for your rally-kart, must be built next to track",
	 "width":1,
	 "height":1,
	 "frames":[{"bmp":"RallyStation.png"}],
	 "needs road":false,
	 "price":1000,
	 "monthly price":10
	 "car":"Rallycar00",
	 "car radius":"1000",
	 "car count":"1"
	}
]
Ok,
Will this spawn a single rally car if the garage is built beside the track?
Will only the rally car use the track?
Will the rally car not go on any track?
Will the track be in road section and garage in sport?
Is everything correct?

Post Reply Previous topicNext topic

Return to “Plug-In Discussion”