1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Compiler - Lightweight Mod Compiler

Discussion in 'Loader Imports' started by ModGuy, Apr 22, 2012.

  1. ModGuy

    ModGuy Club Regular Content Creator

    Joined:
    Feb 17, 2011
    Messages:
    1,754
    Likes Received:
    22
    So I decided to put this here as it would only be for advanced use.

    Take some AS3 code, place it in the included template and compile.
    Don't need Flash or Flex for this AFAIK.

    AS3->AS3 SWF Compiler (Includes Vanilla SDT template):
    https://hostr.co/FDkUZJyao4GL
    http://www.solidfiles.com/d/40b0bfab95/Compiler_Alt.zip

    Free SWF decompiler for code analysis:
    http://www.free-decompiler.com/flash/

    25-08-14 SWF version flag added to match SDT.
    19-01-14 Broken links repaired, mirror added.
    05-12-13 JPEXS Decompiler added.
    23-08-13 haXe compiler removed, useless really.
    14-05-13 Dead links update.
    08-11-12 Update to conform with new loader mod detection and initialization.
    11-11-12 Added alternate compiler for pure AS3.
    05-01-12 Alt compiler now supports vanilla SDT.
     
  2. gollum

    gollum Avid Affiliate

    Joined:
    Dec 31, 2011
    Messages:
    218
    Likes Received:
    0
    is there some sort of API for the loader?

    variables seem to be pretty straightforward, but what about functions like cough, setHands or setColor?
     
  3. ModGuy

    ModGuy Club Regular Content Creator

    Joined:
    Feb 17, 2011
    Messages:
    1,754
    Likes Received:
    22

    What?
    Think about what it is that you're saying.
    If there was an API, one would have had to have been developed for it.
    Now why would I do that when there's something like 2 modders here with any AS3 understanding?

    No, and it wouldn't make the code any easier than it already is.
    Look over the MANY examples on the forum.
    And by that I mean all loader SWF mods.
    A decompiler makes short work of analysing code.
     
  4. anonymous

    anonymous Club Regular

    Joined:
    Feb 16, 2011
    Messages:
    2,925
    Likes Received:
    10
    Is there a such way of knowing the names of all of the variables and functions available?
     
  5. Faceless

    Faceless Club Regular Content Creator

    Joined:
    Jun 12, 2011
    Messages:
    1,118
    Likes Received:
    22
    Mm, yes. Definitely have to second Anon. The biggest hangup for me is wondering what the hell the objects are called.
     
  6. ModGuy

    ModGuy Club Regular Content Creator

    Joined:
    Feb 17, 2011
    Messages:
    1,754
    Likes Received:
    22
    No.
    Although it's clearly time for someone to start indexing them.
    You could implement demonsters debugger.
     
  7. anonymous

    anonymous Club Regular

    Joined:
    Feb 16, 2011
    Messages:
    2,925
    Likes Received:
    10
    If such a thing existed, I'd be much more inclined to bother to learn.
     
  8. gollum

    gollum Avid Affiliate

    Joined:
    Dec 31, 2011
    Messages:
    218
    Likes Received:
    0
    I know it's been a while, but I've tried my luck with the haxe compiler and whenever I load a mod compiled with it, it moves the game-frame to the edge of the flashwindow.

    Code:
    class Mod {
    	static var m;
    	static function main() {
    		var l = flash.Lib.current.stage.getChildByName("root1");
    		if( l.toString().indexOf("boot")==-1 ){
    			modCode(cast(l));
    		}else{
    			trace("LOAD IN THE LOADER!");
    		}
    	}
    	public static function modCode(main){
    		main.unloadMod();
    	}
    }
    
    It shouldn't do anything, I stripped it down to see if I screwed something up, so it's the same as the template.

    attached is a picture of what it looks like and the swf

    maybe someone can help me fix this or tell me how to move the frame back to centre
     

    Attached Files:

    • SDT.jpg
      SDT.jpg
      File size:
      41 KB
      Views:
      773
    • test.swf
      File size:
      3.5 KB
      Views:
      48,745
  9. ModGuy

    ModGuy Club Regular Content Creator

    Joined:
    Feb 17, 2011
    Messages:
    1,754
    Likes Received:
    22
    It does have that problem, I'll see if I can sort it out.
     
  10. superduper2019

    superduper2019 Casual Client Content Creator

    Joined:
    Sep 10, 2012
    Messages:
    101
    Likes Received:
    12
    Ok, as one who can't afford Flash and doesn't want to download it illegally, I'm really interested in this (also for other purposes)

    Thanks a lot, but....

    I'm a programmer myself, but I'm too stupid right now to find out, how to use this...

    So there ist the template:
    Code:
    class Mod {
    	static var m;
    	static function main() {
    		var l = flash.Lib.current.stage.getChildByName("root1");
    		if( l.toString().indexOf("boot")==-1 ){
    			modCode(cast(l));
    		}else{
    			trace("LOAD IN THE LOADER!");
    		}
    	}
    // I have to put my code here, right?
    		main.unloadMod();
    	}
    }
    When I use either
    flash.Lib.current.stage.getChildByName("Her").something = something;
    or
    Her.something = something;

    it doesn't work, as Haxe can't find "Her"...

    I guess this is the case, because when compiling Haxe doesn't know about the SDT.swf's variables, but how can I make it know,

    respectively, how am I supposed to use this? Am I misunderstanding it?

    Anyway, thanks to ModGuy for his emphasis!
     
  11. gollum

    gollum Avid Affiliate

    Joined:
    Dec 31, 2011
    Messages:
    218
    Likes Received:
    0
    try main.her.something

    €dit @modguy:

    could you spare some time and help me with registering the mods to be unloaded once the unload button is clicked/the char is reloaded?

    I tried something I found in another mod:

    Code:
    class Mod {
    	static var m;
    	static var z = new MovieClip();
    	static function main() {
    		var l = flash.Lib.current.stage.getChildByName("root1");
    		if( l.toString().indexOf("boot")==-1 ){
    			modCode(cast(l));
    		}else{
    			trace("LOAD IN THE LOADER!");
    		}
    	}
    	public static function modCode(main){
    		m = cast(main);
    		main.registerUnloadFunction(undo);
    		main.updateStatus("Mod enabled");
    		z.addEventListener(Event.ENTER_FRAME, update);
    		main.unloadMod();
    	}
    	public static function update(e){
    		m.updateStatus("updating");
    	}
    	public static function undo(){
    		m.updateStatus("Mod disabled");
    		z.removeEventListener(Event.ENTER_FRAME, update);
    	}
    }
    but that's not working :/

    also: I found where I had to tweak to mess up the penis and body sliders, but I can't find the breastslider. any hints? :)
     
  12. ModGuy

    ModGuy Club Regular Content Creator

    Joined:
    Feb 17, 2011
    Messages:
    1,754
    Likes Received:
    22
    Use...

    Code:
    class Mod {
    	static function main() {
    		var l = flash.Lib.current.stage.getChildByName("root1");
    		if( l.toString().indexOf("boot")==-1 ){
    			modCode(cast(l));
    		}else{
    			trace("LOAD IN THE LOADER!");
    		}
    	}
    	public static function modCode(main){
    		//CODE HERE!
    		//Her would be: main.her
    		flash.Lib.current.stage.align = cast("");
    		main.unloadMod();
    	}
    }
    EDIT:

    Fix for alignment included above:

    Code:
    flash.Lib.current.stage.align = cast("");
    Basically resetting the align to center.
     
  13. gollum

    gollum Avid Affiliate

    Joined:
    Dec 31, 2011
    Messages:
    218
    Likes Received:
    0
    thanks, you are awesome :D
     
  14. ModGuy

    ModGuy Club Regular Content Creator

    Joined:
    Feb 17, 2011
    Messages:
    1,754
    Likes Received:
    22
    If you're just trying to delete an object on unload, this should be sufficient:

    Code:
    registerToRemove(mc);
    From the dev guide, make sure to call that function from the loader object.
     
  15. gollum

    gollum Avid Affiliate

    Joined:
    Dec 31, 2011
    Messages:
    218
    Likes Received:
    0
    having some problems there. probably just me being tired, but anyway:

    main.registerToRemove(mc), mc being the mod-object ("this" basically) didn't work due to modCode being static. so I extracted another class "Nested"
    Code:
    var nested:Nested = new Nested(main) { 
    	public function new(main) { 
    		main.updateStatus("Mod enabled");
    		main.him.max_penis_size = 10; 
    	}
    main.registerToRemove(nested);
    main.registerUnloadFunction(disable() { main.updateStatus("Mod disabled"); }
    
    was compiled (by now I screwed up Nested so badly I can't reconstruct it, I'll try again tomorrow to give you the proper code, above is an example) caused both messages to appear on loading the mod (resetcharonchange=1 in settings), but the mod remaining in memory
     
  16. ModGuy

    ModGuy Club Regular Content Creator

    Joined:
    Feb 17, 2011
    Messages:
    1,754
    Likes Received:
    22
    If I understand correctly you just want the compiled mod to unload after doing stuff.
    Yeah, that's what main.unloadMod(); does, you don't need to do anything else.
    The mod remains in memory because I don't bother unloading SWFs after use in the event of costumes etc.
    Resetting should remove them, probably.
     
  17. gollum

    gollum Avid Affiliate

    Joined:
    Dec 31, 2011
    Messages:
    218
    Likes Received:
    0
    not quite. since I'm stuck with static methods, I'd like to get rid of the objects completely.
    if you load the mod, then reload the loader without killing the (standalone) player and load another haxe mod again, you get an error message.
    my current guess is that the stage-casts in main() produce a nullpointer since they only load the stage once, but when you reload the game, the stage changes.

    €dit:

    nevermind, I can simply check for null and prevent the crash. I'll try to figure something out tomorrow :)
     
  18. ModGuy

    ModGuy Club Regular Content Creator

    Joined:
    Feb 17, 2011
    Messages:
    1,754
    Likes Received:
    22
    Huh, I've never tried > 1 test at a time. I like to keep things separate.

    EDIT: Noticed I'm still using stupid detection for Compiler mods, I'll fix that soon.

    EDIT2: Performed some fixes, old haXe mods will hopefully still work.

    Start using this template:

    Code:
    class Mod {
    	static function main() {
    	}
    	public static function initl(main){
    		//CODE HERE!
    		flash.Lib.current.stage.align = cast("");
    		main.unloadMod();
    	}
    }
    Expect fix in next loader.

    EDIT3:

    New Compiler and Loader released, weird bug but should be sorted (avoided).
     
  19. gollum

    gollum Avid Affiliate

    Joined:
    Dec 31, 2011
    Messages:
    218
    Likes Received:
    0
    I hate to repeat myself, but I must:

    :D

    I'll test it later

    edit:

    old haxe mods still work. under the above mentioned circumstances they don't reload, but at least the error message vanished.
    new mods work perfectly
     
  20. gollum

    gollum Avid Affiliate

    Joined:
    Dec 31, 2011
    Messages:
    218
    Likes Received:
    0
    can you recommend a good decompiler?
    currently I'm stuck with the trial version of sothink swfdec and that's pretty punishing, since I have to search line for line cause the searchfunction is disabled. but it's the only one able to give me the sdt-source...