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


Author Topic: Returning To Modding  (Read 11933 times)

0 Members and 1 Guest are viewing this topic.

Offline AlphaTech

  • LostInSpace
  • Sr. Member
  • ***
  • Posts: 758
  • Gender: Male
  • The name's AlphaTECH, whatca need help with?! :)
    • View Profile
Re: Returning To Modding
« Reply #15 on: February 10, 2016, 09:00:42 AM »
It's only temporary inactivity it'll start back up soon enough if you notice the guess count it is still active.

Offline DaBOSS54320

  • Hero Member
  • ****
  • Posts: 3,398
  • Gender: Female
    • View Profile
Re: Returning To Modding
« Reply #16 on: February 10, 2016, 07:00:35 PM »
I don't see why you even need a template. You need a while loop, a few if statements, and a few calls to PedSetActionNode. Unless you do something really fancy...

Is popularity all you mod for? Inactivity shouldn't be a concern, do it for yourself and the people that are active, we'll appreciate it and give ya feedback. It might not be a huge community, but I kind of like it like that. You get to know everybody better and it really feels like a community, and if you release a mod, sure it won't feel like a huge release 1000s are going to see, but you're sharing it with ya homiez on BB and that should feel nice. Workin' together n' shit.

Offline Unknownsoldier

  • Hero Member
  • ****
  • Posts: 2,773
    • View Profile
Re: Returning To Modding
« Reply #17 on: February 11, 2016, 05:25:01 PM »
(what daboss said)
but yeah u dont need all the ImportScripts at the beginning of the script. and the most useless thing that i always see is that SObjTest.lua and SZone shit on the top.
if you really wanna import something, like a separate mod file, you'd do it in a function, cause i discovered that when i tried using the importscript out of a function it won't work.
Code: [Select]
function MissionSetup()
   AreaTransitionXYZ(270, -110, 6)
   PlayerSetHealth(PedGetMaxHealth(gPlayer))
end

function MissionCleanup()
  collectgarbage()
end

function main()
  while true do
      Wait(0)
  end
end

and u can also add the function to load all animation groups, Boss has a thread posted regarding that.
« Last Edit: February 11, 2016, 05:27:05 PM by Unknownsoldier »

Offline DaBOSS54320

  • Hero Member
  • ****
  • Posts: 3,398
  • Gender: Female
    • View Profile
Re: Returning To Modding
« Reply #18 on: February 11, 2016, 07:59:26 PM »
^ Looks like a pretty solid setup but remember the area code when calling AreaTransitionXYZ.

About that ImportScript not working outside of a function, that actually sounds pretty strange. Based on my observations and knowledge of LUA, this is how everything works. Each running script gets its own little address space in Bully, and that script can't access variables from other scripts with a few exceptions such as gPlayer and the shared table (basically a table all scripts have access to, used for sharing variables). When ImportScript is called, it simply runs a script in the address space of the script that the function was called from. So if that script had functions or variables in it, they would be in your script's address space by the time the script finished running. Now you may be saying "but boss, those scripts can't run, they don't even have a main function!" and I could see why you'd think this, but in fact the main function isn't actually a normal thing in LUA, it's just something Bully does (and probably other games do too, but not LUA itself). This is how a LUA script will run (in order):

1) The entire script will be read top to bottom executing any instructions as it goes along, such as creating variables, tables, functions, calling functions, anything like that. When the script comes across a function declaration (like function MissionSetup() ... end or MissionSetup = function() ... end) it simply puts the function in memory and has that variable (in this example, "MissionSetup") reference it. Same essentially goes with tables having variables reference them but that's a different discussion. If you want one of your created functions to run, you could call them yourself and they'd run perfectly fine. Unless you do call a function yourself, no functions have run yet.

