Bully-Board

News:

News

Find loads of Bully Mods in in our Modding Section.

*RELEASE* - Bully LUA Script Sources (just a few)

|XF|-MadmaN[AR] · 21331

0 Members and 1 Guest are viewing this topic.

Offline The Dream Is Dead

  • ...
  • Hero Member
  • ****
    • Posts: 1,192
  • ...
    • View Profile
Reply #30 on: December 27, 2012, 09:40:52 AM
I tried adding a vehicle to the game like the example in Madman's bully magazine but when I start the arcade machine it never ends loading.

This is the code that I used (the same Madman used):

F_MissionSetup = function()
VehicleCreateXYZ(284, 320, 160, 5)
PlayerSetControl(1)
WeatherSet(0)
end

This is because I didn't spawn Jimmy?
Is there a way to tell the game the interior ID you want the vehicle to spawn?



Offline Red Blaster

  • The BB Arab
  • Global Moderator
  • More Than Halfway There
  • *****
    • Posts: 5,649
  • Hi
    • View Profile
Reply #31 on: December 27, 2012, 10:06:33 AM
@deadpool: Post the entire code.

@JmTShaw: For IsButtonPressed stuff, you need an if statement. Here's an example:

if IsButtonPressed(2, 0) then
  ExecuteActionNode(gPlayer, "/Global/Nemesis/Special/GarySpecialGrapple", "Act/Anim/Nemesis.act")
end

2 corresponds to the up arrow, which normally zooms into a close up of Jimmy's perspective.

This has to be in a function. Let's call it "F_Buttons = function()"

Under main = function() you must have the following:

F_MissionSetup()
  CreateThread("F_Buttons")
  gMissionRunning = true
  while gMissionRunning do
    UpdateTextQueue()
    F_Buttons()
    Wait(0)
  end
end
« Last Edit: December 27, 2012, 11:09:43 AM by Doctor Red »



Offline The Dream Is Dead

  • ...
  • Hero Member
  • ****
    • Posts: 1,192
  • ...
    • View Profile
Reply #32 on: December 27, 2012, 11:28:49 AM
@deadpool: Post the entire code.

@JmTShaw: For IsButtonPressed stuff, you need an if statement. Here's an example:

if IsButtonPressed(2, 0) then
  ExecuteActionNode(gPlayer, "/Global/Nemesis/Special/GarySpecialGrapple", "Act/Anim/Nemesis.act")
end

2 corresponds to the up arrow, which normally zooms into a close up of Jimmy's perspective.

This has to be in a function. Let's call it "F_Buttons = function()"

Under main = function() you must have the following:

F_MissionSetup()
  CreateThread("F_Buttons")
  gMissionRunning = true
  while gMissionRunning do
    UpdateTextQueue()
    F_Buttons()
    Wait(0)
  end
end

Well... that's the entire code.
The problem is that I don't know what is missing.



Offline JmTsHaW

  • Jr. Member
  • **
    • Posts: 79
    • View Profile
Reply #33 on: December 27, 2012, 11:45:23 AM
It doesn't respond to the button (That, and I don't know what the button numbers are assigned to)

This is the code I have so far:

ImportScript("\\Library\\LibTable.lua") -- imports the LibTable library
ImportScript("\\Library\\LibPed.lua") -- imports the LibPed library
local l_0_0 = false
 
MissionSetup = function() -- basic mission setup function which is used in almost all bully scripts
  local l_1_0 = 117 -- X coords
  local l_1_1 = -8 -- Y coords
  local l_1_2 = 12.8 -- Z coords
  AreaTransitionXYZ(0, l_1_0, l_1_1, l_1_2) -- teleports the player to the 'Hole' in the basement
  TextPrintString("Press button four to activate goodies.", 1, 2) -- Show text
end
 
MissionCleanup = function() -- mission cleanup function
end -- end statement
 
main = function() -- Main mission function
  F_MissionSetup()
  CreateThread("F_Buttons")
    gMissionRunning = true
    while gMissionRunning do
      UpdateTextQueue()
      F_Buttons()
      Wait(0)
    end
end

F_Buttons = function()
  if IsButtonPressed(4, 0) then -- Check whether button four is held or not
  PedSetEffectedByGravity(gPlayer, false) -- Removes the player from the effects of gravity
  TextPrintString("Land is for loser-heads.", 2, 2)
    Wait(5000)
  end
