Bob's Character classes


Adds character classes to the game.

Tweaks
3 months ago
0.16 - 2.0
109K

g Overriding class spawning loadout.

15 days ago

Hi, newbie modder (At least for factorio) here.
I noticed your interface for the classes only seems to let me add spawning equipment to all classes via the global equipment list that is called before the classes add and remove their own equipment. (I couldn't say, edit fighter or builders starting kit/respawn kit while leaving balanced unaffected.)

I've tried toying with the reference passed by getClasses to see if I could influence a classes behavior from there, but after one or two days of fiddling with this at the onInit phase I've only failed to to get it to display any response to my changes here.

Am I missing something about how the class interface is supposed to operate here?

14 days ago

I've not looked at the remote interface for this mod in a long time. From having a quick look, it seems like you should be able to call get_classes, make your changes, then call add_classes. Disclaimer: I haven't tested this.

Anything returned by a remote interface is sandboxed. You get a copy. It isn't a reference to an object in another mod.

13 days ago
(updated 13 days ago)

Last time I tried adding a class it duplicated the class (With both duplicates using the old settings) but I can give it a shot. Thank you for the idea I'll get back to you if it works since I could imagine this mod would be much more useful to other mod packs if the base settings had known procedures for overriding them.

Hopefully this works out and thanks again.

13 days ago
(updated 12 days ago)

Ok so I've learned two things.

The example call to addclasses in the control.lua (Starting as an example at line 145) for bobsclasses may be slightly off as the interface seems to expect a table with {name=some-name, class=some-class} instead of just a table with a raw class in it. If you just pass a class table to bobsclasses it will throw a control error on startup that prevents the game from starting. So the example call seems to be misleading.

So for example, my call to update fighter to be more turret focused crashed later when I used.
remote.call("bobclasses", "add_classes", {name="bob-fighter", class=myFighter})
Instead of
remote.call("bobclasses", "add_classes", myFighter)
Since it expects a paired element unlike what the example shows.
(My fighter was based on a get-classes copy of the fighter class.)

The second is if you try to add an existing class it throws an error that seems to be due to there being duplicate classes with a UI element (Despite the classes being indexed to their name, so one with an identical name such as "bob-fighter" should be overwriting the old one at line 141.)

Error while running event bobclasses::on_cutscene_cancelled (ID 187)
Gui element with name bob_class_fighter already present in the parent element.
stack traceback:
[C]: in function 'add'
bobclasses/control.lua:883: in function 'add_class_gui_classes'
bobclasses/control.lua:851: in function 'draw_class_gui'
bobclasses/control.lua:822: in function <bobclasses/control.lua:813>
stack traceback:
[C]: in function 'exit_cutscene'
base/script/freeplay/freeplay.lua:122: in function 'handler'
core/lualib/event_handler.lua:72: in function <core/lualib/event_handler.lua:70>

This seems to happen at the same line regardless of whether I let the cutscene play or cancel.

Edit from the next day: I'm going to fiddle around with trying to fix this but it still looks like its appending something that should be overwriting, despite the key value pairs at play...
I'm also sorry for assuming the factorio interfaces passed by reference, that was just a default of return values via lua AFAIK so I hadn't imagined the factorio would do a deep-copy or something.

12 days ago
(updated 11 days ago)

https://www.pasteboard.co/xhQ2LDy7SnZm.png

Alright I was able to get the altered fighter to load technically by altering its .button.name to not match the vanilla fighter, but this simply shows that inserting a class via a name string that precisely matches the one that was used to fetch a class from "get_classes" is inserting the class as a new entry to the table of storage.classes instead of overwriting the old table element for fighter.

This is unlikely a case of user error: I'm using the exact key I used to fetch fighter to insert a new fighter to the table, I know this since I'm using a name variable for both the fetch from the table returned by get_classes and the insertion in add_classes. I think what may be happening is that lua is inflicting us with string equivalence hyjinks.

Edit: I tried even using the name key that had been inserted into the fighter classes table via the add_class function in bobs-classes control.lua at line 140 to insert the fighter back in, and the fighter somehow still became a duplicate. Luas string comp is very much likely causing us a headache. Or at least me, given this would probably be an absurdly low priority issue on your end given seablocks likely your main concern right now.

11 days ago

I think I have a fix. Can you send me your mod so I can test with it?

10 days ago
(updated 10 days ago)

I'm going to triple check the dependencies on my mod to make sure the dependencies I've declared are good enough to make sure this launches first try then get it sent to you. (This is my first try at modding factorio so the level of organization leaves a lot to be desired....)

Its been in dire need of refactoring which I've put off for a while. (Unhinged content that was going to be pushed off into its own mod is still stuck in the core mod.)

New response