Code Help

Plug-in related stuff can be discussed here.

Moderator: Plugin Moderators

User avatar
Barky
TheoTown Cartographer
Reactions:
Posts: 2056
Joined: 17 Apr 2017, 22:13
Location: Ireland
Plugins: Showcase Store

Platform

Re: Code Help

#21

Post by Barky »

Not in pt, what do I do? Re-install it?

User avatar
Lobby
Developer
Reactions:
Posts: 3705
Joined: 26 Oct 2008, 12:34
Plugins: Showcase Store
Version: Beta

Platform

Re: Code Help

#22

Post by Lobby »

Your code doesn't follow the syntax I suggested, which is crucial for multiple plugins within one file. There are basic rules in JSON you have to obey.

Radius -1 is not supported as it's a lot of effort to find a target building on the whole map. However you can use a big value (like 512) in case you want the whole map as target.

Most of your questions are answered somewhere in the documentation, don't expect people to be your search engine for free.

User avatar
Barky
TheoTown Cartographer
Reactions:
Posts: 2056
Joined: 17 Apr 2017, 22:13
Location: Ireland
Plugins: Showcase Store

Platform

Re: Code Help

#23

Post by Barky »

Ok,

I changed to

Code: Select all

[
{
car
}
]
[
{
building
}
]
[
{
road
{
[
And changed radius to 512, re downloaded it, still doesnt show up

User avatar
Lobby
Developer
Reactions:
Posts: 3705
Joined: 26 Oct 2008, 12:34
Plugins: Showcase Store
Version: Beta

Platform

Re: Code Help

#24

Post by Lobby »

You haven't tried to put your code into https://jsonlint.com/ have you?

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

Plugin Creator

Platform

Re: Code Help

#25

Post by CommanderABab »

Lobby wrote:
02 Jul 2017, 20:10
You haven't tried to put your code into https://jsonlint.com/ have you?
It's really helpful. It often pinpoints the (first) error at the line number in the code.

User avatar
Barky
TheoTown Cartographer
Reactions:
Posts: 2056
Joined: 17 Apr 2017, 22:13
Location: Ireland
Plugins: Showcase Store

Platform

Re: Code Help

#26

Post by Barky »

I did it and this came up but I dont know how to fix

Code: Select all

Error: Parse error on line 4:
...ar",	"frames": [		("bmp": "RallyCar.pn
---------------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', ']', got 'undefined'
This is probaly obvious to you

User avatar
Barky
TheoTown Cartographer
Reactions:
Posts: 2056
Joined: 17 Apr 2017, 22:13
Location: Ireland
Plugins: Showcase Store

Platform

Re: Code Help

#27

Post by Barky »

Ok I didnt notice

This may not be new to you but it is to me, alright

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

Plugin Creator

Platform

Re: Code Help

#28

Post by CommanderABab »

:space
1284.gif
1284.gif (23.51 KiB) Viewed 2490 times
:fire

User avatar
Barky
TheoTown Cartographer
Reactions:
Posts: 2056
Joined: 17 Apr 2017, 22:13
Location: Ireland
Plugins: Showcase Store

Platform

Re: Code Help

#29

Post by Barky »

Code: Select all

Error: Parse error on line 11:
...	}],	"v2": true}][{	"id": "$garage.r
--------------------^
Expecting 'EOF', '}', ',', ']', got '['
I dont understand why there is an error, the brackets are fine and I dont see anything rong with v2

Yes I know its probaly obvious or easy to understand but gimme a break :o

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

Plugin Creator

Platform

Re: Code Help

#30

Post by CommanderABab »

Screenshot_20170702-135517.jpg
Expecting a comma, there between ][.

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

Plugin Creator

Platform

Re: Code Help

#31

Post by CommanderABab »

V2 is just the start of the line.

User avatar
Barky
TheoTown Cartographer
Reactions:
Posts: 2056
Joined: 17 Apr 2017, 22:13
Location: Ireland
Plugins: Showcase Store

Platform

Re: Code Help

#32

Post by Barky »

But if I add comma all I get is

Code: Select all

Error: Parse error on line 11:
...	}],	"v2": true}], [{	"id": "$garage
--------------------^
Expecting 'EOF', got ','
It's confusing to me :(

User avatar
Lobby
Developer
Reactions:
Posts: 3705
Joined: 26 Oct 2008, 12:34
Plugins: Showcase Store
Version: Beta

Platform

Re: Code Help

#33

Post by Lobby »

Lobby wrote:
02 Jul 2017, 17:59

Code: Select all

[
  {
    // Car
  },
  {
    // Building
  }
]
A JSON file can either contain a top level object {} or a top level array []. For plugins we use a top level array, therefore our base structure looks like

Code: Select all

[
...
]
Within this top level array we define objects separated by commas.

For this reason something like

Code: Select all

[
...
],
[
...
]
is not valid JSON syntax.

User avatar
Barky
TheoTown Cartographer
Reactions:
Posts: 2056
Joined: 17 Apr 2017, 22:13
Location: Ireland
Plugins: Showcase Store

Platform

Re: Code Help

#34

Post by Barky »

Thank you Lobby, I understand now!

User avatar
Barky
TheoTown Cartographer
Reactions:
Posts: 2056
Joined: 17 Apr 2017, 22:13
Location: Ireland
Plugins: Showcase Store

Platform

Re: Code Help

#35

Post by Barky »

Ok I am officially sick of this

JSONLint says it's valid
I see no problem

Wont work

Will I pm link or?

User avatar
Barky
TheoTown Cartographer
Reactions:
Posts: 2056
Joined: 17 Apr 2017, 22:13
Location: Ireland
Plugins: Showcase Store

Platform

Re: Code Help

#36

Post by Barky »

Code: Select all

[{
		"id": "Rallycar00",
		"type": "car",
		"frames": [{
			"bmp": "RallyCar.png",
			"w": 28,
			"h": 10,
			"count": 4
		}],
		"v2": true
	}, {
		"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": "512",
		"car count": "1"
	},
	{
		"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
	}
]
JSONLint says this is valid

User avatar
Barky
TheoTown Cartographer
Reactions:
Posts: 2056
Joined: 17 Apr 2017, 22:13
Location: Ireland
Plugins: Showcase Store

Platform

Re: Code Help

#37

Post by Barky »

Nope

Downloaded Zip
Unlocked Zip
Put it in plug in folder
Went in game
Nothing there

It doesnt crash or anything it doesnt show up in game or in "pt"
I will pm you a link

User avatar
Barky
TheoTown Cartographer
Reactions:
Posts: 2056
Joined: 17 Apr 2017, 22:13
Location: Ireland
Plugins: Showcase Store

Platform

Re: Code Help

#38

Post by Barky »

I sent you link in PM
See for yourself

User avatar
Barky
TheoTown Cartographer
Reactions:
Posts: 2056
Joined: 17 Apr 2017, 22:13
Location: Ireland
Plugins: Showcase Store

Platform

Re: Code Help

#39

Post by Barky »

facepalm

Thats how it saved automatically

Thanks :D

User avatar
Barky
TheoTown Cartographer
Reactions:
Posts: 2056
Joined: 17 Apr 2017, 22:13
Location: Ireland
Plugins: Showcase Store

Platform

Re: Code Help

#40

Post by Barky »

Well its finally in game, however it isnt spawning the kart

Am I missing something in code?
It should spawn then randomly go on the track

Post Reply Previous topicNext topic

Return to “Plug-In Discussion”