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


Author Topic: Lua codes not working?  (Read 8074 times)

0 Members and 1 Guest are viewing this topic.

Offline Phap

  • Full Member
  • ***
  • Posts: 216
  • Gender: Male
    • View Profile
Lua codes not working?
« on: June 16, 2013, 01:17:37 PM »
I try to add these moves to my code but it doesn't work, the compiler says
luac: luascript.lua :89: 'end' expected <to close 'function' at line 7> near '<eof>'
This is my code:

GlobalImportScript("SObjTest.lua")
ImportScript("Library/LibTable.lua")
ImportScript("SZone.lua")

  l_0_0 = 60

MissionSetup = function()
  local l_1_0 = 270
  local l_1_1 = -110
  local l_1_2 = 6.4000000953674
  AreaTransitionXYZ(0, l_1_0, l_1_1, l_1_2)

  l_0_3 = PedCreatePoint(28, POINTLIST._BEGGINING, 1) -- Ricky
  l_0_4 = PedCreatePoint(26, POINTLIST._BEGGINING, 1) -- Lucky

   PedSetActionTree(gPlayer, "/Global/G_Striker_A", "Act/Anim/G_Striker_A.act")
   PedSetActionTree(l_0_3, "/Global/G_Striker_A", "Act/Anim/G_Striker_A.act") -- Ricky
   PedSetActionTree(l_0_4, "/Global/G_Striker_A", "Act/Anim/G_Striker_A.act") -- Lucky

   -- Ally Blip Code Start
   --
    l_2_7 = AddBlipForChar(l_0_3, 6, 2, 2)
    l_2_8 = AddBlipForChar(l_0_4, 6, 2, 2)

   -- Infinite Sprint Code Start for Allies
   --
    PedSetInfiniteSprint(l_0_3, true)
    PedSetInfiniteSprint(l_0_4, true)

   PedSetHealth(gPlayer, 10000)
        PedSetHealth(l_0_3, 10000)
        PedSetHealth(l_0_4, 10000)

   -- Ped Recruit Code Start
   --
    PedRecruitAlly(gPlayer, l_0_3)
    PedRecruitAlly(l_0_3, l_0_4)

   PedSetAllyAutoEngage(l_0_3, true)
   PedSetAllyAutoEngage(l_0_4, true)

  LoadAnimationGroup("Russell")
  LoadAnimationGroup("Boxing")
  LoadAnimationGroup("G_Johnny")

if IsButtonPressed(0, 0) then
PedSetActionNode(gPlayer, "/Global/Actions/Grapples/Front/Grapples/GrappleMoves/PowerBomb", "Globals/BOSS_Russell.act")
elseif IsButtonPressed(1, 0) then
PedSetActionNode(gPlayer, "/Global/G_Johnny/Cinematic/ThroatGrab", "Act/Anim/G_Johnny.act")
elseif IsButtonPressed(14, 0) then
PedSetActionNode(gPlayer, "/Global/Offense/Medium/HeavyAttacks/StraightPunch", "Act/Anim/BOSS_Darby.act")

end


F_MissionSetup = function()
  UnLoadAnimationGroup("Russell")
  UnLoadAnimationGroup("Boxing")
  UnLoadAnimationGroup("G_Johnny")
  PlayerSetControl(1)
  CameraFollowPed(gPlayer)
  ClockSet(9, 30)
  ClockSetTickRate(0.0060000000521541)
  LaunchScript("SObjTest.lua")

end



MissionCleanup = function()
  ClearTextQueue()
  EnablePOI()
  gMissionRunning = false
  shared.gMissionEventFunction = nil
  WeatherRelease()
  PlayerSetControl(1)
  PlayerSetPunishmentPoints(0)
end



main = function()
  F_MissionSetup()
  gMissionRunning = true
  while gMissionRunning do
    UpdateTextQueue()
    Wait(0)
   end
end 

Offline WhenLifeGivesYouLemons

  • xfire: 1emonthatsme
  • Sr. Member
  • ***
  • Posts: 971
  • Gender: Male
  • 波動バースト
    • View Profile
Re: Lua codes not working?
« Reply #1 on: June 16, 2013, 01:42:43 PM »
*Fixed

