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

#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 2488 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

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

Platform

Re: Code Help

#41

Post by Barky »

Is it the height and width of go kart maybe?

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

Plugin Creator

Platform

Re: Code Help

#42

Post by CommanderABab »

You dont need quotes around 512 and 1 there. Ok, so you have 1 tiny car within a radius of 512. Might take a while to see it.

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

Platform

Re: Code Help

#43

Post by Barky »

But is there a way to make it automatically spawn and roam around (only on the track) like emergency vehicleS?

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

Plugin Creator

Platform

Re: Code Help

#44

Post by CommanderABab »

Barky wrote:
02 Jul 2017, 21:48
But is there a way to make it automatically spawn and roam around (only on the track) like emergency vehicleS?
Yes there is!

Please search the documentation. Keywords flags, x flags, own cars, spawn. :space
:fire

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

Platform

Re: Code Help

#45

Post by Lobby »

Your rally cars cannot drive on your rally track because you didn't set flags for them. You might add

Code: Select all

"flag user5": true,
"flag normal": false,
to the car, too.

For bigger cities it might help to add

Code: Select all

"car local only":true
as described here to your building so a valid target building is always found.

Post Reply Previous topicNext topic

Return to “Plug-In Discussion”