Bully-Board

Bully Modding Section => Script Modding => Topic started by: MadmaN on December 25, 2012, 09:04:14 PM

Title: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: MadmaN on December 25, 2012, 09:04:14 PM
(http://i.imgur.com/P1wAl.png)
(http://i.imgur.com/2HF4g.png)
(http://i.imgur.com/vDM4J.png)
Here are some Bully LUA Script Sources to play around with.

You will need a proper IDE for editing these files if you want to use color coding to make the code easier to read. Notepad++ is one that I highly recommend since it has support for lua.

I have some lua code plugins for notepad++ that I can upload here as well to this topic.


NOTE:
This is NOT a complete release of every script in Bully. Bully has over 500 total lua scripts and I only have maybe about half in usable form. I am for now just releasing a small handful of intact rewritten script sources for people to play around with. I also will release a mod source for one of my mods that is fully commented so people basicly will know what various parts of code does.



TestAlly.lua - This is a test script that is part of the debug menu system. This just spawns a single ped and recruits them as your bodyguard.

Code: [Select]
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 = 270 -- X coords
  local l_1_1 = -110 -- Y coords
  local l_1_2 = 6.4000000953674 -- Z coords
  PlayerSetHealth(200) -- gives the player 200 health
  AreaTransitionXYZ(0, l_1_0, l_1_1, l_1_2) -- teleports the player to the sidewalk outside the boys dorm
  local l_1_3 = 25 -- Lola (this is her model id number)
  local l_1_4, l_1_5, l_1_6 = PedGetPosXYZ(gPlayer) -- gets coordinates of the player on the map
  local l_1_7 = PedCreateXYZ(l_1_3, l_1_4 + 1, l_1_5 + 1, l_1_6) -- create a ped (Lola) and spawn them near the player
  PedRecruitAlly(gPlayer, l_1_7, true) -- recruits the spawned ped as a bodyguard (local l_1_7 is assigned to model id 25 which is Lola)
  PedMakeAmbient(l_1_7) -- makes the spawned ped ambient
end
 
MissionCleanup = function() -- mission cleanup function
end -- end statement
 
main = function() -- Main mission function
  repeat -- This makes the script run until the bodyguard is dismissed, attacked by the player or the player is busted
    Wait(0) -- wait 0 seconds
  until l_0_0 ~= false
  Wait(3000) -- wait 3 seconds
  MissionSucceed() -- ends mission
end
 




1_01.lua

Code: [Select]
ImportScript("Library/LibTable.lua")
ImportScript("Library/LibTrigger.lua")
ImportScript("Library/LibSchool.lua")
local l_0_0 = false
local l_0_1 = 0
local l_0_2 = false
local l_0_3 = nil
local l_0_4 = false
local l_0_5 = false
local l_0_6, l_0_7 = nil, nil
local l_0_8 = false
local l_0_9 = false
local l_0_10 = false
local l_0_11, l_0_12, l_0_13 = nil, nil, nil
local l_0_14 = 0
local l_0_15 = 0
local l_0_16, l_0_17 = nil, nil
local l_0_18 = {}
local l_0_19 = nil
local l_0_20 = 1
local l_0_21 = 1
local l_0_22 = false
local l_0_23 = 0
local l_0_24 = 0
local l_0_25 = false
local l_0_26 = true
local l_0_27 = false
local l_0_28 = {}
local l_0_29 = false
local l_0_30 = false
local l_0_31 = false
local l_0_32 = false
local l_0_33 = false
local l_0_34 = 0
local l_0_35 = false
local l_0_36, l_0_37 = nil, nil
local l_0_38 = false
local l_0_39 = false
local l_0_40 = 0
local l_0_41 = 0
local l_0_42 = 0
local l_0_43 = 0
local l_0_44 = 0
local l_0_45 = 0
local l_0_46 = 0
local l_0_47 = 0
local l_0_48 = 0
local l_0_49 = 0
local l_0_50 = 0
local l_0_51 = 0
local l_0_52 = 0
local l_0_53 = 0
local l_0_54 = 0
local l_0_55 = 0
local l_0_56 = 0
local l_0_57 = 0
local l_0_58 = false
 
F_CheckInitialPOI = function(l_1_0)
  local l_1_1, l_1_2, l_1_3 = AreaPOIGetPosition(l_1_0)
  if DistanceBetweenCoords3d(l_1_1, l_1_2, l_1_3, 274.30499267578, -70.682403564453, 5.9864101409912) < 5 then
    if not l_0_10 then
      l_0_10 = true
      return true
    else
      return false
    end
  end
end
 
MissionSetup = function()
  DATLoad("1_01.DAT", 2)
  DATInit()
  LoadActionTree("Act/Conv/1_01.act")
  LoadActionTree("Act/Conv/1_02.act")
  MissionDontFadeIn()
  SoundEnableInteractiveMusic(true)
  ClockSet(8, 30)
  shared.lockClothingManager = true
  if GetMissionAttemptCount("1_01") > 1 then
    MissionSurpressMissionNameText()
    l_0_0 = true
  end
  if not l_0_0 then
    shared.gOverrideSchoolGates = false
    shared.gFrontGateOpen = false
    Wait(10)
    PAnimCreate(TRIGGER._TSCHOOL_FRONTGATE)
    AreaSetDoorOpen(TRIGGER._TSCHOOL_FRONTGATE, true)
    PAnimSetActionNode(TRIGGER._TSCHOOL_FRONTGATE, "/Global/1_01/Gates/BarUpHold", "Act/Conv/1_01.act")
    PlayCutsceneWithLoad("1-1-1", true, true, true)
    PAnimDelete(TRIGGER._TSCHOOL_FRONTGATE)
    GeometryInstance("ScGate01Closed", false, 301.43899536133, -72.505897521973, 8.0465698242188, true)
    GeometryInstance("ScGate02Closed", false, 225.92799377441, 5.7981600761414, 8.3947095870972, true)
  else
    CameraSetWidescreen(false)
  end
    local l_5_0 = -9.9879999160767
    local l_5_1 = 21.420000076294
    local l_5_2 = 30.059999465942
    AreaTransitionXYZ(22, l_5_0, l_5_1, l_5_2)
    PlayerFaceHeading(270, 1)

end
 

 
MissionCleanup = function()
  ToggleHUDComponentVisibility(21, false)
  if shared.gSecretaryID ~= nil and PedIsValid(shared.gSecretaryID) then
    PedDelete(shared.gSecretaryID)
    shared.gSecretaryID = nil
  end
  ClearTextQueue()
  EnablePOI()
  gMissionRunning = false
  shared.gMissionEventFunction = nil
  if l_0_3 then
    BlipRemove(l_0_3)
  end
  PedSetUniqueModelStatus(102, l_0_40)
  PedSetUniqueModelStatus(99, l_0_41)
  PedSetUniqueModelStatus(85, l_0_42)
  PedSetUniqueModelStatus(145, l_0_43)
  PedSetUniqueModelStatus(146, l_0_44)
  PedSetUniqueModelStatus(75, l_0_45)
  PedSetUniqueModelStatus(50, l_0_46)
  PedSetUniqueModelStatus(59, l_0_47)
  PedSetUniqueModelStatus(69, l_0_48)
  PedSetUniqueModelStatus(139, l_0_49)
  PedSetUniqueModelStatus(72, l_0_50)
  PedSetUniqueModelStatus(73, l_0_51)
  PedSetUniqueModelStatus(24, l_0_52)
  PedSetUniqueModelStatus(26, l_0_53)
  PedSetUniqueModelStatus(34, l_0_54)
  PedSetUniqueModelStatus(32, l_0_55)
  PedSetUniqueModelStatus(16, l_0_56)
  PedSetUniqueModelStatus(12, l_0_57)
  UnLoadAnimationGroup("Hang_Talking")
  UnLoadAnimationGroup("NPC_AggroTaunt")
  UnLoadAnimationGroup("Area_School")
  UnLoadAnimationGroup("SBULL_A")
  UnLoadAnimationGroup("POI_Smoking")
  UnLoadAnimationGroup("B_Striker")
  UnLoadAnimationGroup("NPC_Adult")
  PlayerSetInvulnerable(false)
  WeatherRelease()
  TutorialRemoveMessage()
  AreaRevertToDefaultPopulation()
  PlayerSetControl(1)
  DATUnload(2)
  PlayerSetPunishmentPoints(0)
end
 
CB_RenderObj = function()
  misObj = MissionObjectiveAdd("1_01_StandGround")
end
 

 
main = function()
  --gEunice = PedCreatePoint(74, POINTLIST._PRINCIPALROOM, 2)
  --PedSetPosPoint(gEunice, POINTLIST._1_02_EUNICE, 1)


  CameraFade(500, 0)
  SoundPreloadSpeech(gPlayer, "NARRATION", 101, "supersize", true)
  CameraSetWidescreen(true)
  CameraReset()
  Wait(50)
  repeat
    Wait(0)
  until SoundIsSpeechPreloaded()
  Wait(10)
  CameraFade(500, 1)
  Wait(501)
  SoundPlayPreloadedSpeech()
  repeat
    Wait(0)
  until not SoundSpeechPlaying(gPlayer, "NARRATION", 101)
 -- TextPrintString("You win!", 4, 1)
  Wait(15000)
  MissionSucceed(true, false, false)
  PedSetActionNode(gPlayer, "/Global/Player", "Act/Player.act")
end
 
F_CreatePeds = function()
  Prefect1 = PedCreatePoint(13, POINTLIST._PUNISHTEST_P1)
  Wait(5000)
  PedFollowPath(Prefect1, PATH._PUNISHTEST_PATH2, 0, 1, F_CallBack)
  CreateThread("F_HitCheck")
end
 
F_CallBack = function(l_6_0, l_6_1, l_6_2)
  if l_6_2 == 2 then
    PedAttack(l_6_0, gPlayer)
  end
end




6_01.lua

Code: [Select]
local l_0_0 = false
local l_0_1 = nil
local l_0_3 = 0
local l_0_4 = nil
local l_0_5 = false
local l_0_6 = false
 
MissionSetup = function()
  DATLoad("6_01.DAT", 2)
  DATLoad("3_08.DAT", 2)
  MissionSurpressMissionNameText()
  MissionDontFadeIn()
end
 
main = function()
  PlayCutsceneWithLoad("6-0", true, true)
  if ClothingGetPlayer(1) == ObjectNameToHashID("S_Sweater5") then
    ClothingSetPlayer(1, "B_Jacket6")
  end
  if ClothingGetPlayer(4) == ObjectNameToHashID("S_Pants1") then
    ClothingSetPlayer(4, "B_Pants2")
  end
  ClothingBuildPlayer()
  AreaTransitionPoint(14, POINTLIST._6_01_BDORM, 1, false)
  CameraReset()
  CameraReturnToPlayer()
  CameraFade(500, 1)
  Wait(501)
  TextPrint("6_01_EXPELLED", 4, 1)
  shared.gPlayerInitialArea = nil
  MissionSucceed(false, false, false)
end
 
MissionCleanup = function()
  if l_0_0 then
    PlayerSetScriptSavedData(3, PlayerGetNumTimesBusted())
    PlayerSetScriptSavedData(14, 0)
  end
  UnpauseGameClock()
  CameraSetWidescreen(false)
  DATUnload(2)
end
 
F_PlayerGetOutOfBed = function()
  if l_0_4 then
    return 1
  end
  return 0
end





Bike_Gen.lua - This is a library script ran by other scripts that spawns random bikes on the bully world map.

Code: [Select]
F_VehicleGen = function()
  VehicleCreateCarGenerator(513.21002197266, -152.52000427246, 5.2109999656677, 15, 282, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(599.25, -12.78600025177, 6.3959999084473, 90, 274, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(518.20001220703, -32.770000457764, 6.2399997711182, 190, 279, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(485.29998779297, -79.319999694824, 5.4000000953674, 180, 274, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(552.15002441406, -367.70001220703, 2.2349998950958, 140, 279, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(522.72497558594, -487.27499389648, 4.3070001602173, 340, 282, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(238.06100463867, -439.70001220703, 2.6329998970032, 20, 281, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(223.51300048828, -303.35000610352, 5.4650001525879, 180, 274, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(129.80000305176, -407.79699707031, 2.6289999485016, 275, 279, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(118.05000305176, -517.75, 3.319000005722, 30, 274, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(12.75, -448.54998779297, 0.43200001120567, 225, 279, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(219.0299987793, 424.41598510742, 4.8899998664856, 235, 274, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(139.94999694824, 424.36999511719, 8.0349998474121, 342, 282, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(276.04998779297, 207.31799316406, 6.1680002212524, 270, 279, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(349.20001220703, 124.88800048828, 5.375, 90, 282, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(396.75, 148.60400390625, 5.2069997787476, 90, 274, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(401.31100463867, 189.78999328613, 6.6490001678467, 0, 274, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(387.93301391602, 393.29000854492, 21.471000671387, 0, 280, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(482.10000610352, 430.21600341797, 18.05299949646, 90, 279, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(603.45001220703, 393.61599731445, 16.471000671387, 90, 282, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(547.82000732422, 247.16700744629, 16.893999099731, 90, 274, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(332.13000488281, 270.67001342773, 5.9499998092651, 90, 282, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(445.29998779297, 236.5, 9.6999998092651, 90, 282, -1, -1, true, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(498.17001342773, -18.719999313354, 7.25, 0, 293, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(588.90002441406, -139, 6.9800000190735, 0, 297, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(467.9700012207, -204.32000732422, 4.1900000572205, -15, 286, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(548.57000732422, -455.08999633789, 5.4000000953674, -15, 296, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(487.19000244141, -384.2200012207, 3.3299999237061, 75, 294, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(429.67001342773, 163.66999816895, 7.1500000953674, 90, 297, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(317.55999755859, 401.48999023438, 25.729999542236, -30, 292, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(434.39999389648, 486.23999023438, 24.340000152588, 0, 286, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(576.25, 457.2200012207, 19.520000457764, 0, 293, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(310.79998779297, -328.48999023438, 3.5899999141693, 0, 294, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(161.33000183105, -375.48999023438, 3.9900000095367, 100, 291, -1, -1, false, 0, 0, 1500, 45000, true)
  VehicleCreateCarGenerator(60.419998168945, -462.30999755859, 5.9699997901917, 135, 291, -1, -1, false, 0, 0, 1500, 45000, true)
end
 
F_VehicleGen()
F_VehicleGen = nil




SCloth.lua - Library script that controls the clothing outfits

Code: [Select]

scloth = function()
  local l_1_0 = true
  local l_1_1 = false
  local l_1_2 = true
  local l_1_3 = false
  --                   FriendlyName                        Head             Torso             LeftWrist        RightWrist       Legs              Feet
  ClothingDefineOutfit("Underwear",     "CLT_Undies",     "Hair",           "P_SSleeves11",   "none",          "none",          "SP_Briefs",      "SP_Socks",        l_1_3, l_1_1)
  ClothingDefineOutfit("Starting",      "CLT_Start",      "Hair",           "B_Jacket6",      "none",          "none",          "B_Pants2",       "P_Sneakers2",     l_1_2, l_1_1)
  ClothingDefineOutfit("Uniform",       "CLT_Uniform",    "Hair",           "S_Sweater5",     "none",          "none",          "S_Pants1",       "P_Sneakers2",     l_1_3, l_1_1)
  ClothingDefineOutfit("Boxing",        "CLT_BOX_OUTFIT", "Hair",           "SP_BOXING_T",    "SP_Boxing_G_L", "SP_Boxing_G_R", "SP_BOXING_L",    "SP_BOXING_ft",    l_1_3, l_1_0)
  ClothingDefineOutfit("Boxing NG",     "CLT_BOX_NG",     "Hair",           "SP_BOXING_T",    "none",          "none",          "SP_BOXING_L",    "SP_BOXING_ft",    l_1_3, l_1_0)
  ClothingDefineOutfit("Wrestling",     "CLT_WRS_OUTFIT", "SP_Wrestling_H", "SP_Wrestling_T", "none",          "none",          "SP_Wrestling_L", "SP_Wrestling_ft", l_1_3, l_1_0)
  ClothingDefineOutfit("Mascot",        "CLT_MASCOT",     "SP_Mascot_H",    "none",           "none",          "none",          "none",           "SP_Mascot_B",     l_1_2, l_1_0)
  ClothingDefineOutfit("MascotNoHead",  "CLT_MASCOT",     "Hair",           "none",           "none",          "none",          "none",           "SP_Mascot_B",     l_1_2, l_1_0)
  ClothingDefineOutfit("Orderly",       "CLT_OLY_OUTFIT", "Hair",           "SP_Orderly_T",   "none",          "none",          "SP_Orderly_P",   "SP_Orderly_B",    l_1_2, l_1_0)
  ClothingDefineOutfit("Halloween",     "CLT_HALLOW",     "SP_Ween_H",      "SP_Ween_T",      "none",          "none",          "SP_Ween_L",      "B_Boots1",        l_1_2, l_1_1)
  ClothingDefineOutfit("PJ",            "CLT_PJ",         "Hair",           "SP_PJ_T",        "none",          "none",          "SP_PJ_L",        "SP_Socks",        l_1_3, l_1_1)
  ClothingDefineOutfit("Prison",        "CLT_Prison",     "Hair",           "SP_Prison_T",    "none",          "none",          "SP_Prison_L",    "P_Boots2",        l_1_3, l_1_0)
  ClothingDefineOutfit("Grotto Master", "CLT_DM",         "SP_DM_H",        "SP_DM_T",        "none",          "none",          "B_Pants2",       "P_Boots2",        l_1_3, l_1_1)
  ClothingDefineOutfit("Gnome",         "CLT_Gnome",      "SP_Gnome_H",     "SP_Gnome_T",     "none",          "none",          "SP_Gnome_L",     "SP_Gnome_ft",     l_1_2, l_1_0)
  ClothingDefineOutfit("Fast Food",     "CLT_Fastfood",   "SP_Fries_H",     "SP_Fries_T",     "none",          "none",          "SP_Fries_L",     "P_Boots2",        l_1_2, l_1_1)
  ClothingDefineOutfit("Gold Suit",     "CLT_Rocker",     "SP_Goldsuit_H",  "SP_Goldsuit_T",  "none",          "none",          "SP_Goldsuit_L",  "SP_Goldsuit_ft",  l_1_2, l_1_0)
  ClothingDefineOutfit("BMX Champion",  "CLT_BMX",        "SP_BikeHelmet",  "SP_BikeJersey",  "none",          "none",          "B_Pants2",       "P_Boots2",        l_1_2, l_1_1)
  ClothingDefineOutfit("Gym Strip",     "CLT_gym",        "Hair",           "S_SSleeves4",    "S_Wristband4",  "S_Wristband3",  "S_Shorts1",      "P_Sneakers1",     l_1_3, l_1_1)
  ClothingDefineOutfit("Ninja_BLK",     "CLT_NinjaBLK",   "SP_Ninja_H",     "SP_Ninja_T",     "none",          "none",          "SP_Ninja_L",     "SP_Ninja_Ft",     l_1_2, l_1_1)
  ClothingDefineOutfit("Ninja_WHT",     "CLT_NinjaWHT",   "SP_NinjaW_H",    "SP_NinjaW_T",    "none",          "none",          "SP_NinjaW_L",    "SP_NinjaW_Ft",    l_1_2, l_1_1)
  ClothingDefineOutfit("Ninja_RED",     "CLT_NinjaRED",   "SP_NinjaR_H",    "SP_NinjaR_T",    "none",          "none",          "SP_NinjaR_L",    "SP_NinjaR_Ft",    l_1_2, l_1_1)
  ClothingDefineOutfit("Columbus",      "CLT_Columbus",   "SP_Colum_H",     "SP_Colum_T",     "none",          "none",          "SP_Colum_L",     "SP_Colum_FT",     l_1_2, l_1_0)
  ClothingDefineOutfit("Nutcracker",    "CLT_Nutcracker", "SP_Nutcrack_H",  "SP_Nutcrack_T",  "none",          "none",          "SP_Nutcrack_L",  "SP_Nutcrack_FT",  l_1_2, l_1_0)
  ClothingDefineOutfit("Elf",           "CLT_Elf",        "SP_Elf_H",       "SP_Elf_T",       "none",          "none",          "SP_Elf_L",       "SP_Elf_FT",       l_1_2, l_1_0)
  ClothingDefineOutfit("Marching Band", "CLT_MBand",      "SP_MBand_H",     "SP_MBand_T",     "none",          "none",          "SP_MBand_L",     "SP_MBand_FT",     l_1_2, l_1_0)
  ClothingDefineOutfit("Nascar",        "CLT_Nascar",     "SP_Nascar_H",    "SP_Nascar_T",    "none",          "none",          "SP_Nascar_L",    "SP_Nascar_FT",    l_1_2, l_1_0)
  ClothingDefineOutfit("80 Rocker",     "CLT_80Rocker",   "SP_80Rocker_H",  "SP_80Rocker_T",  "none",          "SP_80Bracer",   "SP_80Rocker_L",  "SP_80Rocker_FT",  l_1_3, l_1_0)
  ClothingDefineOutfit("Panda",         "CLT_Panda",      "SP_Panda_H",     "none",           "none",          "none",          "none",           "SP_Panda_B",      l_1_2, l_1_0)
  ClothingDefineOutfit("Alien",         "CLT_Alien",      "SP_Alien_H",     "SP_Alien_T",     "none",          "none",          "SP_Alien_L",     "P_Boots4",        l_1_2, l_1_1)
  ClothingDefineOutfit("NerdJimmy",     "CLT_Nerd",       "SP_Nerd_H",      "SP_Nerd_T",      "none",          "SP_NerdWatch",  "SP_Nerd_L",      "SP_Nerd_FT",      l_1_3, l_1_0)
end
 
scloth()
scloth = nil





STimeCycle.lua - This is the timecycle script. This controls whether Jimmy passes out after curfew...etc and so on. Passing out CAN be disabled by correctly editing this script.

Code: [Select]

main = function()
  repeat
    Wait(1000)
  until not Alive
end
 
F_AttendedClass = function()
  if IsMissionCompleated("3_08") and not IsMissionCompleated("3_08_PostDummy") then
    return
  end
  SetSkippedClass(false)
  PlayerSetPunishmentPoints(0)
end
 
F_MissedClass = function()
  if IsMissionCompleated("3_08") and not IsMissionCompleated("3_08_PostDummy") then
    return
  end
  SetSkippedClass(true)
  StatAddToInt(166)
end
 
F_AttendedCurfew = function()
  if not PedInConversation(gPlayer) and not MissionActive() then
    TextPrintString("You got home in time for curfew", 4)
  end
end
 
F_MissedCurfew = function()
  if not PedInConversation(gPlayer) and not MissionActive() then
    TextPrint("TM_TIRED5", 4, 2)
  end
end
 
F_StartClass = function()
  if IsMissionCompleated("3_08") and not IsMissionCompleated("3_08_PostDummy") then
    return
  end
  F_RingSchoolBell()
  local l_6_0 = PlayerGetPunishmentPoints() + GetSkippingPunishment()
end
 
F_EndClass = function()
  if IsMissionCompleated("3_08") and not IsMissionCompleated("3_08_PostDummy") then
    return
  end
  F_RingSchoolBell()
end
 
F_StartMorning = function()
  F_UpdateTimeCycle()
end
 
F_EndMorning = function()
  F_UpdateTimeCycle()
end
 
F_StartLunch = function()
  if IsMissionCompleated("3_08") and not IsMissionCompleated("3_08_PostDummy") then
    F_UpdateTimeCycle()
    return
  end
  F_UpdateTimeCycle()
end
 
F_EndLunch = function()
  F_UpdateTimeCycle()
end
 
F_StartAfternoon = function()
  F_UpdateTimeCycle()
end
 
F_EndAfternoon = function()
  F_UpdateTimeCycle()
end
 
F_StartEvening = function()
  F_UpdateTimeCycle()
end
 
F_EndEvening = function()
  F_UpdateTimeCycle()
end
 
F_StartCurfew_SlightlyTired = function()
  F_UpdateTimeCycle()
end
 
F_StartCurfew_Tired = function()
  F_UpdateTimeCycle()
end
 
F_StartCurfew_MoreTired = function()
  F_UpdateTimeCycle()
end
 
F_StartCurfew_TooTired = function()
  F_UpdateTimeCycle()
end
 
F_EndCurfew_TooTired = function()
  F_UpdateTimeCycle()
end
 
F_EndTired = function()
  F_UpdateTimeCycle()
end
 
F_Nothing = function()
end
 
F_ClassWarning = function()
  if IsMissionCompleated("3_08") and not IsMissionCompleated("3_08_PostDummy") then
    return
  end
  local l_23_0 = math.random(1, 2)
end
 
F_UpdateTimeCycle = function()
  if not IsMissionCompleated("1_B") then
    local l_24_0 = GetCurrentDay(false)
    if l_24_0 < 0 or l_24_0 > 2 then
      SetCurrentDay(0)
    end
  end
  F_UpdateCurfew()
end
 
F_UpdateCurfew = function()
  local l_25_0 = shared.gCurfewRules
  if not l_25_0 then
    l_25_0 = F_CurfewDefaultRules
  end
  l_25_0()
end
 
F_CurfewDefaultRules = function()
  local l_26_0 = ClockGet()
  if l_26_0 >= 23 or l_26_0 < 7 then
    shared.gCurfew = true
  else
    shared.gCurfew = false
  end
end


This should be enough script sources to get people started with learning lua and trying out their own bully mods. Any questions should be posted in this forum section and Red or I will try to answer them as best as we can. We will not respond to requests in this section. Requests need to go to the requests forum section where they belong and IF one of us or another modder has the time to make a requested mod....we will do so.

I will hold off on posting more script sources until I see where this goes since this is quite a large step for most of the community to attempt at this time....but this is the revolution of bully modding since now all hex editing should be stopped and people should give it a try to learn some lua modding instead. Everything that can be done via hex editing can be done via lua as well and is pretty easy to pull off for most things. Some things are a bit harder to do but I will do what I can to help everyone new to lua understand how things work with this new form of bully modding.


NOTES:

To COMPILE a script just open a windows command prompt window and type luac -o ArcRace1.lur scriptname.lua and just replace scriptname.lua with the script you want to try out. This will compile the script and name it ArcRace1.lur which is the script for the boys dorm arcade machine. Scripts like 1_01.lua need to be named the same as their compiled versions are (1_01.lur in this case) or any script with lib in the name.

I can explain more about this as needed.

For now....I hope everyone has had a great xmas and enjoy this gift since it has been a very long time coming.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Walter20210 on December 25, 2012, 10:56:10 PM
Cool :P
(I gonna test this tomorrow)
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: MadmaN on December 25, 2012, 11:10:43 PM
Don't forget...

You also need to make sure you have extracted your scripts.img to a folder that you can work from....backup your existing scripts.img and scripts.dir files for safekeeping incase you mess up and trust me....you will make mistakes with lua....and when you make scripts...you need to make a new scripts.img and scripts.dir file with the new modded script files in it or else bully will not see any changes you made.

I am releasing in a few days a special tool I made that will build brand new .img files  as well as build a new world.img file too which cannot easily be done with any tool out so far....its easier this way.

I will outline a proper tutorial for this in a day or two.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: c00ld0c26 on December 26, 2012, 12:36:55 AM
Ive been waiting for this for loooooooooooooooooooooooooong time. Awesome work Mad :D
Just 1 question...  I dont know how to script lua. where should I learn how? is there a tutorial?
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: MadmaN on December 26, 2012, 12:40:24 AM
Start off with this: http://www.bully-board.com/index.php?action=downloads;sa=view;down=58 (http://www.bully-board.com/index.php?action=downloads;sa=view;down=58)

I made the first issue of the modding magazine specifically for this.  :biggrin:
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Al Arlington on December 26, 2012, 06:54:34 AM
The script layout seems similar to GTA SA's. ._.


Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: SWEGTA on December 26, 2012, 07:43:45 AM
CMD just says that luac -o ArcRace1.lur scriptname.lua is not a command :/
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Red Blaster on December 26, 2012, 08:12:33 AM
The file has to be in the same folder as the lua compiler, and in CMD, you have to be in the file folder for the command to work.

Not just that, you need VS 2008.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: deadpoolXYZ on December 26, 2012, 08:25:13 AM
The file has to be in the same folder as the lua compiler, and in CMD, you have to be in the file folder for the command to work.

Not just that, you need VS 2008.

I did that but it just says that the system can't execute the specified program. I have visual studio 2010, so I didn't execute the visual studio 2008.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Red Blaster on December 26, 2012, 10:06:16 AM
Won't work. It's strictly coded for VS 2008.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: E32050TRA on December 26, 2012, 11:05:45 AM
I do not get lua all that much. How do i install the decompiler for lua? I already know how to do some stuff with lua. I just can't install it, and how to decompile scripts. Can anyone please help me please.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Al Arlington on December 26, 2012, 11:36:39 AM
Won't work. It's strictly coded for VS 2008.
So does that mean the PS2 script requires a earlier version of VS?
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Red Blaster on December 26, 2012, 11:52:17 AM
No. It's just that the compiler is strictly coded to be used with VS 2008.

I do not get lua all that much. How do i install the decompiler for lua? I already know how to do some stuff with lua. I just can't install it, and how to decompile scripts. Can anyone please help me please.

Make a folder, and place luac in it. Then install VS 2008. Then that's that. Follow the readme and the magazine.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: deadpoolXYZ on December 26, 2012, 12:12:06 PM
I installed VS 2008 but the problem is still there. Honestly, I didn't expect it to work in my first try.  :wacko:

(http://oi45.tinypic.com/2eqffwn.jpg)

Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Red Blaster on December 26, 2012, 12:56:30 PM
I suspect it's a missing .dll file...but with that said, are you opening the VS 2008 command line? Also, is luac in the Administrador folder? Is the file you want to compile also in there?

Don't worry, it's not like it worked right off the bat for me either.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: MadmaN on December 26, 2012, 02:47:00 PM
That is the problem with a executable that is compiled for debug rather then one compiled for release. It can cause some problems but if you explain exactly what you did step by step....I will see what I can do to help you get this working on your end.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: deadpoolXYZ on December 26, 2012, 03:00:57 PM
First of all, I located the "LUAC Bully" folder (with all the files inside) in C:\LUAC Bully.
Then I installed the VS 2008 with the vcredist_x86.exe.

After that I opened the RUN thing and wrote "cmd".

This is what I did in the cmd:

In the first line I wrote the location of the folder with the compiler.
In the second line I wrote the thing you showed in the readme.txt (the .lua file having another name).

(http://oi45.tinypic.com/2eqffwn.jpg)

Here is a pic of the folder in case I missed adding something to it.

(http://oi47.tinypic.com/25jv5m9.jpg)
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: MadmaN on December 26, 2012, 03:03:59 PM
Try typing luac just by itself and see if it runs.

if it runs then thats good.

if it doesn't then what we might have to do is add luac.exe to your windows path variable so u can simply run it from any folder in command window.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: MadmaN on December 26, 2012, 03:04:51 PM
also...if you have xfire...add me: madmancorp and I can help you a lot easier there.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: deadpoolXYZ on December 26, 2012, 03:10:11 PM
also...if you have xfire...add me: madmancorp and I can help you a lot easier there.

I already added you months ago, Im deadpool. :P

Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: SWEGTA on December 26, 2012, 03:31:19 PM
(http://i47.tinypic.com/2cfcbw3.png)
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: MadmaN on December 26, 2012, 03:50:14 PM
to fix the side by side configuration problem...you have to download and install either a trial version of visual studio 2008 or download it by some other means. That is the only way to fix that problem im afraid since the .dll files it requires are specific to visual studio directly due to the compiler being built with the debug flags in it and not built as a release binary.

Both Red and I had this problem at the start too...but since I have every version of visual studio....its no problem for me.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: SWEGTA on December 26, 2012, 03:57:16 PM
to fix the side by side configuration problem...you have to download and install either a trial version of visual studio 2008 or download it by some other means. That is the only way to fix that problem im afraid since the .dll files it requires are specific to visual studio directly due to the compiler being built with the debug flags in it and not built as a release binary.

Both Red and I had this problem at the start too...but since I have every version of visual studio....its no problem for me.


I have visual studio ultimate 2012, do I still need 2008?
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: MadmaN on December 26, 2012, 04:02:26 PM
yea...since this was compiled strictly for 2008.

If it was compiled as a release binary instead of a debug binary...then it would run no matter what version of vs or vs runtimes were installed.

When I get hold of fred...IF I can that is...I will see if he can compile a release binary for everyone since this is the only problem with releasing it.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: SWEGTA on December 26, 2012, 04:05:50 PM
yea...since this was compiled strictly for 2008.

If it was compiled as a release binary instead of a debug binary...then it would run no matter what version of vs or vs runtimes were installed.

When I get hold of fred...IF I can that is...I will see if he can compile a release binary for everyone since this is the only problem with releasing it.


Oh... Well alright then, hopefully it'll work and I'll get to do some new type of modding ^^
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: MadmaN on December 26, 2012, 04:12:22 PM
It should.

I can try helping you on xfire if you like. Might go a bit easier.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: JmTsHaW on December 27, 2012, 05:17:46 AM
The program's working fine now, I'm just having problems with scripting itself now.

"Luac:test.lua:10: unexpected symbol near 'ô'"
So I assume it's a problem with line 10 since it compiles that there bodyguard script fine (The script I have right now is a modified version of that script that's just supposed to start the player in 'the hole', display some text and remove the player from gravity when a certain button is pressed.)

This is what's on line 10, by the way:

"  TextPrintString(“Press button four to activate goodies.”, 1, 2)"

My script is also assuming " IsButtonPressed(4, 0)" followed by a repeat and a two second wait works correctly for checking if button four is pressed or not, if that's right.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Red Blaster on December 27, 2012, 07:50:01 AM
I am going to release a video tutorial in the coming days (maybe a week or two) explaining the basics as well as demonstrating several things to help you guys get the gist of scripting.

Maybe later then when I learn new techniques as well as the more difficult forms of scripting, I will release other videos.

Edit - JmTshaW, question: did you add an if statement to the bottom line?
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: E32050TRA on December 27, 2012, 09:26:54 AM
Ahhhh...I did everything write but it stil is not working...can someone explain to me step by step
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: JmTsHaW on December 27, 2012, 09:34:27 AM
Edit - JmTshaW, question: did you add an if statement to the bottom line?

No, I didn't. Should I?
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: deadpoolXYZ 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?
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Red Blaster 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
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: deadpoolXYZ 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.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: JmTsHaW 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
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Red Blaster 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
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: JmTsHaW on December 27, 2012, 12:43:03 PM
I tried it with 2 earlier and it didn't work either.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Red Blaster 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.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: MadmaN 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.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Red Blaster 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.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: MadmaN 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.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: deadpoolXYZ 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:

(http://screenshot.xfire.com/s/126733741-3.jpg)
(http://screenshot.xfire.com/s/126733737-3.jpg)
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: E32050TRA 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
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: MadmaN 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:
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: MadmaN 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.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: E32050TRA on December 27, 2012, 08:55:40 PM
Mad, what is the bodyguard script called actually?
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: MadmaN on December 27, 2012, 09:54:21 PM
If you are referring to my multi bodyguard script it is here http://www.bully-board.com/index.php?topic=17595.0 (http://www.bully-board.com/index.php?topic=17595.0)

scroll down to Red's message because he posted the fixed version of the script since the version I posted has a couple minor errors that prevent it from working that I never spotted due to not having touched this script in quite some time...since I am going in a different direction with multiple bodyguards for a mod.

This mod was really more of a learning curve for me to nail down a lot of the bully specific scripting so I could get a really good feel for how the script structure had to be done for bully itself rather then as a generic lua script that can run on its own.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Red Blaster on December 28, 2012, 01:09:37 AM
It's in another thread within this section.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Red Blaster on December 28, 2012, 01:11:13 AM
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:

(http://screenshot.xfire.com/s/126733741-3.jpg)
(http://screenshot.xfire.com/s/126733737-3.jpg)

Probs because I forgot the () in F_MissionSetup().

Anyways, congrats on fixing it.  ;)
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: xXxNarumi on December 28, 2012, 05:35:22 AM
This sorta reminds me of Packet Editor.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: deadpoolXYZ on December 28, 2012, 06:38:17 PM
When I spawn Gary as a bodyguard, he just hold hands with Jimmy like in the carnival date mission with Pinky.
By the way, Gary has his boss AI in the ide.img. Is this the problem?

(http://screenshot.xfire.com/s/126745986-3.jpg)


Bro fist! xD
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: MadmaN on December 29, 2012, 03:35:19 AM
Remove , true from the PedRecruitAlly line. Having , true will cause the spawned ped to hold hands with the player.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: deadpoolXYZ on December 29, 2012, 07:09:03 PM
Im having a problem giving fighting styles. When I start the arcade machine the game crashes.
This is the code:

Code: [Select]
MissionSetup = function()
local l_1_0 = 270
local l_1_1 = -110
local l_1_2 = 5.009
PlayerSetHealth(200)
AreaTransitionXYZ(0, l_1_0, l_1_1, l_1_2)
PedCreateXYZ(112, 271, -109, 5.009)
PedSetActionTree(112, "/Global/J_Grappler_A", "Act/Anim/J_Grappler_A.act")
end

In the bully magazine you used the “” in the actiontree code part while I used "". If I try to use “”
then the compilator shows me this: "luac: test.lua:8 unexpected symbol near `ô'"
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Red Blaster on December 29, 2012, 11:42:49 PM
Well first off, why are you using PedSetActionTree(112, etc.)? Using the ped ID won't change his or her style. To do that, you have to spawn a ped and have the ped referenced by a local. Then you use that local in place of the ped ID.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: MadmaN on December 30, 2012, 12:29:19 AM
I think the text got screwed up on the magazine a little bit with the "" marks since I did initially use "" marks and not the other ones that you say are in there.....I will have to check into that and maybe release a fixed issue.....also may be the custom font I am using too.

Red is right on this...you have to reference the ped using locals since assigning the action trees to a simple number will simply confuse the lua interpreter inside bully and it won't know what to make of it. I will give you a example maybe tomorrow if I have time that will hopefully help you with understanding how to assign locals for peds...it also makes the code easier to maintain too in the long run.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: deadpoolXYZ on December 30, 2012, 11:56:52 AM
I think the text got screwed up on the magazine a little bit with the "" marks since I did initially use "" marks and not the other ones that you say are in there.....I will have to check into that and maybe release a fixed issue.....also may be the custom font I am using too.

Red is right on this...you have to reference the ped using locals since assigning the action trees to a simple number will simply confuse the lua interpreter inside bully and it won't know what to make of it. I will give you a example maybe tomorrow if I have time that will hopefully help you with understanding how to assign locals for peds...it also makes the code easier to maintain too in the long run.

Don't bother to make an example, I fixed it using the locals that Red said.

EDIT:

This is exactly the same code that Madman used for his bodyguard mod with the exception that I removed the part that makes the ped a bodyguard and gave the fighting style to the ped instead of Jimmy. I used the locals but it still crashes.
If I give the fighting style to the player (gPlayer) instead of the ped it doesn't crash but I want the ped to have that fighting style.

Code: [Select]
ImportScript("\\Library\\LibTable.lua")
ImportScript("\\Library\\LibPed.lua")
local l_0_0 = false

MissionSetup = function()
local l_1_0 = 270
local l_1_1 = -110
local l_1_2 = 6.4000000953674
PlayerSetHealth(200)
AreaTransitionXYZ(0, l_1_0, l_1_1, l_1_2)
local l_1_3 = 216
local l_1_4, l_1_5, l_1_6 = PedGetPosXYZ(gPlayer)
local l_1_7 = PedCreateXYZ(l_1_3, l_1_4 + 1, l_1_5 + 1, l_1_6)
PedSetActionTree(l_1_3, "/Global/J_Ted", "Act/Anim/J_Ted")
end

MissionCleanup = function()
end

main = function()
repeat
Wait(0)
until l_0_0 ~= false
Wait(3000)
MissionSucceed()
end
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Red Blaster on December 30, 2012, 01:35:38 PM
I'll get to you tomorrow about this.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: JmTsHaW on December 30, 2012, 03:04:06 PM
Code: [Select]
ImportScript("\\Library\\LibTable.lua")
ImportScript("\\Library\\LibPed.lua")
local l_0_0 = false

MissionSetup = function()
local l_1_0 = 270
local l_1_1 = -110
local l_1_2 = 6.4000000953674
PlayerSetHealth(200)
AreaTransitionXYZ(0, l_1_0, l_1_1, l_1_2)
local l_1_3 = 216
local l_1_4, l_1_5, l_1_6 = PedGetPosXYZ(gPlayer)
local l_1_7 = PedCreateXYZ(l_1_3, l_1_4 + 1, l_1_5 + 1, l_1_6)
PedSetActionTree(l_1_3, "/Global/J_Ted", "Act/Anim/J_Ted")
end

MissionCleanup = function()
end

main = function()
repeat
Wait(0)
until l_0_0 ~= false
Wait(3000)
MissionSucceed()
end

Try changing
PedSetActionTree(l_1_3, "/Global/J_Ted", "Act/Anim/J_Ted")
to
PedSetActionTree(l_1_7, "/Global/J_Ted", "Act/Anim/J_Ted")

It worked for me when I modified the original script to spawn two bodyguards instead of one.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: deadpoolXYZ on December 30, 2012, 03:43:22 PM
Thanks it worked.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: deadpoolXYZ on December 30, 2012, 07:29:32 PM
I figured out (or at least I hope  :P) that SoundPlayInteractiveStream controls the background music and SoundSetHighIntensityStream controls the fighting/bike theme. The problem is that I don't know how to use it properly.

This is what I tried:

Code: [Select]
MissionSetup = function()
local l_1_0 = 270
local l_1_1 = -110
local l_1_2 = 6.4000000953674
PlayerSetHealth(200)
AreaTransitionXYZ(0, l_1_0, l_1_1, l_1_2)
SoundPlayInteractiveStream("MS_TenementsLow.rsm")
SoundSetHighIntensityStream("MS_TenementsMid.rsm")
end

When I start the arcade machine there is no background music nor fighting music.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Red Blaster on December 30, 2012, 10:59:07 PM
That's because you're forgetting to set the volume level at the end. Add a comma after the rsm" part, then write MUSIC_DEFAULT_VOLUME. Or, you can also add a number (For example, 0.60000002384186, 500, 0).

Also, you're wrong.

SoundSetMidIntensityStream is for bike. High is for fighting.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: JmTsHaW on December 31, 2012, 08:24:17 AM
I experimented with faction attitudes and wrote down all the IDs, which are basically the same order as in pedpop.dat.

0 - Prefects
1 - Nerds
2 - Jocks
3 - Dropouts/Townies
4 - Greasers
5 - Preppies
6 - Non-Clique Students
7 - Cops
8 - Teachers
9 - Townspeople
10 - Shopkeepers
11 - Bullies
12 - ? (Crashes upon load)
13 - Player

An example of changing the attitude for the nerds to hate the player:
Code: [Select]
PedSetTypeToTypeAttitude(1, 13, 0)
SetFactionRespect(1, 0)
The first line sets the nerds to attack the player on sight, and the second line sets their 'respect percentage' in the menu to 0%.

EDIT: In another faction-related subject, you can change the faction of a script-created ped using: 
Code: [Select]
PedSetFaction(l_1_7, 1)This example in particular when added onto the debug bodyguard  script madman has on the first page will turn whoever you spawned as your bodyguard into a nerd.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: xXxNarumi on December 31, 2012, 08:30:43 AM
12 doesnt seem to crash on me
I dont think any1 even spawns on 12 and there is 1 removed faction from bully
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: SWEGTA on December 31, 2012, 09:59:02 AM
How do I make it lock doors?
I want the script to lock all doors outside the school like stores and such, how does one do this?
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Red Blaster on December 31, 2012, 10:06:00 AM
There is a code for locking doors, but usually those are in area scripts, which are not fully decompiled, thus making overriding them impossible until they're fully decompiled.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: SWEGTA on December 31, 2012, 10:37:47 AM
Okay :/
Also, how do I rotate vehicles and peds?
They seem to spawn facing one way
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: MikerBarba on December 31, 2012, 10:58:37 AM
Damn! this is sooo cool!, i'll be starting Lua by tomorrow :3
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Red Blaster on December 31, 2012, 11:26:02 AM
Okay :/
Also, how do I rotate vehicles and peds?
They seem to spawn facing one way

I haven't checked for vehicles, but peds is done through PedFaceXYZ.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: deadpoolXYZ on December 31, 2012, 11:33:35 AM
Thanks Red the music works now.

Is there a way to make a bodyguard to not disappear if he/she gets far enough from you?
In the missions your bodyguard never disappears.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Red Blaster on December 31, 2012, 12:04:31 PM
Hiring a bodyguard through lua will make that bodyguard never disappear.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: JmTsHaW on December 31, 2012, 12:56:21 PM
Any way to get the bodyguard to spawn on a bike?
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Red Blaster on December 31, 2012, 01:25:36 PM
Yeah, but I don't remember the exact code.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: SWEGTA on December 31, 2012, 03:47:45 PM
How do I rotate the peds then? :P

Also, log in to xfire man :D
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: MadmaN on December 31, 2012, 05:37:06 PM
Sry I have not been around on xfire to be on hand for any help but I have been taking a very much needed break.

This is just so that anyone on my list doesn't wonder where I went all of a sudden....I will resume being on xfire regularly probably in a few days.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: SWEGTA on December 31, 2012, 07:43:17 PM
How do you close the school gates? Both the main gate and the parking lot that is?
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: MadmaN on January 02, 2013, 01:24:33 PM
I can give you code that will not only allow you to close them or what not...but open and close them with a button press  :biggrin: .

I can also do the same for ANY door in the game at any time.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: SWEGTA on January 02, 2013, 02:16:55 PM
I can give you code that will not only allow you to close them or what not...but open and close them with a button press  :biggrin: .

I can also do the same for ANY door in the game at any time.


Please do, my good sir :)
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: MadmaN on January 03, 2013, 03:33:55 PM
I will outline a simple script for you that demonstrates this type of code and it will be a modification of 1_01.lua so you will have to restart the game in order to test it.

I use that as my central testing point for script modding anyways.  :biggrin:
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: SWEGTA on January 04, 2013, 05:45:14 AM
Great! :P
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: deadpoolXYZ on January 06, 2013, 03:38:22 PM
Is there a way to give a ped the thing between the stats and the fighting style?

Example:

         F_Jocks.
J_Grappler..null
....Straf_Wrest.

I tried with LoadAnimationGroup but it didn't work.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: MadmaN on January 06, 2013, 03:48:09 PM
you mean assign animation groups like as listed in default.ide for the specific ped?

If so...then yes but its complicated.

My tables version of the player switcher will do that but it will take time to explain how to do it.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Red Blaster on January 06, 2013, 04:08:41 PM
Is there a way to give a ped the thing between the stats and the fighting style?

Example:

         F_Jocks.
J_Grappler..null
....Straf_Wrest.

I tried with LoadAnimationGroup but it didn't work.

Those are animation groups, and it should work...whenever I load "Boxing" but don't give Derby Boxing, he still fights without any glitches.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: c00ld0c26 on January 08, 2013, 01:48:26 AM
For some reason I cant make the lua script fille... I do all the stages and after I do the "luac -o ArcRace1.lur 1_01.lua" I cant countinue after that stage nothing else.. Can someone give a more detailed explanesion? Or Teamview me?
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: deadpoolXYZ on January 08, 2013, 12:01:18 PM
For some reason I cant make the lua script fille... I do all the stages and after I do the "luac -o ArcRace1.lur 1_01.lua" I cant countinue after that stage nothing else.. Can someone give a more detailed explanesion? Or Teamview me?

A .lur file (ArcRace1.lur in your case) should be created in the folder where the compiler is. Then you just have to replace the normal ArcRace1.lur file from scripts.img with the new one using imgtool.

Make sure to write the location of the compiler first.

Like: "cd C:\LUAC Bully"
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: c00ld0c26 on January 08, 2013, 12:10:44 PM
I did the cmd (cd : ect ) and when I do the luac -o ArcRace1.lur 1_01.lua it dosnt work
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: SWEGTA on January 08, 2013, 01:11:38 PM
I did the cmd (cd : ect ) and when I do the luac -o ArcRace1.lur 1_01.lua it dosnt work


cd c:\LUAFOLDER
luac -o ArcRace1.lur luafile.lua
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: c00ld0c26 on January 08, 2013, 01:52:34 PM
This is the exact thing I did : cd D:Lua
then I did luac -o ArcRace1.lur 1_01.lua when I do that cmd it says : unknown command something like that.
and the complitor is at D/Lua.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: deadpoolXYZ on January 08, 2013, 02:29:24 PM
Have you installed visual studio 2008 express? You need it to get the compiler working.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: JmTsHaW on January 08, 2013, 05:49:58 PM
I just keep a spare copy of cmd.exe in my Lua folder so I don't have to go through all that stuff involving guiding the cmd to your Lua folder, so try that.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Scoff on January 09, 2013, 09:16:15 AM
Hey,can someone help me? I made a lua script for change Jimmy fighting style,but when i go compile this script, appear this:

unexpected symbol near 'ô'
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: SWEGTA on January 09, 2013, 11:42:37 AM
Hey,can someone help me? I made a lua script for change Jimmy fighting style,but when i go compile this script, appear this:

unexpected symbol near 'ô'

There's a symbol/letter/number near a certain part of the script. This error usually includes a line part where it tells you which line the error is at. Use notepad ++ to see these lines.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: c00ld0c26 on January 09, 2013, 01:10:55 PM
I did install it. What do I do with it thought?
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: MadmaN on January 10, 2013, 03:52:27 PM
unexpected symbol near 'ô' occurs for many reasons.

Most of the time it is simply due to a invalid character in the code syntax itself...or a missing or extra end statement or a if or while in the wrong place.

Please post your full code using the bbcode button that has a # on it and I will look it over and see if I can spot the problem.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Scoff on January 10, 2013, 03:54:42 PM
I get the code on Bully Magazine Issue.I only change J_Grappler_A for P_Grappler_A.Here it is:

Code: [Select]
ImportScript(“\\Library\\LibTable.lua”)
ImportScript(“\\Library\\LibPed.lua”)
local l_0_0 = false
MissionSetup = function()
  local l_1_0 = 270
  local l_1_1 = -110
  local l_1_2 = 6.4000000953674
  PlayerSetHealth(200)
  AreaTransitionXYZ(0, l_1_0, l_1_1, l_1_2)
  local l_1_3 = 25
  local l_1_4, l_1_5, l_1_6 = PedGetPosXYZ(gPlayer)
  local l_1_7 = PedCreateXYZ(l_1_3, l_1_4 + 1, l_1_5 + 1, l_1_6)
  PedSetActionTree(gPlayer, “/Global/P_Grappler_A”, “Act/
Anim/P_Grappler_A.act”)
  PedRecruitAlly(gPlayer, l_1_7, true)
  PedMakeAmbient(l_1_7)
end
MissionCleanup = function()
end
main = function()
  repeat
    Wait(0)
  until l_0_0 ~= false
  Wait(3000)
  MissionSucceed()
end
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: JmTsHaW on January 10, 2013, 04:23:35 PM
Code: [Select]
  PedSetActionTree(gPlayer, “/Global/P_Grappler_A”, “Act/
Anim/P_Grappler_A.act”)

I don't know if you just did that to shorten out the line when you pasted your code here, but if you're using that line in your script why is half of the code on a new line?
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: deadpoolXYZ on January 10, 2013, 04:31:17 PM
Code: [Select]
  PedSetActionTree(gPlayer, “/Global/P_Grappler_A”, “Act/
Anim/P_Grappler_A.act”)

I don't know if you just did that to shorten out the line when you pasted your code here, but if you're using that line in your script why is half of the code on a new line?

Because Madman wrote the code exactly like that in the magazine. It's not a big problem...
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: JmTsHaW on January 10, 2013, 04:35:53 PM
^ Ah, I see. I never meant to sound harsh or anything if anyone took that the wrong way :happy:

Code: [Select]
  PedSetActionTree(gPlayer, “/Global/P_Grappler_A”, “Act/Anim/P_Grappler_A.act”)
Try replacing those two lines with the combined version of those lines  like above and your code should work.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Scoff on January 10, 2013, 04:41:08 PM
^ Ah, I see. I never meant to sound harsh or anything if anyone took that the wrong way :happy:

Code: [Select]
  PedSetActionTree(gPlayer, “/Global/P_Grappler_A”, “Act/Anim/P_Grappler_A.act”)
Try replacing those two lines with the combined version of those lines  like above and your code should work.

I tried your code,but still the same error.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: JmTsHaW on January 10, 2013, 04:47:09 PM
^ Usually when that error is given, it displays a number which is the exact line the error is on, what number does it say?
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Scoff on January 10, 2013, 04:49:57 PM
^ It says 1
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: JmTsHaW on January 10, 2013, 04:53:09 PM
It's the "s being italicised, remove them and replace every instance of them with normal, non-italised versions.

You will know when you've done it right because the section of code the "s encase will turn different colours depending on the zone.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Scoff on January 10, 2013, 05:05:01 PM
It's the "s being italicised, remove them and replace every instance of them with normal, non-italised versions.

You will know when you've done it right because the section of code the "s encase will turn different colours depending on the zone.

Thanks for the help! Now it compile normally.Time to test de style!
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: JmTsHaW on January 10, 2013, 05:36:40 PM
Having CameraFollowPed set to a script spawned ped such as the one in the debug bodyguard script actually makes the camera follow that bodyguard around.

I still haven't got the hang of button mapping yet, but setting the camera to switch between the bodyguard and Jimmy on a button press could actually be useful for some mods.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: PHjohnyvincent on January 11, 2013, 09:17:17 PM
(http://img803.imageshack.us/img803/5627/screenshot1wl.jpg)



:(
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Red Blaster on January 11, 2013, 10:22:18 PM
Did you install Virtual Studio 2008?
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: PHjohnyvincent on January 13, 2013, 01:05:41 AM
Nope
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Evolution on January 13, 2013, 05:29:17 AM
^ Well, you need to install it then. -_-
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: JmTsHaW on January 13, 2013, 07:38:48 AM
Is there a certain line of code that allows spawned peds to use vehicles such as bikes?

Like how the Greasers annoyingly keep stealing the bikes that are left alone in New Coventry.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Red Blaster on January 13, 2013, 07:54:12 AM
Nope

You have to download it and use the VS 2008 CMD for the compiler to work. MadmaN made this quite clear, too.

Is there a certain line of code that allows spawned peds to use vehicles such as bikes?

Like how the Greasers annoyingly keep stealing the bikes that are left alone in New Coventry.

Yes, there is.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: JmTsHaW on January 13, 2013, 10:59:15 AM
What is it? I've been trying to get peds to ride bikes for ages now.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: MadmaN on January 13, 2013, 05:47:16 PM
It is:

PedWarpIntoCar(cop, CopCar) -- First value is the ped id number (it can be assigned to a local too) and the second value is the vehicle id number (this can also be assigned to a local)

You can also remove a ped from a vehicle using:

PedWarpOutOfCar (cop, CopCar)

The warp out of car code works the same as the warp into car.

I will post a script example of proper usage a bit later tonite if I get time.  :biggrin:
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: JmTsHaW on January 14, 2013, 11:12:37 AM
^ Thanks. Can you also show an example of a working button-press script when you can?
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: James Maurice on March 24, 2013, 05:35:13 AM
|XF|-MadmaN[AR], can you send the video "how to make fighting style with lua", because i want to make fighting style
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: MadmaN on March 30, 2013, 05:55:33 PM
I never made any videos.

I suggest downloading the bully modding magazine issue number 1 once I reupload it since it has been staticly linked to my server since I released it due to a file size limit on file uploads for the forum....My server has been down for a while now since I took it down so I can redo everything and once thats done I will redo the link in the download section for the modding magazine.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Walter20210 on April 06, 2013, 05:04:32 AM
I wanna ask what the command repeat does

I never get a way to make it work.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Red Blaster on April 06, 2013, 10:15:51 AM
It means to repeat commands that you put underneath it until a certain criteria is met (you end it with "until" and write then write the action that terminates the loop).

For instance, in my one on one/survival mod, I set a repeat loop so that the camera shifts between the characters until someone is knocked out or all opponents are cleared (until PedGetHealth(idExample1) <= 0).
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Walter20210 on April 06, 2013, 03:05:57 PM
for example :
 
Code: [Select]
  repeat
  PedSetActionTree(l_1_7, "/Global/J_Grappler_A", "Act/J_Grappler.act")
  wait(10000)
  PedSetActionTree(l_1_7, "/Global/J_Melee_A", "Act/J_Melee.act")
  wait(10000)
  PedSetActionTree(l_1_7, "/Global/J_Striker_A", "Act/J_Striker_A.act")
  wait(10000)
  PedSetActionTree(l_1_7, "/Global/J_Mascot", "Act/J_Mascot.act")
  until
  PedGetHealth(l_1_7, 300)

like this?
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Red Blaster on April 07, 2013, 03:53:57 PM
Not quite...I'll have to make an example for you.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: deadpoolXYZ on April 07, 2013, 04:18:04 PM
Red I needed help with PedGetHealth too. Can I use it like this?

If PedGetHealth then
Blablabla
End
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Red Blaster on April 07, 2013, 06:59:36 PM
Yep. I use an if statement for PedGetHealth to give points to a winner in my one on one mod.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: MadmaN on April 08, 2013, 01:46:06 PM
Red I needed help with PedGetHealth too. Can I use it like this?

If PedGetHealth then
Blablabla
End

Here is an example of one way you can use PedGetHealth:

Code: [Select]
    if PedGetHealth(gPlayer) < 150 then
      PedSetHealth(gPlayer, 150)
    end

Here is another example...it is a bit more complex from the 6_B.lua script:

Code: [Select]

Stage2_Objectives = function()
  if not l_0_11 then
    if PedGetHealth(l_0_2) / GaryHealth * 100 < 75 then
      l_0_14 = true
    end
  elseif not l_0_12 and PedGetHealth(l_0_2) / GaryHealth * 100 < 50 then
    l_0_14 = true
  end
  if not l_0_13 and PedGetHealth(l_0_2) / GaryHealth * 100 < 1 then
    PedSetActionNode(gPlayer, "/Global/6_B/AdjustGravity", "Act/Conv/6_B.act")
    PedSetActionNode(l_0_2, "/Global/6_B/AdjustGravity", "Act/Conv/6_B.act")
    l_0_32 = true
  end
end

If you have any further questions I can try to help you out with them.  :cool:
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: deadpoolXYZ on April 08, 2013, 05:10:26 PM
Thanks!

I wanted to make Johnny boss theme to play when his life decreased (like a custom theme for a ped).
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: MadmaN on April 08, 2013, 09:29:14 PM
It is certainly possible this way.

You will just have to play around with the code structure a little bit to figure out how, where and when you want it to activate and so forth.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Walter20210 on April 11, 2013, 08:02:21 AM
A question how the next commands works?
PedSetAlpha
PedShowHealthBar
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: DarbyHarringtonMind on April 11, 2013, 02:28:31 PM
what is 1_01 ????
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: MadmaN on April 11, 2013, 04:44:52 PM
what is 1_01 ??? ?

This is the start of the game right after the cutscene with Jimmy's mom and stepdad in the car and then the cutscene with the secretary.

This is the only storyline mission that I have completely intact and I actually use a highly modded version of that mission script for testing new code out when working on mods.

I can post the 1_01 script in the scripts section if I haven't already....pretty sure I did release that one.

A question how the next commands works?
PedSetAlpha
PedShowHealthBar

For this....PedSetAlpha I have not messed around with that lua code yet...but I think this may have something to do with how light or dark the ped appears compared to the surrounding world.....but not fully sure yet.

PedShowHealthBar I do know about and this is used to display a healthbar on the right hand side of the screen. Think of during halloween when Gary and Pete follow you around for a bit....both of their healthbars show up on the screen. This command does that. HOWEVER, there is a slight issue with this code....You can only show two healthbars maximum at any given time but you can however display the circle shaped healthbar at the feet of every bodyguard if you want to use several bodyguards and still see their health. This is the same as when you z target any ped you will generally see a round healthbar at their feet on the ground.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Walter20210 on April 11, 2013, 05:35:56 PM
A question how the next commands works?
PedSetAlpha
PedShowHealthBar
For this....PedSetAlpha I have not messed around with that lua code yet...but I think this may have something to do with how light or dark the ped appears compared to the surrounding world.....but not fully sure yet.

PedShowHealthBar I do know about and this is used to display a healthbar on the right hand side of the screen. Think of during halloween when Gary and Pete follow you around for a bit....both of their healthbars show up on the screen. This command does that. HOWEVER, there is a slight issue with this code....You can only show two healthbars maximum at any given time but you can however display the circle shaped healthbar at the feet of every bodyguard if you want to use several bodyguards and still see their health. This is the same as when you z target any ped you will generally see a round healthbar at their feet on the ground.
For this....PedSetAlpha I have not messed around with that lua code yet...but I think this may have something to do with how light or dark the ped appears compared to the surrounding world.....but not fully sure yet.

PedSetAlpha, is for make a ped be less visible (Like a ghost or something like that)

PedShowHealthBar, i think it was just making the boss health and the one that are on their feets i see it can be used on many peds but i dont know how it works i see something like "name" inside of that code
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: DarbyHarringtonMind on April 12, 2013, 01:06:25 AM
ah..... :jajaja:
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: xbetstyler on April 12, 2013, 03:08:01 AM
I think the PedSetAlpha is useful when we play like zombie mod.Make zombie less visible and hard to see.
This is how i used the code and it make jimmy invisible.

Code: [Select]
main = function()
  F_MissionSetup()
  gMissionRunning = true
  while gMissionRunning do
  PedSetAlpha(gPlayer, 0) repeat 
  until gMissionRunning ~= false
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: SWEGTA on April 12, 2013, 09:21:32 AM
^Delicious!
I'll try it out today and see if any more spices are needed for it.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Walter20210 on April 12, 2013, 09:30:51 AM
This makes me remeber Counter strike Zombie plague xD
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: deadpoolXYZ on April 12, 2013, 02:38:15 PM
Just a curious question but lua scripting is related to visual basic or c#?
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: MadmaN on April 12, 2013, 03:24:34 PM
It is similar enough that if you can code in those languages....then picking up lua will be even easier since it does have some things in common regarding syntax and such. Most programming languages have some similarities to one another but each one has its own strengths and weaknesses.....and some are intended for specific purposes too.....

lua is a very fast language in regards to the lua interpreter...whether the script is compiled or not.

The only reason that the lua scripts in bully are compiled is to keep ppl like us from seeing any of the code and changing the game around. That is the ONLY reason why those files are compiled since lua can run without needing to be compiled...but bully for some reason seems to require them to be compiled before it can use the scripts.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Black Norton on April 14, 2013, 04:31:56 AM
Can You teach me to use this MOD???
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: MadmaN on April 14, 2013, 05:10:13 AM
Can You teach me to use this MOD???

It is hard to simply "teach" lua since I am only one person and don't have the resources to teach every single person that asks.

It would be in your best interests to download the Bully Modding Magazine issue 1 from teh downloads section in this forum and download the lua compiler......and just read through the magazine carefully since I focus pretty heavily on lua and just try some of the things I talk about in that magazine....plus look in teh scripting section of this forum and look at some of the script sources already posted.

That should get you started on messing about with lua since it is better to read up on it first.

If you look on google for the lua programmers handbook (I think that is what it is called....cant remember) also give that a read even if it may seem complicated since it will give a better in depth explanation on what lua is ....what it can do and so forth and just experiment with the scripts already posted here and see what happens.

That is a better way to learn a language since hands on is easier then just trying to soak in lessons that might be too complicated to understand all at once.

If the magazine is too hard to understand then just ask questions here but please try to read it through first and see if you can grasp what I am explaining since it does no good to not give it a honest try and then ask for help since it would be kinda defeating the purpose of even asking.  8)
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: TASK FORCE_141 on April 19, 2013, 03:17:10 AM
what is Bike_Gen.lua???
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: deadpoolXYZ on April 19, 2013, 12:39:15 PM
what is Bike_Gen.lua???

A script that spawns random bikes around bullworth.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: DarbyHarringtonMind on April 19, 2013, 08:36:58 PM
what is Bike_Gen.lua???

A script that spawns random bikes around bullworth.


ah..
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Walter20210 on April 23, 2013, 08:05:37 AM
How to i can make a ped have is range of view i mean
Like when you hit a prefect you see in the radar how long he sees
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: MadmaN on April 23, 2013, 07:49:27 PM
I have that in my rather immense notes.

I will post a howto on that soon as I can make it since its a couple of lua codes that does that trick.
Title: Re: *RELEASE* - Bully LUA Script Sources (just a few)
Post by: Walter20210 on April 23, 2013, 08:28:01 PM
=D

I will wait ;)