2) Now that the script has run and all functions are loaded and such, it is time for Bully to call some functions in your script. If it is a mission script (like ArcRace1.lur), Bully will call MissionSetup first, then main, and MissionCleanup when the mission is done (success or fail). If its just a normal script (like STimeCycle.lur), only main will be called. If the script is being imported (through ImportScript) then Bully will not call any functions (but of course any functions the script itself calls will run), the script will just run through normally, and since most scripts are structured in a way that mostly functions are the only thing in the outer level of the script (like nothing else is outside of any functions), then this will usually just load the functions from a certain script (but of course still run any code in the script that isn't in any function, unless of course that function is called).

So really I don't see any reason why ImportScript wouldn't work for you, it is still a part of your script and in theory should be executed.

Offline Unknownsoldier

  • Hero Member
  • ****
  • Posts: 2,773
    • View Profile
Re: Returning To Modding
« Reply #19 on: February 11, 2016, 09:54:58 PM »
remember the area code when calling AreaTransitionXYZ.
shit it's been a while i probably suck now lol

Offline AlphaTech

  • LostInSpace
  • Sr. Member
  • ***
  • Posts: 758
  • Gender: Male
  • The name's AlphaTECH, whatca need help with?! :)
    • View Profile
Re: Returning To Modding
« Reply #20 on: February 12, 2016, 02:13:00 AM »
Importscript works for me you can check in my Petes Missing mod and see it run the other .lur inside the scripts.img and dir. I usually see this as overwritting a script without delay or crashes.
Code: [Select]
Importscript("BossHealth.lua")
ImportScript("Ped Spawns.lua")
ImportScript("BossStyles.lua")
ImportScript("Animations.lua")
ImportScript("FailValue.lua")
ImportScript("WinValue.lua")

Some imports that I did in the past worked perfectly.

Offline Bully_Lover13

  • Full Member
  • ***
  • Posts: 119
    • View Profile
Re: Returning To Modding
« Reply #21 on: February 12, 2016, 04:49:23 AM »
^What boss said. You shouldn't mod for fame or anything.

Offline Unknownsoldier

  • Hero Member
  • ****
  • Posts: 2,773
    • View Profile
Re: Returning To Modding
« Reply #22 on: February 12, 2016, 03:46:25 PM »
Importscript works for me you can check in my Petes Missing mod and see it run the other .lur inside the scripts.img and dir. I usually see this as overwritting a script without delay or crashes.
Code: [Select]
Importscript("BossHealth.lua")
ImportScript("Ped Spawns.lua")
ImportScript("BossStyles.lua")
ImportScript("Animations.lua")
ImportScript("FailValue.lua")
ImportScript("WinValue.lua")

Some imports that I did in the past worked perfectly.
Is it out of a function?

Offline DaBOSS54320

  • Hero Member
  • ****
  • Posts: 3,398
  • Gender: Female
    • View Profile
Re: Returning To Modding
« Reply #23 on: February 12, 2016, 10:25:23 PM »
Remember LUA is case sensitive guys. ImportScript and Importscript are two different things. Make sure to ImportScript.

Also remember ImportScript expects the name of the compiled .lur file, but with a .lua extension. For example if you have "my mod.lua" and you compile to "mod001.lur" and you want to import it, you should do ImportScript("mod001.lua").

Offline AlphaTech

  • LostInSpace
  • Sr. Member
  • ***
  • Posts: 758
  • Gender: Male
  • The name's AlphaTECH, whatca need help with?! :)
    • View Profile
Re: Returning To Modding
« Reply #24 on: February 12, 2016, 11:22:03 PM »
Remember LUA is case sensitive guys. ImportScript and Importscript are two different things. Make sure to ImportScript.

Also remember ImportScript expects the name of the compiled .lur file, but with a .lua extension. For example if you have "my mod.lua" and you compile to "mod001.lur" and you want to import it, you should do ImportScript("mod001.lua").

Obviously it didn't take me two seconds to figure that out. Another way to setup a better running mission is to seperate its scripts. I noticed that combining plenty scripts at once can make it harder for you to fix an error ingame. "The name of the files I am speaking of."

Once I was doing a test mission to see if I could force the game to start a mini game. I made a little zombie hoard where it starts at 6 then so on and so fourth.

I noticed when jumbling everything it would always glitch and freeze somewhere but when seperating them it usually fixed this. So every round I did 6+ zombies plus a round which after round 24 it crashes.

What I did was use ImportScript to get spawn values each time 6 peds get knocked out. This is a good way to create mini games or want a mission where 24+ characters are coming at you. What I noticed though is that after 40+ spawns the game starts to lock peds off targets sometimes attack each other lol the game gets  crazy.

One thing though when creating a table or kill table how would a set the ped values?

Would it be
if AllPedsDead(zombies) and MiniGame = true then
Minigame = false
end

So the value for zombies would what? If I could explain better lets say. How would I let the game know the value of ped knockouts without writing a bunch of script.

I wrote over 24 pedisdead when I did that minigame what is the easier way lol.
« Last Edit: February 12, 2016, 11:31:27 PM by AlphaTech »

Offline Unknownsoldier

  • Hero Member
  • ****
  • Posts: 2,773
    • View Profile
Re: Returning To Modding
« Reply #25 on: February 13, 2016, 01:55:52 AM »
Remember LUA is case sensitive guys. ImportScript and Importscript are two different things. Make sure to ImportScript.

Also remember ImportScript expects the name of the compiled .lur file, but with a .lua extension. For example if you have "my mod.lua" and you compile to "mod001.lur" and you want to import it, you should do ImportScript("mod001.lua").
(WTF WHEN I CLICKED QUOTE I SAW AN ORANGE TAB APPEAR SAYING "LOADING" IN ORANGE LETTERS)

Wtf dude that's weird. I've always thought ImportScript("my mod.lua") would work. not really understanding how the function works. I know what it does and how it's used, but I mean like how it would be made or something.

Offline DaBOSS54320

  • Hero Member
  • ****
  • Posts: 3,398
  • Gender: Female
    • View Profile
Re: Returning To Modding
« Reply #26 on: February 14, 2016, 07:25:23 PM »
ImportScript simply runs a script in another script's address space (the one that called ImportScript). So any variables (or functions) created in that script that you "imported" (technically ran) will be available to the script that imported it. If this doesn't make sense remember that functions are indeed created like any other variable. If you try to use the function somewhere in the script before it was created, then it will not work. This isn't to say a function has to be created above the code where you use it (like in C), but it simply means the part of the script that defines the function has to run before using it, which is usually done fine since first the whole script runs, putting all functions and everything outside of other functions into memory, THEN main runs (since Bully calls main after the script runs as I just explained), so you can call whatever function you want in main and it'll work fine (well assuming the function was in global scope, as in not in another function or something like that, since the function it is in may not of run).

I may be rambling a bit but it is nice to be able to understand this. A function is just like any other variable in LUA.

Code: [Select]
-- Trying to print the variable 'x' will not work as x wasn't created yet
TextPrintString("X: "..x,1,1)
x = 1

function runMyFunc()
  -- Since 'runMyFunc' is called after 'myFunc' was created, 'myFunc' should be in memory and can be called
  myFunc()
end

-- Trying to print the function 'myFunc' will not work as 'myFunc' wasn't created yet
myFunc()
function myFunc()
  TextPrintString("my func",1,1)
end

runMyFunc()

It actually gets slightly more complex then that but, those basics are what is important in this situation. So really to answer your question as clearly as possible.

Code: [Select]
-- script.lua (compiled to myscript.lur)
function x()
  TextPrintString("x called",1,1)
end
TextPrintString("imported",1,1)

-- arcrace1.lua (compiled to ArcRace1.lur)
ImportScript("myscript.lua")

When the script gets to that ImportScript("myscript.lua") (which is immediately since it has nothing else), that myscript.lur runs, and that function x is put into memory for ArcRace1.lur to use, and "imported" is printed (because remember the script just simply runs, the functions aren't all just pulled out).

Offline Unknownsoldier

  • Hero Member
  • ****
  • Posts: 2,773
    • View Profile
Re: Returning To Modding
« Reply #27 on: February 15, 2016, 06:05:55 AM »
.dude my brain is having an unpleasant orgasm after reading this.

Offline AlphaTech

  • LostInSpace
  • Sr. Member
  • ***
  • Posts: 758
  • Gender: Male
  • The name's AlphaTECH, whatca need help with?! :)
    • View Profile
Re: Returning To Modding
« Reply #28 on: February 19, 2016, 06:54:13 PM »
Well I am about to come back from my trip so i'll get back to modding. I won't be using my desktop though it has some errors with the windows which wont let me log in. I tried everything from getting a new version of windows 7 64 bit installed to a new HDD but it just wont work anymore. Something is up with the hardware and software which a 1TB RPM HDD wont install a new version of windows. It keeps saying "error windows not installed restarting". Maybe I just need a whole new HDD port in general but that's gonna take a while.

Offline MadmaN

  • Bully-Board Admin Team
  • Newbie
  • *
  • Posts: 0
  • Gender: Male
  • Biblio-Techa Mods (retired)
    • View Profile
Re: Returning To Modding
« Reply #29 on: February 20, 2016, 03:52:57 AM »
I will stillt finish helping you with that....and I apologise for having been silent via pm about this as I have been....busy.

I will upload something that should help you fix the issue and failing that...all you have to do is just get an external adaptor to hook that drive straight to your laptop via usb and rip your files off of it that way.

I should have things uploaded and sent to you in a few days....just been bogged down lately and playing catchup is ..... wearing me out.