Staredit Network > Forums > SC1 Mapping Tools > Topic: scmdraft2 sample plugin
scmdraft2 sample plugin
Aug 19 2014, 10:25 pm
By: trgk  

Aug 19 2014, 10:25 pm trgk Post #1



Modified version of SCMDraft2 sample plugin. (Original : one on Scmdraft2 beta site)
See Release\Scmdraft Plugin.sdp for sample plugin.
This plugin manipulates some string / dumps stirng table / unit names / location names.

This version of plugin works with SCMDraft2 2.0.8.0

Attachments:
SCMDraft2_Plugin.zip
Hits: 20 Size: 51.27kb

Post has been edited 6 time(s), last time on Aug 21 2014, 7:26 am by trgk.



EUD

Aug 20 2014, 3:07 am CecilSunkure Post #2



So which files should we be looking at here? Which ones did you write? Could you please post a short description about the pieces of code you did write? I don't have a login so I didn't check -did you find resources for writing this plugin (like the interface headers) at that site?

This can all be very helpful for anyone else interested in writing a plugin (like myself).



None.

Aug 20 2014, 3:29 am trgk Post #3



Almost everything is based on SI's sample plugin code.

What I did is:
- Plugin version : 1 -> 2
- Made interface for string table related functions. SI_VirtSCStringTable methods are not working anymore.

You should see RunPlugin function inside Scmdraft Plugin.cpp
Inside it, I've written a simple example for what I've found so far. Basic string manipluation, Getting unit names/location names.
It seems like that SCMDraft2 plugin system is strictly designed to support TrigEdit.
Every supported functions are used by TrigEdit, and are only suitable to create another Trigger Editor.




+
Code
        ...
        int findindex = StringTable_FindString(stb, str);
        printf("(should be the same)  %d %d\n", test_stringid, findindex);                 /// THIS
        const char* str2 = StringTable_GetString(stb, findindex);
        ...


Two number printed on there can be different if duplicate strings exists inside map.






Summay) See scmdraft plugin.cpp -> RunPlugin function.
Every string is reference-counted, and you'll have to manually dereference it if you need.

Post has been edited 2 time(s), last time on Aug 20 2014, 3:35 am by trgk.



EUD

Aug 20 2014, 3:32 am CecilSunkure Post #4



Great thanks a lot. This helps.

Yeah I always imagined the plugin system was specifically for trigedit, since nothing else was ever made. Nonetheless I'll see if I like it all and perhaps I'll make something :)



None.

Aug 20 2014, 10:14 pm CecilSunkure Post #5



Took another look and decided I don't have any time to devote to this, too many other things to finish.

However, if someone (trgk) were to write a plugin that could load triggers from a string I'd be extremely grateful! What I'd like to do is:
Press button in SCMDraft and have it run the plugin. If I had code to load triggers into SCMDraft from string, I could run LIT and read LIT's output triggers.



None.

Aug 21 2014, 12:15 am trgk Post #6



Quote from CecilSunkure
Took another look and decided I don't have any time to devote to this, too many other things to finish.

I wonder how creating plugin with scmdraft2 plugin system can be harder than building one with ChkDraft.


Quote from CecilSunkure
However, if someone (trgk) were to write a plugin that could load triggers from a string I'd be extremely grateful! What I'd like to do is:
Press button in SCMDraft and have it run the plugin. If I had code to load triggers into SCMDraft from string, I could run LIT and read LIT's output triggers.

My trigger format is different from that of scmdraft2. :)
I'll open source my trigger editor once it's completed.


+ I refactored the plugin base. See the main post

Edit08210425 : Edited pic

Attachments:
dkzuek.png
Hits: 4 Size: 24.24kb

Post has been edited 4 time(s), last time on Aug 21 2014, 7:26 am by trgk.



EUD

Aug 23 2014, 11:27 am trgk Post #7



Example trigger editor source code.
I've not yet finished this, but it's already in usable level.

This plugin decodes your trigger into lua script.
You modify lua script, and this program will compile it to triggers.


Compiled plugin : TrigEditPlus.sdp. Put this inside (SCMDraft2 folder)\Plugin\
Source code : TrigEditPlus.zip

I used Lua because I was to lazy to make another script engine. No relation with LIT.




Usage : Push TrigEdit++ button & after popup, open trigeditplus.lua at scmdraft2 directory. (It should be opened automatically, but if not.)
Modify it & save. Push compile button.

Error -> Modify again and press yes / No to not compile.

Attachments:
TrigEditPlus.sdp
Hits: 1 Size: 193kb
TrigEditPlus.zip
Hits: 5 Size: 233.26kb

Post has been edited 1 time(s), last time on Aug 23 2014, 11:32 am by trgk.



EUD

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[11:50 pm]
O)FaRTy1billion[MM] -- nice, now i have more than enough
[11:49 pm]
O)FaRTy1billion[MM] -- if i don't gamble them away first
[11:49 pm]
O)FaRTy1billion[MM] -- o, due to a donation i now have enough minerals to send you minerals
[2024-4-17. : 3:26 am]
O)FaRTy1billion[MM] -- i have to ask for minerals first tho cuz i don't have enough to send
[2024-4-17. : 1:53 am]
Vrael -- bet u'll ask for my minerals first and then just send me some lousy vespene gas instead
[2024-4-17. : 1:52 am]
Vrael -- hah do you think I was born yesterday?
[2024-4-17. : 1:08 am]
O)FaRTy1billion[MM] -- i'll trade you mineral counts
[2024-4-16. : 5:05 pm]
Vrael -- Its simple, just send all minerals to Vrael until you have 0 minerals then your account is gone
[2024-4-16. : 4:31 pm]
Zoan -- where's the option to delete my account
[2024-4-16. : 4:30 pm]
Zoan -- goodbye forever
Please log in to shout.


Members Online: Ultraviolet