Code: [Select]
GlobalImportScript("SObjTest.lua")
ImportScript("Library/LibTable.lua")
ImportScript("SZone.lua")

  l_0_0 = 60

MissionSetup = function()
  local l_1_0 = 270
  local l_1_1 = -110
  local l_1_2 = 6.4000000953674
  AreaTransitionXYZ(0, l_1_0, l_1_1, l_1_2)

  l_0_3 = PedCreatePoint(28, POINTLIST._BEGGINING, 1) -- Ricky
  l_0_4 = PedCreatePoint(26, POINTLIST._BEGGINING, 1) -- Lucky

   PedSetActionTree(gPlayer, "/Global/G_Striker_A", "Act/Anim/G_Striker_A.act")
   PedSetActionTree(l_0_3, "/Global/G_Striker_A", "Act/Anim/G_Striker_A.act") -- Ricky
   PedSetActionTree(l_0_4, "/Global/G_Striker_A", "Act/Anim/G_Striker_A.act") -- Lucky

   -- Ally Blip Code Start
   --
    l_2_7 = AddBlipForChar(l_0_3, 6, 2, 2)
    l_2_8 = AddBlipForChar(l_0_4, 6, 2, 2)

   -- Infinite Sprint Code Start for Allies
   --
    PedSetInfiniteSprint(l_0_3, true)
    PedSetInfiniteSprint(l_0_4, true)

   PedSetHealth(gPlayer, 10000)
        PedSetHealth(l_0_3, 10000)
        PedSetHealth(l_0_4, 10000)

   -- Ped Recruit Code Start
   --
    PedRecruitAlly(gPlayer, l_0_3)
    PedRecruitAlly(l_0_3, l_0_4)

   PedSetAllyAutoEngage(l_0_3, true)
   PedSetAllyAutoEngage(l_0_4, true)

  LoadAnimationGroup("Russell")
  LoadAnimationGroup("Boxing")
  LoadAnimationGroup("G_Johnny")

if IsButtonPressed(0, 0) then
PedSetActionNode(gPlayer, "/Global/Actions/Grapples/Front/Grapples/GrappleMoves/PowerBomb", "Globals/BOSS_Russell.act")
elseif IsButtonPressed(1, 0) then
PedSetActionNode(gPlayer, "/Global/G_Johnny/Cinematic/ThroatGrab", "Act/Anim/G_Johnny.act")
elseif IsButtonPressed(14, 0) then
PedSetActionNode(gPlayer, "/Global/Offense/Medium/HeavyAttacks/StraightPunch", "Act/Anim/BOSS_Darby.act")
end
end


F_MissionSetup = function()
  UnLoadAnimationGroup("Russell")
  UnLoadAnimationGroup("Boxing")
  UnLoadAnimationGroup("G_Johnny")
  PlayerSetControl(1)
  CameraFollowPed(gPlayer)
  ClockSet(9, 30)
  ClockSetTickRate(0.0060000000521541)
  LaunchScript("SObjTest.lua")

end



MissionCleanup = function()
  ClearTextQueue()
  EnablePOI()
  gMissionRunning = false
  shared.gMissionEventFunction = nil
  WeatherRelease()
  PlayerSetControl(1)
  PlayerSetPunishmentPoints(0)
end



main = function()
  F_MissionSetup()
  gMissionRunning = true
  while gMissionRunning do
    UpdateTextQueue()
    Wait(0)
   end
end

Offline Phap

  • Full Member
  • ***
  • Posts: 216
  • Gender: Male
    • View Profile
Re: Lua codes not working?
« Reply #2 on: June 16, 2013, 01:51:53 PM »
So it requires 2 end right after the code?

Offline Phap

  • Full Member
  • ***
  • Posts: 216
  • Gender: Male
    • View Profile
Re: Lua codes not working?
« Reply #3 on: June 16, 2013, 01:53:30 PM »
*Fixed

Code: [Select]
GlobalImportScript("SObjTest.lua")
ImportScript("Library/LibTable.lua")
ImportScript("SZone.lua")

  l_0_0 = 60

