Login

russian armor

A note on scripting

Only Relic postRelic 28 Feb 2014, 08:49 AM
#1
avatar of Tribalbob
Developer Relic Badge

Posts: 160 | Subs: 3

Hey guys, I see a lot of you are starting to delve into SCAR scripting, and I think that's awesome.

One thing I wanted to note; I've seen a few tutorials referencing the mapname_ID.scar file as the file you script in.

I would recommend against using this as it's a scar file that auto generates when the map is saved to store map-defined egroups/sgroups/markers. This means you'd have to be constantly backing up and copy+pasting work.

The engine will actually automatically execute a scar file that matches the map's sgb name.

For example: If your map is named MyMap.sgb, then it will have MyMap_ID.scar as the auto-generated file.

What you want to do is make a NEW scar file and call it MyMap.scar. You can then script to your heart's content (be sure to create an OnInit function and Scar_AddInit(OnInit) it!).

All you have to do is ensure you package this file with your other files (via Mod Tools or whatever application you use). Best part about it is you no longer have to worry about saving in the map and overwriting your work!

Happy scripting!

(ps: Don't forget to call import("ScarUtil.scar") on line one of your file so you can make use of our library of functions!)

EDIT: Here's sort of what it would look like:

Code
import("ScarUtil.scar")

function OnInit()

-- Here you can do stuff!
-- Like call another function
MyNewFunction()

end

Scar_AddInit(OnInit)

function MyNewFunction()

-- More stuff!

end
28 Feb 2014, 10:02 AM
#2
avatar of Janne252
Admin Black Badge
Patrion 15

Posts: 3421 | Subs: 11

Hey Tribalbob!
Thank you for sharing this information. This is relevant but unfortunately this does not work at the moment. WorldBuilder DOES NOT include <mapname>.scar in the archive which is built via "Export Package". I would never have written those tutorials telling people to use <mapname>_ID.scar unless it was the only way available to include scripts.

I've messaged Lardinal a couple of times about WorldBuilder's inability to include relevant files in the archive. Could you please forward this issue? I really would like to include several .scar files in a map archive for creating custom libraries.

List of files I'd like to include in a custom map archive:
  • .SCAR for scriptig
  • .NIS for NIS animations
  • .rgd (and other attrib related files) to include custom abilities, units in a map
  • .DDS files for overriding game GUI images
  • .fnt for custom fonts ( mainly for altering dr_text2D output font)
  • .lua files for adjusting game config (Camera max zoom out height, player colors, etc.)
  • folders to include all of this data
    Basically including all of these files in the archive would require a some kind of fully recursive loop though the project folder and some filtering. This leads to an issue map project requiring a base directory. Maps could no longer be saved in /mp/.
28 Feb 2014, 10:02 AM
#3
avatar of OnkelSam
Honorary Member Badge

Posts: 1582 | Subs: 4

i guess that's why tribalbob said you should export using the .sga packer tool by Corsix instead of worldbuilder itself
1 user is browsing this thread: 1 guest

Ladders Top 10

  • #
    Steam Alias
    W
    L
    %
    Streak
Data provided by Relic Relic Entertainment

Replay highlight

VS
  • U.S. Forces flag cblanco ★
  • The British Forces flag 보드카 중대
  • Oberkommando West flag VonManteuffel
  • Ostheer flag Heartless Jäger
uploaded by XXxxHeartlessxxXX

Board Info

889 users are online: 889 guests
0 post in the last 24h
8 posts in the last week
38 posts in the last month
Registered members: 49084
Welcome our newest member, sunwingamescom1
Most online: 2043 users on 29 Oct 2023, 01:04 AM