.com.unity Forums
  The Official e-Store of Shrapnel Games

This Month's Specials

Raging Tiger- Save $9.00
winSPMBT: Main Battle Tank- Save $6.00

   







Go Back   .com.unity Forums > Digital Eel > Weird Worlds: Return to Infinite Space > Scenarios and Mods

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old July 20th, 2006, 10:54 PM

McPhage McPhage is offline
Private
 
Join Date: Jul 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
McPhage is on a distinguished road
Default Ruby DSL for Weird Worlds mods

Hey all,

I love the mod capabilities of Weird Worlds, but the notation is not very clear. So I'm working on a Ruby DSL in order to define mods in ruby, which are then turned into Weird Worlds format mods.

A DSL is a Domain Specific Language... it's like a little language designed for a particular task. So the WW mod system is definitely a DSL, but suffers from poor readability, and is very rigid. So my project you write the mods in Ruby (with functions designed to make it easy and clear).

So some of the advantages:

1) clarity. Instead of writing "WEAP 21 84 92 172 315 55 2 -1", you write
"weapon :sprite => [21, 84],
lhouette => [92, 172],
:firing_arc => 260..370,
ret => :under,
:symmetric => true"
with the variable order being flexible... and you can specify things in different ways. so :fixed => 90 is the same as :firing_arc => 90..90.

2) simplicity. You can create a mod in one or two files, and those generate the needed files in the correct places. You don't need to remember the format, or the structure--the system itself handles that.

3) correctness... since there's a layer of processing between what you code, and the final mod, it can make sure that you don't do anything illegal. So it'll tell you if you leave out an image size, for instance.

It's not very far along (big shocker, right?). At the current point it's at, you can create extra Terran ships. (I'm following the ModMaker's Guide, and so that's the first real mod.) But I'm setting up a RubyForge project so that other people can contribute, if you're familiar with Ruby.

Note that! You don't really need to know Ruby to create a mod using this. It uses only simple parts of the Ruby syntax.

So you can see what it looks like, here's the code for the Terran Assault Ship mod:

*** File: AssaultShipMod/AssaultShipMod.rb ***

class AssaultShipMod < WeirdWorldsMod

title "Terran Assault Ship Mod", :terran_assaultship

include_default_race :terran

mod_file "AssaultShip"

hulls :add => [AssaultShip]
races :include => [Terran]

end

*** File: AssaultShipMod/AssaultShip.rb ***

class Terran < Race

extend_default_race :terran

end

class AssaultShip < Ship

# These are the basic ship settings

name "Terran Assault Ship", :ter_asst
race Terran

size 64
cargo_space 12
hit_points 30
movement_rate 35
turning_rate 44

flags :regensystems

value arships => 500

# These are the image frames

main_image :at => [0, 0], ze => [80, 128]
lights_image :at => [88, 0]
icon :at => [188, 64]

projectile_weapon :at => [172, 0], ze => [16, 40]
beam_weapon :at => [188, 0]
missile_weapon :at => [204, 0]

starmap :at => [220, 0]
interface :at => [220, 32]

# These are the hull hardpoints

weapon :sprite => [21, 84],
lhouette => [92, 172],
:firing_arc => 260..370,
ret => :under,
:symmetric => true

engine :sprite => [40, 122], lhouette => [128, 236]
thrusters :sprite => [29, 100], lhouette => [112, 204], :symmetric => true
system :sprite => [40, 86], lhouette => [128, 172]
system :sprite => [40, 54], lhouette => [128, 108]
system :sprite => [40, 27], lhouette => [128, 54]
system :sprite => [32, 70], lhouette => [112, 140], :symmetric => true

# These are the particular instances of the hull

create_ship "Assault Ship" do |ship|
ship.flags mulator, :intro
ship.add_weapon :wp_projrail, :quantity => 2
ship.add_thrusters :th_fusion
ship.add_engine _fusion
ship.add_system :sy_shieldelmx
end

end

*** END ***

When you stick the needed image files in a folder, and run the provided script, it generates the entire mod and its folder structure.

To run it, at least on OS X, type:

./generate_mod AssaultShipMod

Like I said, I'm setting up a RubyForge page for it (rubyforge.org), but it's not up yet. Needs to get approved.

So... um.... yeah. Feel free to ask me any questions if something's unclear.

McPhage
 

Bookmarks


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 06:45 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2024, Shrapnel Games, Inc. - All Rights Reserved.