MissionSetup = function()
  local l_1_0 = 270
  local l_1_1 = -110
  local l_1_2 = 6.4000000953674
  AreaTransitionXYZ(0, l_1_0, l_1_1, l_1_2)

  l_0_3 = PedCreatePoint(28, POINTLIST._BEGGINING, 1) -- Ricky
  l_0_4 = PedCreatePoint(26, POINTLIST._BEGGINING, 1) -- Lucky

   PedSetActionTree(gPlayer, "/Global/G_Striker_A", "Act/Anim/G_Striker_A.act")
   PedSetActionTree(l_0_3, "/Global/G_Striker_A", "Act/Anim/G_Striker_A.act") -- Ricky
   PedSetActionTree(l_0_4, "/Global/G_Striker_A", "Act/Anim/G_Striker_A.act") -- Lucky

   -- Ally Blip Code Start
   --
    l_2_7 = AddBlipForChar(l_0_3, 6, 2, 2)
    l_2_8 = AddBlipForChar(l_0_4, 6, 2, 2)

   -- Infinite Sprint Code Start for Allies
   --
    PedSetInfiniteSprint(l_0_3, true)
    PedSetInfiniteSprint(l_0_4, true)

   PedSetHealth(gPlayer, 10000)
        PedSetHealth(l_0_3, 10000)
        PedSetHealth(l_0_4, 10000)

   -- Ped Recruit Code Start
   --
    PedRecruitAlly(gPlayer, l_0_3)
    PedRecruitAlly(l_0_3, l_0_4)

   PedSetAllyAutoEngage(l_0_3, true)
   PedSetAllyAutoEngage(l_0_4, true)

  LoadAnimationGroup("Russell")
  LoadAnimationGroup("Boxing")
  LoadAnimationGroup("G_Johnny")

if IsButtonPressed(0, 0) then
PedSetActionNode(gPlayer, "/Global/Actions/Grapples/Front/Grapples/GrappleMoves/PowerBomb", "Globals/BOSS_Russell.act")
elseif IsButtonPressed(1, 0) then
PedSetActionNode(gPlayer, "/Global/G_Johnny/Cinematic/ThroatGrab", "Act/Anim/G_Johnny.act")
elseif IsButtonPressed(14, 0) then
PedSetActionNode(gPlayer, "/Global/Offense/Medium/HeavyAttacks/StraightPunch", "Act/Anim/BOSS_Darby.act")
end
end


F_MissionSetup = function()
  UnLoadAnimationGroup("Russell")
  UnLoadAnimationGroup("Boxing")
  UnLoadAnimationGroup("G_Johnny")
  PlayerSetControl(1)
  CameraFollowPed(gPlayer)
  ClockSet(9, 30)
  ClockSetTickRate(0.0060000000521541)
  LaunchScript("SObjTest.lua")

end



MissionCleanup = function()
  ClearTextQueue()
  EnablePOI()
  gMissionRunning = false
  shared.gMissionEventFunction = nil
  WeatherRelease()
  PlayerSetControl(1)
  PlayerSetPunishmentPoints(0)
end



main = function()
  F_MissionSetup()
  gMissionRunning = true
  while gMissionRunning do
    UpdateTextQueue()
    Wait(0)
   end
end
Thanks it worked. :)

Offline Phap

  • Full Member
  • ***
  • Posts: 216
  • Gender: Male
    • View Profile
Re: Lua codes not working?
« Reply #4 on: June 16, 2013, 02:03:05 PM »
Nvm it didn't work, I try pressing the buttons but Jimmy doesn't do anything.

Offline WhenLifeGivesYouLemons

  • xfire: 1emonthatsme
  • Sr. Member
  • ***
  • Posts: 971
  • Gender: Male
  • 波動バースト
    • View Profile
Re: Lua codes not working?
« Reply #5 on: June 16, 2013, 02:47:15 PM »
You probably wrote something wrong  :cc_detective:

Offline c00ld0c26

  • The D0c
  • Moderator
  • Can't Get Enough
  • *****
  • Posts: 5,137
  • Gender: Male
  • Just a dood doing dood things.
    • View Profile
    • My channel.
Re: Lua codes not working?
« Reply #6 on: June 16, 2013, 02:58:31 PM »
You wrote something wrong.
The Error you were getting was saying that you need to add another end under the line it was mentioning.

