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


Author Topic: Tutorial: Constantly Running LUA Scripts  (Read 13159 times)

0 Members and 1 Guest are viewing this topic.

Offline DaBOSS54320

  • Hero Member
  • ****
  • Posts: 3,398
  • Gender: Female
    • View Profile
Tutorial: Constantly Running LUA Scripts
« on: July 03, 2013, 06:52:54 AM »
I have updated this tutorial to simplify it.
The below code is source code of a STimeCycle.lur script (Thanks to |XF|-MadmaN[AR] for releasing the source of the original STimeCycle.lur script). This script, as it suggests is related the the time cycle of the game. Thus, always running (Yes even before the clock is displayed on screen in the tutorial mission) Copy and paste it into notepad++ and then treat the main function as you would if you were putting it into a ArcRace1.lur script (Assuming you did that before this tutorial).
Tip: You cannot use MissionSetup function or MissionCleanup function. You can make a function for setting things up, but not by those names. They are not called in this script.
I have slightly modified some code here and inserted notes.
Code: [Select]
main = function()
  Wait(500) -- Wait 0.5 seconds. This is needed for some scenarios.
  -- Setup code goes here.
  repeat
    -- Constantly running code goes here.
    Wait(0) -- Waits 0 seconds. Seems pointless but leave this in!
  until not Alive
end
 -- In most cases, you can ignore everything below here
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
« Last Edit: June 06, 2015, 08:21:00 PM by DaBOSS54320 »

Offline c00ld0c26

  • The D0c
  • Moderator
  • Can't Get Enough
  • *****
  • Posts: 5,137
  • Gender: Male
  • Just a dood doing dood things.
    • View Profile
    • My channel.
Re: Tutorial: How to Run Lua Scripts in Free Mode
« Reply #1 on: July 03, 2013, 07:01:34 AM »
Is Mad okey that u post this?

Offline MadmaN

  • Bully-Board Admin Team
  • Newbie
  • *
  • Posts: 0
  • Gender: Male
  • Biblio-Techa Mods (retired)
    • View Profile
Re: Tutorial: How to Run Lua Scripts in Free Mode
« Reply #2 on: July 05, 2013, 08:09:23 PM »
I am ok with this.

However I will not allow the secret to changing player skins to be made public. I want the modding community to discover that secret on their own since it will just ruin everything Rise and I have worked for these past couple years on making a player model selector mod.

Offline Phap

  • Full Member
  • ***
  • Posts: 216
  • Gender: Male
    • View Profile
Re: Tutorial: How to Run Lua Scripts in Free Mode
« Reply #3 on: July 05, 2013, 10:29:43 PM »
Great, now Darby's code is released.
Hope Rise is okay with that.

Offline Walter20210

  • Hero Member
  • ****
  • Posts: 1,102
  • Gender: Male
  • I keep loving the old things :P
    • View Profile
    • YouTube Account
Re: Tutorial: How to Run Lua Scripts in Free Mode
« Reply #4 on: July 05, 2013, 11:15:47 PM »
:D
« Last Edit: July 06, 2013, 03:08:23 AM by Walter20210 »

Offline c00ld0c26

  • The D0c
  • Moderator
  • Can't Get Enough
  • *****
  • Posts: 5,137
  • Gender: Male
  • Just a dood doing dood things.
    • View Profile
    • My channel.
Re: Tutorial: How to Run Lua Scripts in Free Mode
« Reply #5 on: July 06, 2013, 12:32:30 AM »
Well
I admit, Mad teached me this and asked me not to release, thats why I ask but, Walter, u sure he said he isn't okey with it? Cuz he just posted that he is okey with this.

Offline Evolution

  • Elitist
  • *********
  • Posts: 13,574
  • Gender: Male
    • View Profile
Re: Tutorial: How to Run Lua Scripts in Free Mode
« Reply #6 on: July 06, 2013, 12:46:18 AM »
Nice work DaBoss. Your work is awesome.

It's not his work.

Offline c00ld0c26

  • The D0c
  • Moderator
  • Can't Get Enough
  • *****
  • Posts: 5,137
  • Gender: Male
  • Just a dood doing dood things.
    • View Profile
    • My channel.
Re: Tutorial: How to Run Lua Scripts in Free Mode
« Reply #7 on: July 06, 2013, 12:48:37 AM »
Mad is the one who found this.
He explained me how to do this quite long ago, I guess I can tell since DaBOSS  just did a tutorial on this well...

Offline Walter20210

  • Hero Member
  • ****
  • Posts: 1,102
  • Gender: Male
  • I keep loving the old things :P
    • View Profile
    • YouTube Account
Re: Tutorial: How to Run Lua Scripts in Free Mode
« Reply #8 on: July 06, 2013, 01:00:30 AM »
Rise to honor is not okey with this

Madman already says he was ok with this.
« Last Edit: July 06, 2013, 03:09:11 AM by Walter20210 »

Offline Red Blaster

  • The BB Arab
  • More Than Halfway There
  • *****
  • Posts: 5,649
  • Gender: Male
  • Hi
    • View Profile
Re: Tutorial: How to Run Lua Scripts in Free Mode
« Reply #9 on: July 06, 2013, 03:06:33 AM »
I just noticed the Derby code. I edited it out.

Offline ultrasbully

  • Jr. Member
  • **
  • Posts: 22
    • View Profile
Re: Tutorial: How to Run Lua Scripts in Free Mode
« Reply #10 on: July 06, 2013, 09:18:54 AM »
loadanimationgroup dont work in free mode..
anyone has any suggestion..?

Offline Mick3Mouse

  • Obam3mouse
  • Bullworth Junkie
  • ****
  • Posts: 4,343
  • Gender: Male
  • Major Mick3Mouse Algie Hunter
    • View Profile
    • My youtube
Re: Tutorial: How to Run Lua Scripts in Free Mode
« Reply #11 on: July 06, 2013, 10:24:56 AM »
it works, you just type it wrong. Becuz mine worked

Offline Evolution

  • Elitist
  • *********
  • Posts: 13,574
  • Gender: Male
    • View Profile
Re: Tutorial: How to Run Lua Scripts in Free Mode
« Reply #12 on: July 06, 2013, 11:45:27 AM »
How the hell is that important?

Offline Phap

  • Full Member
  • ***
  • Posts: 216
  • Gender: Male
    • View Profile
Re: Tutorial: How to Run Lua Scripts in Free Mode
« Reply #13 on: July 06, 2013, 04:59:36 PM »
Another about to break out

Offline MadmaN

  • Bully-Board Admin Team
  • Newbie
  • *
  • Posts: 0
  • Gender: Male
  • Biblio-Techa Mods (retired)
    • View Profile
Re: Tutorial: How to Run Lua Scripts in Free Mode
« Reply #14 on: July 06, 2013, 05:11:50 PM »
I AM ok with releasing how to run lua scripts this way since this method is not exactly something I wish to hold back from the community.

Rise happens to be the one who originally figured this method out and he then taught me how to do it and he deserves the credit for it not me.

The only thing I can take credit for is teaching DaBOSS54320 and a couple others how to do this.


I have no idea if Rise is/was ok with this since I did kinda forget to ask him about it....but since the cat is outta the bag anyways on this I don't think it will hurt much.

Rise and I however will be coming up with a way better way to load our own scripts up since this method IS flawed and does not work perfectly so please use this method with caution.

The following bugs exist with this specific method:

  • If you get busted the loaded script will reset and not load back up. The only way to load it back up is to load from a save.
  • If you pass out or get knocked out....the same thing above will happen.

Meanwhile...I will be looking into a way to embed a mod menu directly into the ingame menu for executing any mods which should make things much easier....but this will take some time and careful planning.

I will be talking to Rise about this and see what we can do. I also am currently looking into adding some things from the original canis canem edit which were removed from Bully: Scholarship Edition...but this also will take some time.

As soon as I redo my main system (the one I am on now) I will release some things for everyone.....a new .IMG editing tool which is command line only...but it has its own shell so it should not be too hard to figure out how to use this.....it also has batch file support to automate use and it is way better then the Bully Img Editor that I long ago released...but it is NOT meant as a full replacement for that....however it is meant as a companion tool and I have already released it for testing to one person already.

I also will be releasing a few more .lua script sources that are original scripts from Bully and will try to comment them so everyone has a way to understand how those work a bit easier.

I also am working as fast as I can to write and release a excel spreadsheet that will detail all of the lua commands and their full syntax (minus a couple things like the player model switching codes) since I still wish everyone to figure that out on their own due to how long Rise and I have worked on this mod.
« Last Edit: July 06, 2013, 05:18:01 PM by |XF|-MadmaN[AR] »