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: 10 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: 4 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.
[06:51 am]
Pr0nogo -- if the person joins my server they'll be able to get all the modding info they need, since very few people mod in SEN's server afaik
[06:44 am]
Pr0nogo -- no real idea though, i haven't explored that yet
[06:44 am]
Pr0nogo -- can't be done on scr probably
[06:44 am]
Pr0nogo -- they can but you need to set them up in a specific way
[06:44 am]
jjf28 -- like not necessarily turrets/cannons, but whether any building (CC/barracks/forge) could be given a weapon
[06:42 am]
Pr0nogo -- what does 'random buildings' mean
[06:42 am]
jjf28 -- o someone was curious if you could give random buildings weapons somehow
[06:41 am]
Pr0nogo -- what did you need
[06:40 am]
jjf28 -- kay
Please log in to shout.


Members Online: Roy, O)FaRTy1billion[MM]