Offline Phap

  • Full Member
  • ***
  • Posts: 216
  • Gender: Male
    • View Profile
Re: Lua codes not working?
« Reply #7 on: June 16, 2013, 03:07:45 PM »
Everything works good but when I start it up with the arcade in the boy's dorm and tried to press the button to do those moves, Jimmy doesn't do anything.

Offline Phap

  • Full Member
  • ***
  • Posts: 216
  • Gender: Male
    • View Profile
Re: Lua codes not working?
« Reply #8 on: June 21, 2013, 04:07:23 PM »
Help please? :(

Offline xbetstyler

  • Jr. Member
  • **
  • Posts: 14
    • View Profile
Re: Lua codes not working?
« Reply #9 on: June 22, 2013, 05:18:21 AM »
the action node must be in main = function()
Code: [Select]
main = function()
  F_MissionSetup()
  gMissionRunning = true
  while gMissionRunning do
if IsButtonPressed(0, 0) then
PedSetActionNode(gPlayer, "/Global/Actions/Grapples/Front/Grapples/GrappleMoves/PowerBomb", "Globals/BOSS_Russell.act")
elseif IsButtonPressed(1, 0) then
PedSetActionNode(gPlayer, "/Global/G_Johnny/Cinematic/ThroatGrab", "Act/Anim/G_Johnny.act")
elseif IsButtonPressed(14, 0) then
PedSetActionNode(gPlayer, "/Global/Offense/Medium/HeavyAttacks/StraightPunch", "Act/Anim/BOSS_Darby.act")


and your F_MissionSetup = function() also have to change

Code: [Select]
F_MissionSetup = function()
  LoadAnimationGroup("Russell")
  LoadAnimationGroup("Boxing")
  LoadAnimationGroup("G_Johnny")
  PlayerSetControl(1)
  CameraFollowPed(gPlayer)
  ClockSet(9, 30)
  ClockSetTickRate(0.0060000000521541)
  LaunchScript("SObjTest.lua")

hope this will help you

Offline Phap

  • Full Member
  • ***
  • Posts: 216
  • Gender: Male
    • View Profile
Re: Lua codes not working?
« Reply #10 on: June 22, 2013, 11:07:17 AM »
Thanks brudah, it worked.

Offline Xavier the vampire

  • Jr. Member
  • **
  • Posts: 21
  • Gender: Male
  • Vampire is dark gift you really become vampire.
    • View Profile
    • www.youtube.com
Re: Lua codes not working?
« Reply #11 on: October 30, 2013, 11:10:24 AM »
Sorry I don't know what is to close function at 82 line? I have like this?
Code: [Select]
GlobalImportScript("SObjTest.lua")
ImportScript("Library/LibTable.lua")
ImportScript("SZone.lua")

  l_0_0 = 60

MissionSetup = function()
  local l_1_0 = 270
  local l_1_1 = -110
  local l_1_2 = 6.4000000953674
  AreaTransitionXYZ(0, l_1_0, l_1_1, l_1_2)

  l_0_3 = PedCreatePoint(28, POINTLIST._BEGGINING, 1) -- Ricky
  l_0_4 = PedCreatePoint(26, POINTLIST._BEGGINING, 1) -- Lucky

   PedSetActionTree(gPlayer, "/Global/G_Striker_A", "Act/Anim/G_Striker_A.act")
   PedSetActionTree(l_0_3, "/Global/G_Striker_A", "Act/Anim/G_Striker_A.act") -- Ricky
   PedSetActionTree(l_0_4, "/Global/G_Striker_A", "Act/Anim/G_Striker_A.act") -- Lucky

   -- Ally Blip Code Start
   --
    l_2_7 = AddBlipForChar(l_0_3, 6, 2, 2)
    l_2_8 = AddBlipForChar(l_0_4, 6, 2, 2)

   -- Infinite Sprint Code Start for Allies
   --
    PedSetInfiniteSprint(l_0_3, true)
    PedSetInfiniteSprint(l_0_4, true)

   PedSetHealth(gPlayer, 10000)
        PedSetHealth(l_0_3, 10000)
        PedSetHealth(l_0_4, 10000)

   -- Ped Recruit Code Start
   --
    PedRecruitAlly(gPlayer, l_0_3)
    PedRecruitAlly(l_0_3, l_0_4)

   PedSetAllyAutoEngage(l_0_3, true)
   PedSetAllyAutoEngage(l_0_4, true)

  LoadAnimationGroup("Russell")
  LoadAnimationGroup("Boxing")
  LoadAnimationGroup("G_Johnny")

if IsButtonPressed(0, 0) then
PedSetActionNode(gPlayer, "/Global/Actions/Grapples/Front/Grapples/GrappleMoves/PowerBomb", "Globals/BOSS_Russell.act")
elseif IsButtonPressed(1, 0) then
PedSetActionNode(gPlayer, "/Global/G_Johnny/Cinematic/ThroatGrab", "Act/Anim/G_Johnny.act")
elseif IsButtonPressed(14, 0) then
PedSetActionNode(gPlayer, "/Global/Offense/Medium/HeavyAttacks/StraightPunch", "Act/Anim/BOSS_Darby.act")
end
end


F_MissionSetup = function()
  LoadAnimationGroup("Russell")
  LoadAnimationGroup("Boxing")
  LoadAnimationGroup("G_Johnny")
  PlayerSetControl(1)
  CameraFollowPed(gPlayer)
  ClockSet(9, 30)
  ClockSetTickRate(0.0060000000521541)
  LaunchScript("SObjTest.lua")

end



MissionCleanup = function()
  ClearTextQueue()
  EnablePOI()
  gMissionRunning = false
  shared.gMissionEventFunction = nil
  WeatherRelease()
  PlayerSetControl(1)
  PlayerSetPunishmentPoints(0)
end



main = function()
  F_MissionSetup()
  gMissionRunning = true
  while gMissionRunning do
if IsButtonPressed(0, 0) then
PedSetActionNode(gPlayer, "/Global/Actions/Grapples/Front/Grapples/GrappleMoves/PowerBomb", "Globals/BOSS_Russell.act")
elseif IsButtonPressed(1, 0) then
PedSetActionNode(gPlayer, "/Global/G_Johnny/Cinematic/ThroatGrab", "Act/Anim/G_Johnny.act")
elseif IsButtonPressed(14, 0) then
PedSetActionNode(gPlayer, "/Global/Offense/Medium/HeavyAttacks/StraightPunch", "Act/Anim/BOSS_Darby.act")
    UpdateTextQueue()
    Wait(0)
   end
end
I want to have 3 boss styles Russell, Johhny and Darby mixed. I have a bit of problem?
« Last Edit: November 02, 2013, 07:39:19 PM by |XF|-MadmaN[AR] »

Offline c00ld0c26

  • The D0c
  • Moderator
  • Can't Get Enough
  • *****
  • Posts: 5,137
  • Gender: Male
  • Just a dood doing dood things.
    • View Profile
    • My channel.
Re: Lua codes not working?
« Reply #12 on: October 30, 2013, 12:27:55 PM »
the action node must be in main = function()
Code: [Select]
main = function()
  F_MissionSetup()
  gMissionRunning = true
  while gMissionRunning do
if IsButtonPressed(0, 0) then
PedSetActionNode(gPlayer, "/Global/Actions/Grapples/Front/Grapples/GrappleMoves/PowerBomb", "Globals/BOSS_Russell.act")
elseif IsButtonPressed(1, 0) then
PedSetActionNode(gPlayer, "/Global/G_Johnny/Cinematic/ThroatGrab", "Act/Anim/G_Johnny.act")
elseif IsButtonPressed(14, 0) then
PedSetActionNode(gPlayer, "/Global/Offense/Medium/HeavyAttacks/StraightPunch", "Act/Anim/BOSS_Darby.act")


and your F_MissionSetup = function() also have to change

Code: [Select]
F_MissionSetup = function()
  LoadAnimationGroup("Russell")
  LoadAnimationGroup("Boxing")
  LoadAnimationGroup("G_Johnny")
  PlayerSetControl(1)
  CameraFollowPed(gPlayer)
  ClockSet(9, 30)
  ClockSetTickRate(0.0060000000521541)
  LaunchScript("SObjTest.lua")

hope this will help you

Why in the main function? It will make the code look messy aswell it will make it harder for him to add other things to his mod.
My suggestion is that you make a function especially for the action nodes.

Action = function()
IF AND ACTION NODES CODE HERE
end
end

in the main write this below the "do"

Action()

I also believe it runs smoother, but not sure.

Offline Xavier the vampire

  • Jr. Member
  • **
  • Posts: 21
  • Gender: Male
  • Vampire is dark gift you really become vampire.
    • View Profile
    • www.youtube.com
Re: Lua codes not working?
« Reply #13 on: October 31, 2013, 11:23:58 AM »
I don't know how do you add this for lua please try to fix my mod to fit my favorite 3 bosses styles for Jimmy control button?
Code: [Select]
LoadAnimationGroup("Russell")
  LoadAnimationGroup("Boxing")
  LoadAnimationGroup("G_Johnny")

if IsButtonPressed(0, 0) then
PedSetActionNode(gPlayer, "/Global/Actions/Grapples/Front/Grapples/GrappleMoves/PowerBomb", "Globals/BOSS_Russell.act")
elseif IsButtonPressed(1, 0) then
PedSetActionNode(gPlayer, "/Global/G_Johnny/Cinematic/ThroatGrab", "Act/Anim/G_Johnny.act")
elseif IsButtonPressed(14, 0) then
PedSetActionNode(gPlayer, "/Global/Offense/Medium/HeavyAttacks/StraightPunch", "Act/Anim/BOSS_Darby.act")

I am a bit confused me by my own making mod luascript.lua?
« Last Edit: November 02, 2013, 07:38:48 PM by |XF|-MadmaN[AR] »

Offline c00ld0c26

  • The D0c
  • Moderator
  • Can't Get Enough
  • *****
  • Posts: 5,137
  • Gender: Male
  • Just a dood doing dood things.
    • View Profile
    • My channel.
Re: Lua codes not working?
« Reply #14 on: October 31, 2013, 11:47:57 AM »
I don't know how do you add this for lua please try to fix my mod to fit my favorite 3 bosses styles for Jimmy control button?  LoadAnimationGroup("Russell")
  LoadAnimationGroup("Boxing")
  LoadAnimationGroup("G_Johnny")

if IsButtonPressed(0, 0) then
PedSetActionNode(gPlayer, "/Global/Actions/Grapples/Front/Grapples/GrappleMoves/PowerBomb", "Globals/BOSS_Russell.act")
elseif IsButtonPressed(1, 0) then
PedSetActionNode(gPlayer, "/Global/G_Johnny/Cinematic/ThroatGrab", "Act/Anim/G_Johnny.act")
elseif IsButtonPressed(14, 0) then
PedSetActionNode(gPlayer, "/Global/Offense/Medium/HeavyAttacks/StraightPunch", "Act/Anim/BOSS_Darby.act")

I am a bit confused me by my own making mod luascript.lua?

Code: [Select]
MissionSetup = function()
LoadAnimationGroup("Russell")
  LoadAnimationGroup("Boxing")
  LoadAnimationGroup("G_Johnny")
end

Moves = function()
if IsButtonPressed(0, 0) then
PedSetActionNode(gPlayer, "/Global/Actions/Grapples/Front/Grapples/GrappleMoves/PowerBomb", "Globals/BOSS_Russell.act")
elseif IsButtonPressed(1, 0) then
PedSetActionNode(gPlayer, "/Global/G_Johnny/Cinematic/ThroatGrab", "Act/Anim/G_Johnny.act")
elseif IsButtonPressed(14, 0) then
PedSetActionNode(gPlayer, "/Global/Offense/Medium/HeavyAttacks/StraightPunch", "Act/Anim/BOSS_Darby.act")
end
end

main = function()
repeat
Moves()
Wait(0)
until not Alive
end

Fixed.
This is for the ArcRace1.lur, if you want it for the free roam script, copy all the "LoadAnimationGroup("")" and put them in the "main = function" BEFORE the "repeat" and delete the "MissionSetup = function()" from top to bottom.