PDA

View Full Version : Basic Extension Coding Tutorial Session



damned
April 15th, 2018, 16:52
Hi Guys,

Here is the video link from my Basic Extension Coding Tutorial Session at FG Con 12.

**New Link**
https://youtu.be/R_CulFJYs-M
Three additional videos:
nine slices https://youtu.be/ZLM0qMsNybg
extending an extension https://youtu.be/x4leZBomtOc
5e character sheet https://youtu.be/UPKJDwUt554

Tip reminders

Tools
Notepad++ or another code editor that supports find in files
7zip for compressing/uncompressing files (it recognises .pak/.mod/.ext/.ppk as .zip files – don’t use .7z compression – only .zip)

Fantasy Grounds
Copy the following to your hotkeys:
/reload
/console
/save
And a link to whatever you are working on

Debug
Debug.console();
Debug.chat();
Use them often.

File Structure
Mimic the CoreRPG/5e folder structure, file naming conventions and separation of strings and layout and templates and scripts etc…
The only required file is extension.xml
LUA code should be in .lua files so that the error reporting can identify the line that the error occurs on

Anchoring
Learn it!

Finding the Right Files
Find a unique or rare keyword on the page that you want to edit and search on that.
Follow templates and strings and icons etc etc (using FiF) to learn how these things link to each other
Use the merge=”” so as to minimise the amount of code that may be affected by upgrades

Packing Extensions
You don’t need to pack your extension up each time you make a change – do all your dev with unpacked files
When zipping the final product up – don’t include the parent folder. Include the files and folders at the same level as extension.xml and everything below.
Make sure you don’t end up with a filename like – myextension.ext.zip – it wont work!

shadzar
April 15th, 2018, 17:37
when doing an announcement, you don't require both

\r\n

for a new line with FG.


\r

is all you need, or just make more announcements or both.



<announcement text="Fantasy Grounds College Custom Theme" font="emotefont" icon="fgc_decal_logo" />
<announcement text="Includes: 5E Font - 14 point Clear Font and MOTD by Trenloe.\r https://www.fantasygroundscollege.net fantasygroundscollege.net" font="emotefont" />


23033

damned
April 16th, 2018, 00:26
Thanks shadzar

celestian
April 16th, 2018, 00:33
Thanks for posting and doing this for the community. Good stuff.

Varsuuk
April 16th, 2018, 14:08
Ditto my thanks for doing this!

I’m watching it on my commute to work in this gods-blasted rainstorm so thank you for giving me SOMETHING to enjoy this morning.

Btw, I’m totally a noob, my son wants to make videos... what software do you or folks use to record that sort of screen/window presentation? (also anyone interested, check out Humble Bundle for a great $20 deal on Vegas 14 (current is 15) )

damned
April 17th, 2018, 00:00
Ditto my thanks for doing this!

I’m watching it on my commute to work in this gods-blasted rainstorm so thank you for giving me SOMETHING to enjoy this morning.

Btw, I’m totally a noob, my son wants to make videos... what software do you or folks use to record that sort of screen/window presentation? (also anyone interested, check out Humble Bundle for a great $20 deal on Vegas 14 (current is 15) )

I used Camtasia but it really doesnt matter what you use - no one is doing anything too complex.

Varsuuk
April 17th, 2018, 00:13
Just finished on my commute back. Great, intro to writing extensions.
You asked for ideas during the session. I think yourself or some folks could do worse than a “control showcase”, demo various vanilla controls and common usage for beginners. Show one of them slightly customized. Show one with rollable with simple chat box print, etc

Part two maybe some sort of primer on placement tricks/anchoring... Definitely teach the Sacred Square of Super Siding! (yeah, coming up with snazzy advertising names is NOT one of my strengths)

My biggest complaint (after wanting more 8) ) was that you are too self-effacing! Seriously, with the amount of help you give, MoreCore and all your help troubleshooting ... you should strut a bit more is all ahm sayin’


