Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Internal scripting system for AI and MapScripts
- - By EdwinOdesseiron Date 2013-07-30 21:27
Hi all

I guess this is more of a ruby question than just gosu, but you guys are helpful, so I hope you won't mind much :p
I wanted to create a small, internal map background script system and AI scripts. Pretty much a really basic scripting language within ruby. The map background script would deal with things like if CONDITION then RESULT, ex:
CONDITION GameTrigget ExaminedMine
RESULT SwapNPC Chara01 Chara02

And I figured that I could use String's .include?(keyword), but I wonder if there is any other way I could manage doing that, perhaps easier or more efficient?

Thanks in advance

EdwinOdesseiron / Piotr
Parent - - By Spooner Date 2013-07-31 10:00
I wouldn't aim to make it a scripting language which is overkill for what you need (and, you know, you could use Ruby for that!), but rather a data structure, which is already structured for you:

---
conditions:
    type: GameTrigger
    trigger: EnterMine
    effects:
        -
            type: SwapNPC
            args:
                - Chara04
                - Chara01
            type: SwapNPC
            args:
                - Chara08
                - Chara02
    type: GameTrigger
    trigger: ExaminedMine
    effects:
        -
            type: SwapNPC
            args:
                - Chara01
                - Chara02
Parent - - By jlnr (dev) Date 2013-08-05 14:48
I think you should mention that this uses require 'yaml', and can be loaded using YAML.load_file(filename) :)

And if you want to write YAML by hand, you can also use the shortcut syntax to make things a little more compact:

args: [Chara04, Chara01]
Parent - By Spooner Date 2013-08-05 14:50
Good points!
Up Topic Gosu / Gosu Exchange / Internal scripting system for AI and MapScripts

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill