Bully-Board

Bully Modding Section => Bully Modding => TUTORIALS => Topic started by: DaBOSS54320 on July 03, 2013, 06:52:54 AM

Title: Tutorial: Constantly Running LUA Scripts
Post by: DaBOSS54320 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
Title: Re: Tutorial: How to Run Lua Scripts in Free Mode
Post by: c00ld0c26 on July 03, 2013, 07:01:34 AM
Is Mad okey that u post this?
Title: Re: Tutorial: How to Run Lua Scripts in Free Mode
Post by: MadmaN 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.
Title: Re: Tutorial: How to Run Lua Scripts in Free Mode
Post by: Phap on July 05, 2013, 10:29:43 PM
Great, now Darby's code is released.
Hope Rise is okay with that.
Title: Re: Tutorial: How to Run Lua Scripts in Free Mode
Post by: Walter20210 on July 05, 2013, 11:15:47 PM
:D
Title: Re: Tutorial: How to Run Lua Scripts in Free Mode
Post by: c00ld0c26 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.
Title: Re: Tutorial: How to Run Lua Scripts in Free Mode
Post by: Evolution on July 06, 2013, 12:46:18 AM
Nice work DaBoss. Your work is awesome.

It's not his work.
Title: Re: Tutorial: How to Run Lua Scripts in Free Mode
Post by: c00ld0c26 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...
Title: Re: Tutorial: How to Run Lua Scripts in Free Mode
Post by: Walter20210 on July 06, 2013, 01:00:30 AM
Rise to honor is not okey with this

Madman already says he was ok with this.
Title: Re: Tutorial: How to Run Lua Scripts in Free Mode
Post by: Red Blaster on July 06, 2013, 03:06:33 AM
I just noticed the Derby code. I edited it out.
Title: Re: Tutorial: How to Run Lua Scripts in Free Mode
Post by: ultrasbully on July 06, 2013, 09:18:54 AM
loadanimationgroup dont work in free mode..
anyone has any suggestion..?
Title: Re: Tutorial: How to Run Lua Scripts in Free Mode
Post by: Mick3Mouse on July 06, 2013, 10:24:56 AM
it works, you just type it wrong. Becuz mine worked
Title: Re: Tutorial: How to Run Lua Scripts in Free Mode
Post by: Evolution on July 06, 2013, 11:45:27 AM
How the hell is that important?
Title: Re: Tutorial: How to Run Lua Scripts in Free Mode
Post by: Phap on July 06, 2013, 04:59:36 PM
Another about to break out
Title: Re: Tutorial: How to Run Lua Scripts in Free Mode
Post by: MadmaN 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:


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.
Title: Re: Tutorial: How to Run Lua Scripts in Free Mode
Post by: MadmaN on July 06, 2013, 08:49:50 PM
@romeos2013 and Evolution

It would be best if the two of you wish to argue to do it via pm or somewhere else since this will turn people away from the subject of this topic.
Title: Re: Tutorial: How to Run Lua Scripts in Free Mode
Post by: c00ld0c26 on July 06, 2013, 08:51:45 PM
How the hell is that important?
then why you talked to me in the first place?

Romeos knock it off.

Mad, Romeos starts the argues doing : "Do I know you?" ect...
also :
Well, Ye, You teached me this before DaB0ss released that.
When this got released I got shocked, cuz I remembered Mad, that u asked me not to share this currectly.
Propebly wanted to test this around before u release.
Anyway, Good Job guys.
Title: Re: Tutorial: How to Run Lua Scripts in Free Mode
Post by: MadmaN on July 06, 2013, 09:26:06 PM
Ok
sorry Madman

Apology accepted m8.  8)

I just don't like to see arguing like that since it really just serves no purpose in the end. Much like most of the violence in the world today. Just makes more problems then before each time....rofl.

Quote
Well, Ye, You teached me this before DaB0ss released that.
When this got released I got shocked, cuz I remembered Mad, that u asked me not to share this currectly.
Propebly wanted to test this around before u release.
Anyway, Good Job guys.

I really didn't wish this to be released really for some time so I could figure out a way thats much more stable and guaranteed to work each time.....but the method I showed DaBoss happens to be a alternate way that I long knew about that loads scripts the same way that Rise and I have been doing for some time now...only the way he and I have been doing this differs a bit. But this method gives the same exact result.
Title: Re: Tutorial: How to Run Lua Scripts in Free Mode
Post by: DaBOSS54320 on July 06, 2013, 11:17:21 PM
RESPONDING TO ALL ABOVE REPLIES!
I have discovered this by myself, it is madman's original and I infact did know this, but did not ask him about it. I figured this out myself, I also got the source script for STimeCycle.lur i in one of mad's posts (As said in my post)
Mad, I would appreciate you confirming this message a bit so that people are aware of the facts.

And to Mad, sorry to argue with you but you must remember thing's wrong, I actually did figure this out myself. You didn't teach me. You may be confusing me with another person you taught.
This info has been modified into my original post.
Title: Re: Tutorial: How to Run Lua Scripts in Free Mode
Post by: DaBOSS54320 on July 06, 2013, 11:24:19 PM
I just noticed the Derby code. I edited it out.
Didn't know you wanted to hide action nodes too. The Grim Peeper taught me about action nodes.
Title: Re: Tutorial: How to Run Lua Scripts in Free Mode
Post by: DaBOSS54320 on July 07, 2013, 02:56:39 AM
DaBOSS54320 (Me)
Quote
Do you mind if I post a tutorial on running scripts in freemode?

Rise to Honor
Quote
yeah if you put credit
Rise to Honor was the original one to find this mod. Note: He didn't teach me, he just found it before me. I originally though madman found it.
Title: Re: Tutorial: How to Run Lua Scripts in Free Mode
Post by: Red Blaster on July 07, 2013, 02:59:35 AM
It's not me that wants action nodes hidden, it's Rise to Honor. Grim Peeper learned most, if not all of it, from him.

So for now, it has to remain a secret. So please, keep it that way. I don't want hostilities to break out over this.
Title: Re: Tutorial: How to Run Lua Scripts in Free Mode
Post by: MadmaN on July 09, 2013, 01:18:34 AM
RESPONDING TO ALL ABOVE REPLIES!
I have discovered this by myself, it is madman's original and I infact did know this, but did not ask him about it. I figured this out myself, I also got the source script for STimeCycle.lur i in one of mad's posts (As said in my post)
Mad, I would appreciate you confirming this message a bit so that people are aware of the facts.

And to Mad, sorry to argue with you but you must remember thing's wrong, I actually did figure this out myself. You didn't teach me. You may be confusing me with another person you taught.
This info has been modified into my original post.

My apologies for getting slightly mixed up about that....lol

I shall stand corrected on that since I have taught quite a few people various little tidbits and I do at times get things confused due to my really shit memory which tends to fail me at the worst possible times....hah.
Title: Re: Tutorial: How to Run Lua Scripts in Free Mode
Post by: DaBOSS54320 on July 09, 2013, 02:53:46 AM
^ That's very understandable, I know that you help a lot of people at once. Who doesn't mess up every once in a while?
Title: Re: Tutorial: How to Run Lua Scripts in Free Mode
Post by: ultrasbully on July 09, 2013, 03:04:49 PM
i've tried this method in my bodyguard script but why it not working.?
i mean the bodyguard do not spawn.
Title: Re: Tutorial: How to Run Lua Scripts in Free Mode
Post by: DaBOSS54320 on July 09, 2013, 10:05:51 PM
^ I've had trouble with spawning too. I usually use this to disable punishments, put in action nodes, switch fighting styles, etc. I know it's probably possible to spawn though. Try to make it by pressing a button they spawn. if IsButtonPressed(0,0)
Title: Re: Tutorial: How to Run Lua Scripts in Free Mode
Post by: perfectozzyozborne on August 13, 2013, 06:10:39 AM
Nice :) It looks useful to use  :cheernutz:
Title: Re: Tutorial: Constantly Running LUA Scripts
Post by: Mick3Mouse on April 24, 2014, 02:44:58 PM
(i'm typing this so i dont need to go to 2nd site evrytime i go here.  sorry)
Title: Re: Tutorial: Constantly Running LUA Scripts
Post by: WhenLifeGivesYouLemons on April 25, 2014, 09:01:00 AM
(i'm typing this so i dont need to go to 2nd site evrytime i go here.  sorry)
(http://lepakjackwedding.files.wordpress.com/2014/02/dancing_potato_gif_by_artist119-d634szy.gif)

Did this because of you.
Title: Re: Tutorial: Constantly Running LUA Scripts
Post by: Mick3Mouse on April 25, 2014, 09:06:15 AM
how sexy