One thing I THINK I’d do (think because as you know I am still only xml-ing) is set up a local set of 6 vars repping each ability like, lastStrMod etc. Then each time through the if chain you update that with 1 or 2 or 0 based 9n the example you had. while this adds a bunch of repetitive assigns (as I write thinking of a func I’d do if supported, will come back to that after I load your extension) it also gives one nice decoupling effect: No matter if you rearrange the order of the cycling titles or add/remove them - you won’t have to be careful to pay attention explicitly to prior value. It just works.

It is a trivial “improvement” (maybe haven’t seen it implemented to compare +-) but I like that keeping knowledge of self vs state transitions outside of self.

damned
April 17th, 2018, 00:24
Hey Varsuuk

The extension itself is meaningless. I have no need for anything that this extension does - it was purely an exercise in adding something to the char sheet and then making it interact with the database.
I agree that the data manipulation could only be described as clumsy. The challenge to storing the original values and going back to them is what happens if I cycle thru to another title during another session then that data wont be saved.
If I save the old values to the DB then what happens if I have a legitimate increase/decrease of an ability elsewhere for some other reason?
Anyway - my coding is not one to mimic! The tutorial was purely meant to show how to locate what you want to edit, how to setup your environment and how to use Debug/Console to assist you in getting things to work.
Im quietly confident that you will all produce much better extensions than this one :)

Varsuuk
April 17th, 2018, 03:20
Sorry, thought was part of some larger extension and was hoping to give ideas cos I’m soooo in karmic debt :)

Varsuuk
April 18th, 2018, 04:41
In days since FGCon I have probably saved over an hour from these shortcuts. I reload and select character, varsuuk etc at least 20+ times an hour... probably low end estimate.

damned
April 18th, 2018, 05:16
Sorry guys - here is the new ink - forgot I posted it here.
https://youtu.be/R_CulFJYs-M

Varsuuk it is amazing how much time little tweaks can save :)

damned
April 28th, 2018, 08:37
I have made another small coding tutorial video and I have extended another extension as the content of the video. It addresses in a very basic way one method of being able to track carried and non carried treasure.
https://youtu.be/x4leZBomtOc

https://www.fantasygrounds.com/forums/attachment.php?attachmentid=23256

The original extension is here: https://www.fantasygrounds.com/forums/showthread.php?41109-The-weight-of-the-coins
and the new extension is in post #32.

Also any comments about splitting the code into different files are personal preference and not a criticism.

Bidmaron
April 28th, 2018, 19:00
Damned you are good!
Thanks for the vid!
We are lucky to have such contributing supporters.

damned
April 29th, 2018, 11:59
And one more today on nine slices https://youtu.be/ZLM0qMsNybg

damned
June 24th, 2018, 05:38
Ive added another new video today:
5e character sheet https://youtu.be/UPKJDwUt554

Slagmoth
August 7th, 2020, 04:57
Might be a stupid question but is it possible and is there anything different if I were to attempt to extend a published .mod file?

As an example: I have changed a couple of spell descriptions to more properly reflect the school of magic they claim to be. Instead of simply editing the PHB as an example and having to redo that every time there is an errata/update I thought I could try to just merge the XML with the changes I needed.

I also want to add damage types and resistances to Savage Worlds. I finally have an IDE that is a bit less cumbersome for this type of thing than NP++ (still not as good as VS2019's navigation for my usual C# coding projects but I have to live with that).

I also want to change running in SW to d4+2 instead of the basic d6 or the "Lower the run die by one step then add +2 to it".

damned
August 7th, 2020, 05:04
This tutorial series (from memory) is dealing with the ruleset code rather than with data in modules.
They are different but can also be manipulated.
The data in shop modules is mostly encrypted so you cant directly edit the data.
Im not sure of the top of my head how you might go about that programatically but Im sure some clever person will have some ideas...