News: Welcome back to Bullworth! If you haven't already, you will need to reset your password..


Author Topic: LuaC compiling error  (Read 5556 times)

0 Members and 1 Guest are viewing this topic.

Offline AWiseMelon

  • Jr. Member
  • **
  • Posts: 42
  • Gender: Male
    • View Profile
LuaC compiling error
« on: April 01, 2016, 07:50:15 PM »
When I try to compile a script using LuaC it brings this up:

WeaponSelector.lua:16: `}' expected (to close `{' at line 14) near `{'

What have I done wrong?

Offline Bellic19

  • Sr. Member
  • ***
  • Posts: 933
  • Gender: Male
    • View Profile
Re: LuaC compiling error
« Reply #1 on: April 01, 2016, 08:08:25 PM »
Could you post the code here? Or if you don't want to put the code up publicly add me on steam and I'll fix it:
http://steamcommunity.com/id/gembo555

Offline AWiseMelon

  • Jr. Member
  • **
  • Posts: 42
  • Gender: Male
    • View Profile
Re: LuaC compiling error
« Reply #2 on: April 01, 2016, 08:54:23 PM »
Sure, I'll post it here, it's DaBOSS' tutorial script:

-- Weapon Selector
local weaponSelect = 1

MissionSetup = function()
  AreaTransitionXYZ(0,270,-110,6)
  F_SetupWeapons()
end

function MissionCleanup()
 
end

function F_SetupWeapons()
  weapons = {
    {name = "Apple",model = 310}
    {name = "Banana",model = 358}
    {name = "Baseball",model = 302}
    {name = "Basket Ball",model = 381}
    {name = "Bat",model = 300}
    {name = "Big Firework",model = 397}
    {name = "Books 1",model = 405}
    {name = "Books 2",model = 413}
    {name = "Books 3",model = 414}
    {name = "Books 4",model = 415}
    {name = "Books 5",model = 416}
    {name = "Brick",model = 311}
    {name = "Broom",model = 377}
    {name = "Camera",model = 426}
    {name = "Dead Rat",model = 346}
    {name = "Devil Fork",model = 409}
    {name = "Dish",model = 338}
    {name = "Egg",model = 312}
    {name = "Fire Extinguisher",model = 326}
    {name = "Firework",model = 301}
    {name = "Flowers",model = 359}
    {name = "Football",model = 331}
    {name = "Football (Bomb)",model = 400}
    {name = "Frisbee",model = 335}
    {name = "Gold Pipe",model = 418}
    {name = "Itchy Powder",model = 394}
    {name = "Kick Me",model = 372}
    {name = "Lunch Tray",model = 348}
    {name = "Marbles",model = 349}
    {name = "News Roll",model = 320}
    {name = "Pinky Wand",model = 410}
    {name = "Plate",model = 355}
    {name = "Poison Gun",model = 395}
    {name = "Rocket Launcher",model = 307}
    {name = "Rubber Band",model = 325}
    {name = "Shield",model = 387}
    {name = "Metal Plate",model = 360}
    {name = "Skateboard",model = 437}
    {name = "Sledge Hammer",model = 324}
    {name = "Slingshot",model = 303}
    {name = "Snowball",model = 313}
    {name = "Snowball 2",model = 330}
    {name = "Soccer Ball",model = 329}
    {name = "Spray Can",model = 321}
    {name = "Spud Gun",model = 305}
    {name = "Stink Bomb",model = 309}
    {name = "Super Slingshot",model = 306}
    {name = "Super Spud Gun",model = 396}
    {name = "Trash Lid",model = 315}
    {name = "Trophy",model = 385}
    {name = "Umbrella",model = 404}
    {name = "Vase 1",model = 354}
    {name = "Vase 2",model = 353}
    {name = "Vase 3",model = 345}
    {name = "Water Baloon",model = 383}
    {name = "Water Pipe",model = 342}
    {name = "Whip",model = 411}
    {name = "Wood Paddle",model = 357}
    {name = "Wood Plank",model = 323}
    {name = "Yardstick",model = 299}
  }
end

function main()
  repeat
    F_WeaponSelect()
 Wait(0)
  until not Alive
end

F_WeaponSelect = function()
  if IsButtonBeingPressed(0,0) and weaponSelect > 1 then
    weaponSelect = weaponSelect - 1
  elseif IsButtonBeingPressed(1,0) and weaponSelect < table.getn(weapons) then
    weaponSelect = weaponSelect + 1
  elseif IsButtonBeingPressed(3,0) then
    PedSetWeapon(gPlayer,weapons[weaponSelect].model,50)
  end
  TextPrintString("Weapon Selector\n\nWeapon: "..weapons[weaponSelect].name,1,1)
end

Offline Unknownsoldier

  • Hero Member
  • ****
  • Posts: 2,773
    • View Profile
Re: LuaC compiling error
« Reply #3 on: April 02, 2016, 02:01:09 PM »
Gembo doesn't know how to use tables xD. I fixed it for you.

Here u go

Code: [Select]
-- Weapon Selector
local weaponSelect = 1

MissionSetup = function()
  AreaTransitionXYZ(0,270,-110,6)
  F_SetupWeapons()
end

function MissionCleanup()
 
end

function F_SetupWeapons()
  weapons = {
    {name = "Apple",model = 310},
    {name = "Banana",model = 358},
    {name = "Baseball",model = 302},
    {name = "Basket Ball",model = 381},
    {name = "Bat",model = 300},
    {name = "Big Firework",model = 397},
    {name = "Books 1",model = 405},
    {name = "Books 2",model = 413},
    {name = "Books 3",model = 414},
    {name = "Books 4",model = 415},
    {name = "Books 5",model = 416},
    {name = "Brick",model = 311},
    {name = "Broom",model = 377},
    {name = "Camera",model = 426},
    {name = "Dead Rat",model = 346},
    {name = "Devil Fork",model = 409},
    {name = "Dish",model = 338},
    {name = "Egg",model = 312},
    {name = "Fire Extinguisher",model = 326},
    {name = "Firework",model = 301},
    {name = "Flowers",model = 359},
    {name = "Football",model = 331},
    {name = "Football (Bomb)",model = 400},
    {name = "Frisbee",model = 335},
    {name = "Gold Pipe",model = 418},
    {name = "Itchy Powder",model = 394},
    {name = "Kick Me",model = 372},
    {name = "Lunch Tray",model = 348},
    {name = "Marbles",model = 349},
    {name = "News Roll",model = 320},
    {name = "Pinky Wand",model = 410},
    {name = "Plate",model = 355},
    {name = "Poison Gun",model = 395},
    {name = "Rocket Launcher",model = 307},
    {name = "Rubber Band",model = 325},
    {name = "Shield",model = 387},
    {name = "Metal Plate",model = 360},
    {name = "Skateboard",model = 437},
    {name = "Sledge Hammer",model = 324},
    {name = "Slingshot",model = 303},
    {name = "Snowball",model = 313},
    {name = "Snowball 2",model = 330},
    {name = "Soccer Ball",model = 329},
    {name = "Spray Can",model = 321},
    {name = "Spud Gun",model = 305},
    {name = "Stink Bomb",model = 309},
    {name = "Super Slingshot",model = 306},
    {name = "Super Spud Gun",model = 396},
    {name = "Trash Lid",model = 315},
    {name = "Trophy",model = 385},
    {name = "Umbrella",model = 404},
    {name = "Vase 1",model = 354},
    {name = "Vase 2",model = 353},
    {name = "Vase 3",model = 345},
    {name = "Water Baloon",model = 383},
    {name = "Water Pipe",model = 342},
    {name = "Whip",model = 411},
    {name = "Wood Paddle",model = 357},
    {name = "Wood Plank",model = 323},
    {name = "Yardstick",model = 299},
  }
end

function main()
  repeat
    F_WeaponSelect()
 Wait(0)
  until not Alive
end

F_WeaponSelect = function()
  if IsButtonBeingPressed(0,0) and weaponSelect > 1 then
    weaponSelect = weaponSelect - 1
  elseif IsButtonBeingPressed(1,0) and weaponSelect < table.getn(weapons) then
    weaponSelect = weaponSelect + 1
  elseif IsButtonBeingPressed(3,0) then
    PedSetWeapon(gPlayer,weapons[weaponSelect].model,50)
  end
  TextPrintString("Weapon Selector\n\nWeapon: "..weapons[weaponSelect].name,1,1)
end

Offline AWiseMelon

  • Jr. Member
  • **
  • Posts: 42
  • Gender: Male
    • View Profile
Re: LuaC compiling error
« Reply #4 on: April 02, 2016, 02:12:51 PM »
Hmmm, for some reason the script put the game on an endless loading screen when I interacted with the arcade machine.

Offline DaBOSS54320

  • Hero Member
  • ****
  • Posts: 3,398
  • Gender: Female
    • View Profile
Re: LuaC compiling error
« Reply #5 on: April 02, 2016, 07:15:23 PM »
I'll look into this. I see that your script is missing commas for separating each of the weapon tables, and you say there is an infinite loading screen. I am pretty sure I tested it before but maybe I need to fix something. My bad.

Offline AWiseMelon

  • Jr. Member
  • **
  • Posts: 42
  • Gender: Male
    • View Profile
Re: LuaC compiling error
« Reply #6 on: April 02, 2016, 07:21:07 PM »
I think the infinite loading screen is my bad actually, I accidently names the file ArcRace.lur instead of ArcRace1.lur  :blank:

Offline Unknownsoldier

  • Hero Member
  • ****
  • Posts: 2,773
    • View Profile
Re: LuaC compiling error
« Reply #7 on: April 03, 2016, 04:01:48 AM »
I'll look into this. I see that your script is missing commas for separating each of the weapon tables, and you say there is an infinite loading screen. I am pretty sure I tested it before but maybe I need to fix something. My bad.
niqquh i already fixt the commas

and yes it has to be ArcRace1.lur lol
« Last Edit: April 03, 2016, 04:03:22 AM by Unknownsoldier »

Offline DaBOSS54320

  • Hero Member
  • ****
  • Posts: 3,398
  • Gender: Female
    • View Profile
Re: LuaC compiling error
« Reply #8 on: April 03, 2016, 03:38:51 PM »
I know you did but I was explaining to him what you did, since you didn't care to.