Good vs. Evil

  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
99


Even if you're just doing the quick and easy thing, if you plan to expand it later, you should make sure you write it in a maintainable and extensible way, even if itsn't quite as quick and easy. Otherwise you could find yourself needing to rewrite it to get the functionality you wish.
98 characters already are tables (a table is lua's only real data structure but they are powerful enough to be used as basically any other data structure that exists, including objects)
I guess I could turn modifiers also into tables, even if they only hold one value so far.
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
98
Code:
battle:createCharacter("cat")
stdin:1: attempt to call method 'createCharacter' (a nil value)
stack traceback:
   stdin:1: in main chunk
   [C]: ?
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
43 so... I think I have the most important stuff for now done.
There are now delta's to insert characters. I'm not going let you update characters as of yet as there is very little you can edit (except for name, appearance and stuff like that which I'm not going to expose)
You can also not delete characters. The idea is that each character that gets created by an action get marked as a "minion" and will be cleaned up after a battle.
There is also function inside the script itself (unless already registered before the script runs) that just prints out each change as json. Though, I should probably do a check first if its a number, boolean or string as right now that is all the same (oops).

If the action fails for whatever reason the changes get cleaned up and a new one gets inserted telling what the error was. The line numbers of said error even line up with the code given by the user, thus I don't even need to show the whole script if something breaks.

Only thing that is left to do is make a new print function that just puts output in the changes table instead of really printing it. After that, its time to chop it up so php can use it and create code to update the database according to the given changes. Shouldn't be too hard (famous last words)
Also, after that is done it should be pretty much ready to be able to run inside WASM.
 
  • Like
Reactions: GamerwithnoGame