.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
  #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
  #2  
Old July 22nd, 2006, 01:27 AM

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 Re: Ruby DSL for Weird Worlds mods

Ok, so.

I realize that my previous post didn't explain too much. I didn't want to get into too much detail before I had anything that people could actually download, since it wouldn't be very useful.

So now the project is being hosted on RubyForge (similar to SourceForge, but for Ruby-based projects). To get the current version of the project, go to: http://rubyforge.org/frs/?group_id=1961

When there, click on "Version 1.0" for some information about the project, or click "Version1.0.zip" to download it.

I'm going to update this thread with more info as time goes by, but here should (hopefully) be enough to get people started, and show them what this project has to offer.

So the basics:

Ruby is a modern scripting language. Right now it's hot stuff because of a website framework called Rails. However, this really has nothing to do with that.

OS X comes with Ruby pre-installed, so if you're a mac user you don't need to do anything besides download the project and unzip it. If you use Windows, which I assume most of you do, you can install Ruby using the "Ruby 1-click installer", also hosted here: http://rubyforge.org/frs/?group_id=167 on RubyForge.

The purpose of this project is to make mod writing a little cleaner and neater. One of the nice features of Ruby is that it's easy to make 'little languages' using it, that allow you to use Ruby while bending its syntax to allow something a little more readable.

So that's what I'm doing, and I think things are moving in that direction. For example, both of the included sample mods use 2 files of code + graphics, instead of the many different files that a mod requires. Those extra files are generated and put into the right place by the mod. The mod author doesn't need to know what they are or where they go, it's all handled behind the scenes.

DSL writing isn't my area of expertise, so the reason I took this project on is to learn about them--but I really hope that I'm not the only person who finds this of any value.

So, please! Download the project! Install Ruby if necessary! I'm looking forward to making your lives easier :-)

Any and all comments or feedback would be appreciated--even a WTF?
  #3  
Old July 22nd, 2006, 02:19 PM
Psientist's Avatar

Psientist Psientist is offline
Sergeant
 
Join Date: Apr 2004
Location: Tampa Bay, Florida, USA
Posts: 327
Thanks: 5
Thanked 33 Times in 11 Posts
Psientist is on a distinguished road
Default Re: Ruby DSL for Weird Worlds mods

Well, I'm not familiar with Ruby, so my feedback is limited. It might be great if:

- it's easier to create mods with ruby than without
- you have access to more documentation than is currently available (e.g., get Digital Eel on board)
- you're willing to put a whole lot of time into creating something relatively mature before other people get interested
- some more people get involved with modmaking

Not trying to discourage you, it's hard to create a complex mod by trial-and-error.
  #4  
Old July 23rd, 2006, 05:38 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 Re: Ruby DSL for Weird Worlds mods

Well, the first and foremost goal is to make it easier to write mods using Ruby than not. So if I don't accomplish that, then I don't have much of anything. But I think it will be the case (and even _is_ the case, for the simple mods it can already generate) for the following reasons:

(1) Don't need to worry about files or directories:

WW mods require a lot of files in a lot of directories. Writing the mods in Ruby frees you from having to remember how many, and what they are. You just create the contents, and the when the mod is generated it automatically puts the right files in the right places.

This is even better if the directory structure changes--the DSL author [me]changes where files are put, and the mod authors simply regenerate their mod, without changing anything. Same with if the file structures change.

(2) Freedom from unreadable files:

WW ini files aren't very readable, usually using a string of numbers to represent some structure. Using Ruby, you name parts of the structure like ze => [128, 256] for an image that is 128 pixels by 256 pixels. So you don't need to remember what order they're supposed to go in, that's all handled by the DSL.

Plus, when there are numbers which just represent something, like a weapon turret being above/below/none, then just say ret => ow, instead of having to remember that below = -1

Also, variable names free you from the "FLT4 00122", allowing you to say things like fleet << fighter * 2 << cruiser << battleship * 2 to add ships to a fleet. What is SHP0? Who cares! It's handled for you!

(3) Flexibility:

You can specify things in different places. For instance, you can specify a ship instance with the ship hull, or with the race that owns it. WHen specifying a weapon arc, you can specify min range & max range, center & sweep, or fixed angle (can = will be able to). Whatever makes the most sense at the time.

(4) Comments:

Although this point seems minor, it's really not. Want someone else to understand your mod? Leave comments about what you're doing at any point by putting in a hash ('#'); the rest of the line is a comment.

***

So even those 4, I think, are pretty convincing. I can probably come up with more if I need to, but that should be a start.

Plus, and this is important--to create a mod in Ruby, you _don't_need_to_know_much_of_Ruby_! Mod writing only uses the most basic syntax.

As for extra documentation, or getting Digital Eel staff on board (Fingers, or Ripcord O'Reilly), that would be excellent. I'm hoping that if I write enough, they'll see the wisdom of my plan ;-) And even more so, if they see the value of including a scripting language (ANY scripting langauge!) into Infinite Space 3, I would be happy.

I'm hoping that I'm not the only Weird Worlds Rubyist, but even more so, I hope that Weird Worlds modders who don't know Ruby are still interested enough to check this out. It's here to make your life easier, I promise!

McPhage
  #5  
Old July 24th, 2006, 10:11 AM
Psientist's Avatar

Psientist Psientist is offline
Sergeant
 
Join Date: Apr 2004
Location: Tampa Bay, Florida, USA
Posts: 327
Thanks: 5
Thanked 33 Times in 11 Posts
Psientist is on a distinguished road
Default Re: Ruby DSL for Weird Worlds mods

heck, it would be worth it for the ability to comment alone!
  #6  
Old July 25th, 2006, 02:52 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 Re: Ruby DSL for Weird Worlds mods

Then check it out :-)

I'll be putting out a new version soon which has Hulls, Races, Planets, Stars, Emitters, and some other pieces. Just have some bugs to fix.

Also, I'm working on backporting the demo datafiles to Ruby, so that people can see how things work.
 

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 12:29 PM.


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