end
« Last Edit: December 27, 2012, 12:02:26 PM by JmTsHaW »



Offline Red Blaster

  • The BB Arab
  • Global Moderator
  • More Than Halfway There
  • *****
    • Posts: 5,649
  • Hi
    • View Profile
Reply #34 on: December 27, 2012, 12:28:39 PM
Change "4" to "2", then when the script starts, press the up arrow. If that doesn't work...something is wrong.

Quote
Well... that's the entire code.
The problem is that I don't know what is missing.

Well, for one: You need the main = function()

It's like this:

MissionSetup = function()

^ That's where you add the stuff like where Jimmy spawns and any text if you want.

Then there's the F_SetupMission = function() part you posted.

Afterwards, you add the main = function() part.

main = function()
  F_MissionSetup
  gMissionRunning = true
  while gMissionRunning do
     UpdateTextQueue()
     Wait(0)
  end -- End Statement
end
« Last Edit: December 27, 2012, 12:38:53 PM by Admiral Red »



Offline JmTsHaW

  • Jr. Member
  • **
    • Posts: 79
    • View Profile
Reply #35 on: December 27, 2012, 12:43:03 PM
I tried it with 2 earlier and it didn't work either.



Offline Red Blaster

  • The BB Arab
  • Global Moderator
  • More Than Halfway There
  • *****
    • Posts: 5,649
  • Hi
    • View Profile
Reply #36 on: December 27, 2012, 01:08:59 PM
Ahhhhh, I see now why it's not working.

The problem is, you don't have the function F_MissionSetup = function()

But it's referenced in main by (F_MissionSetup()), so without a function by that name to reference, the script will lock up.

Plus, MissionCleanup is missing everything, and that's needed for when the script ends.
« Last Edit: December 27, 2012, 01:11:50 PM by Admiral Red »



Offline |XF|-MadmaN[AR]

  • Bully-Board Admin Team
  • Administrator
  • Hero Member
  • *****
    • Posts: 1,394
  • Biblio-Techa Mods (retired)
    • View Profile
Reply #37 on: December 27, 2012, 01:24:46 PM
Here is some button code that I use in one of my current testing scripts.

This code does work but you will have to play around with it alittle bit to apply it to your current project since there is no "one size fits all" approach to scripting sadly.

Code: [Select]
main = function()
    F_MissionSetup()
PlayerSetControl(1)
CameraSetWidescreen(true)
DisablePunishmentSystem(true)
CameraReset()
Wait(50)
Wait(10)
CameraFade(500, 1)
--TextPrintString("Starting", 1, 1)
HasGravity = true
index = 1
--F_BuildWeaponTable()
--F_BuildPickupTable()
controllernum = 0
HairIsChanging = nil
DebugMenuAddPage("Spawn Character")
ShouldLoop = true
while (ShouldLoop) do
if F_IsButtonPressedWithDelayCheck(1, 0, 1, 100) then
    TextPrintString("Print Something"..index, 2, 2)
elseif F_IsButtonPressedWithDelayCheck(0, 0, 1, 100) then
TextPrintString("Print More Something"..index, 2, 2)
elseif IsButtonPressed(2, 0) then
CreateThread("Function0")
elseif F_IsButtonPressedWithDelayCheck(3, 0, 1, 200) then
CreateThread("Function1")
end
Wait(0)             
end
end

Keep in mind that this is just a example and not intended to be used directly as it is since it is only a portion of some test code of mine and I edited it to remove certain things that I need to keep quiet about for the time being.



Offline Red Blaster

  • The BB Arab
  • Global Moderator
  • More Than Halfway There
  • *****
    • Posts: 5,649
  • Hi
    • View Profile
Reply #38 on: December 27, 2012, 01:43:35 PM
Never mind that...his issue was that he's missing the F_MissionSetup = function() part, but he's still calling the function in main. But since that function doesn't exist, the game will lock up.



Offline |XF|-MadmaN[AR]

  • Bully-Board Admin Team
  • Administrator
  • Hero Member
  • *****
    • Posts: 1,394
  • Biblio-Techa Mods (retired)
    • View Profile
Reply #39 on: December 27, 2012, 02:01:07 PM
Yeah. You are right.

I went ahead and posted all that anyways to give a better hint on how to deal with button mapping...etc for custom scripts. Since it is something that will take some practice to get the hang of for most modders new to lua scripting.



Offline The Dream Is Dead

  • ...
  • Hero Member
  • ****
    • Posts: 1,192
  • ...
    • View Profile
Reply #40 on: December 27, 2012, 06:25:40 PM
Change "4" to "2", then when the script starts, press the up arrow. If that doesn't work...something is wrong.

Quote
Well... that's the entire code.
The problem is that I don't know what is missing.

Well, for one: You need the main = function()

It's like this:

MissionSetup = function()

^ That's where you add the stuff like where Jimmy spawns and any text if you want.

Then there's the F_SetupMission = function() part you posted.

Afterwards, you add the main = function() part.

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

  end -- End Statement
end

I get a text saying:

"=" expected near 'gMissionRunning'

There is already a =.
I doubt it should go next to the other 'gMissionRunning'

EDIT:


« Last Edit: December 27, 2012, 07:09:06 PM by Ωяιмѕση_υяуΩ »



E32050TRA

  • Guest
Reply #41 on: December 27, 2012, 07:24:22 PM
Ok, I am kind of almost getting started with Lua but i have not have so much luck in getting it to work. I installed and got everything i need. Because when I click to run it it worked. Do when i try to do the Run and CMD thing, it did not work and it said:

C:\Users\Computer>''C:\Users\Computer\Documents\LUAC Bully\LuaC.exe''
C:\Users\Computer\Documents\LUAC Bully\LuaC.exe: no input files given usage: C:\Users\Computer\Documents\LUAC Bully\LuaC.exe [options] [filenames]. Available options are:
-               process stdin
-1             list
-o name    output to file 'name' <default is ''luac.out''
-p             parse only
-s             strip debug information
-v             show version information
--             stop handling options



Offline |XF|-MadmaN[AR]

  • Bully-Board Admin Team
  • Administrator
  • Hero Member
  • *****
    • Posts: 1,394
  • Biblio-Techa Mods (retired)
    • View Profile
Reply #42 on: December 27, 2012, 08:33:06 PM
What you need to do is if you modified a script and want to compile it to test it...just type at the command line (cmd window) luac -o ArcRace1.lua scriptname.lua and hit enter.

Replace scriptname.lua with the full name of the script you wish to compile.

I highly suggest starting with a existing script like the testally.lua script or my bodyguard mod script as a base and just play with the code a bit so you get a feel for lua. The bodyguard script is well documented (use the fixed one Red posted since my original posted one has some errors that I forgot totally about) and study the code syntax....also just read over the magazine a bit to get a feel for everything since I put a wealth of info into that as a starting point for everyone to read before they start off on their LUA script adventures  :biggrin:



Offline |XF|-MadmaN[AR]

  • Bully-Board Admin Team
  • Administrator
  • Hero Member
  • *****
    • Posts: 1,394
  • Biblio-Techa Mods (retired)
    • View Profile
Reply #43 on: December 27, 2012, 08:37:16 PM
Change "4" to "2", then when the script starts, press the up arrow. If that doesn't work...something is wrong.

Quote
Well... that's the entire code.
The problem is that I don't know what is missing.

Well, for one: You need the main = function()

It's like this:

MissionSetup = function()

^ That's where you add the stuff like where Jimmy spawns and any text if you want.

Then there's the F_SetupMission = function() part you posted.

Afterwards, you add the main = function() part.

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

  end -- End Statement
end

I get a text saying:

"=" expected near 'gMissionRunning'

There is already a =.
I doubt it should go next to the other 'gMissionRunning'



Please post the full code in question that you are working with that has this error (use the bbcode # button to put code in that way it keeps the code syntax intact and allows me to see what you are modifying and I will see what the problem is.

LUA is very very picky about syntax like most programming languages. Here is a tip for you and anyone else that reads this and gets a similar or any error with the compiler when trying to compile a script:

anytime you see a error when compiling......look closely at the error because the lua compiler will tell you exactly what line the error happened at and generally it will be a error caused by too many or too few end statements....or a while in the wrong place or a if statement missing something....a small typo will throw everything off and sometimes it can be frusterating to find the error. I myself have a couple scripts with similar errors that I have not figured out yet....but will eventually.



E32050TRA

  • Guest
Reply #44 on: December 27, 2012, 08:55:40 PM
Mad, what is the bodyguard script called actually?