Questions about scripts

Ask any questions that you come up with while using the IB2 Toolset

Questions about scripts

Postby sfg » Fri Jan 20, 2017 9:55 am

Hi,

I have a few questions about using scripts in IB2.
First, it looks to me like the C# scripts are gone? But at the same time, I see items still using scripts, but they're nowhere to be found. Is that sort of a backwards compatibility thing?
How do you do new scripts for items in this case? I tried making a scripts folder in the module's main folder and placed a script from IB1 and told the item to use that, but it didn't work.
With IBScripts then? First, I have no clue how to use them (found no documentation) but I also tried as a test to use a IBScript found in Hearkenworld (one to increase base strength) on the healing potion and that didn't do anything either. Very possible I didn't do it correctly, though.

So, how are scripts supposed to work in IB2 or how will they work in the final release? Will they give us the same options the C# ones did? Or more? Or less?

It's the same with the scripts you use in dialogues. Couldn't find them anywhere.
I also saw a difference in how spells are done... now there's the effect editor, which granted offers a lot of options, but what if I want to script some more funky spell?
Or item... would you say it's possible to script an item that on use will start a dialogue... for puzzle like items (think Modron cube) for example?

Oh yeah, I also don't really get it how traits work. Say Cleave... no script, nothing? It it hardcoded? Does it even work actually? I have not tested in play.
sfg
 
Posts: 4
Joined: Fri Jan 20, 2017 9:43 am

Re: Questions about scripts

Postby slowdive » Fri Jan 20, 2017 8:37 pm

Welcome to the forums sfg. Scripts are handled differently in IB2 then they were in IB1. Since the goal of IB2 was to create a code base that could be used for PC, Android, and potentially other platforms, the way IB1 used c# scripts wouldn't work. We decided to create a simple scripting language for IB called IBScript. It is intended to be used only for simple purposes and not for any complex systems (although it is capable of such).

IB2 uses two types of scripts. The first type are scripts that are really just internal function calls that allow for input parameters (these are all the "ga", "gc", "og", and "os" scripts). The second type is the IBScripts as mentioned before. We plan on having documentation for all the toolset systems as we get closer to an official release. For now, when ever you see "script" (like in triggers or converesations) it is really one of those internal to the engine functions like "ga" and "gc" "scripts". If you see "ibscript", it is an IBScript which you can create from the toolset IBScript editor (see the IBScript tab in the left panels).

sfg wrote:would you say it's possible to script an item that on use will start a dialogue... for puzzle like items (think Modron cube) for example?


-To launch a conversation from an item, just create an IBScript with the following code in it:
~gaDoConversationByName(parm(0))

-Then in the item's onUseItemIBScript field enter the name of the script you just created (this is a dropdown box and since you just created the script you may need to click the "Reset DropDowns" button in the top menu bar of the toolset).
-In the onUseItemIBScriptParms field enter the name of the conversation you want to launch.

That's it.

Again, we hope to have more documentation and youtube tutorial videos in the near future so stay tuned. In the mean time, if you like code, all the code can be found here:
https://github.com/IceBlinkEngine

Also, if you need any specific "script" ga or gc types added to the engine, just let us know... or you could even clone the engine repo and make a pull request if you enjoy coding :lol:
User avatar
slowdive
Site Admin
Site Admin
 
Posts: 2838
Joined: Wed Nov 21, 2012 11:58 pm

Re: Questions about scripts

Postby sfg » Sat Jan 21, 2017 5:53 pm

Thanks for the answer! I'm starting to figure it out more and more.

What about traits? How does something like cleave work if it does at all with no scripts? Is it or will it be possible to use some kind of scripts for them? Similarly for spells... as an example, say I want to make a spell that all it does is push a character a certain number of squares in a direction? Or a spell that works like web (holding people in place) but also does damage each turn? Is that possible? At the moment traits and spells only have the field "scripts" but since you said C# scripts are not supported anymore, then it means it's not really possible to do scripts for them?

If that's the case and C# offered more power why didn't you leave it it an option and let people decide if they want to support other platforms? Too much work to maintain?

Edit:

And getting back to the items... currently it looks like the healing potion, for example, uses a script (which I can only assume is hardcoded into the engine). How would you rebuild it, if at all possible, with the new system? If I wanted to make it heal more or less. Or an random amount. Stuff like that.
sfg
 
Posts: 4
Joined: Fri Jan 20, 2017 9:43 am

Re: Questions about scripts

Postby slowdive » Sat Jan 21, 2017 9:36 pm

The decision to not use compiled at run time type scripts was mostly a security and legal issue for me. If I truly was a coder and new how to properly sandbox that type of user input then maybe it could work for PC only, but I am just not that good. Also, having IBScript allows IB2 to be portable, consistent, simple and keeps our code base and job scope reasonable for a small team (two self taught coders in me and Karl). If builders really want to create complex c# type scripts, and they know how, we hope that they will just clone the repo and submit pull requests. The push a character type spell... we could add that to the Effect's system as well.

Traits recently have become more flexible in the upcoming release. Cleave (and Sweep) in the IBmini v4 and in IB2 v22 (to come) is just a property in Trait/Effect editor. Spells and Traits have Effect Lists so a Spell can do multiple things such as a web and damage each turn at the same time. To create your own unique spells and traits, you create an effect(s) from the Effect Editor and then create a spell or trait in the Spell or Trait Editor and assign that effect to the spell or trait in the effectTagList collection.

Items can cast a spell upon use so I create a heal potion by creating a heal effect, then create a heal spell and add the effect to its effectTagList and then assign that spell to the onUseItemCastSpell property of the item (this is off the top of my head so names may be different). Your heal effect made in the effect editor can heal a fixed or random number.

I'll be making some YouTube videos on how to use the toolset in the next coming weeks so hopefully those will be more helpful.
User avatar
slowdive
Site Admin
Site Admin
 
Posts: 2838
Joined: Wed Nov 21, 2012 11:58 pm

Re: Questions about scripts

Postby sfg » Sun Jan 22, 2017 12:10 am

Sweet, thanks a lot! Makes much more sense now!

Just another question for now, are different creature sizes, like in the Goldbox games, planned to come anytime soon? I read a post on the forum about it, but it wasn't clear for when is it planned.
Also, will it support non square creatures? Like say, 1 by 2 squares as well as 2 by 1 instead of just 1 by 1 or 2 by 2?

Edit: Also, I'm not making a request for the push spell. It was just a thing that came to my mind. I'm sure that if I'll start working seriously on what I have in mind I'll have requests and don't want to use them on that one. :D Unless you think that would be a useful addition to the engine.
sfg
 
Posts: 4
Joined: Fri Jan 20, 2017 9:43 am

Re: Questions about scripts

Postby slowdive » Sun Jan 22, 2017 3:14 am

Creature sizes was recently just added to ibmini and ib2. It is in the current ibmini v4 on the vault, but I think in ib2 it will be in the v22 which is still in the works. It includes 1x1, 1x2, 2x1, and 2x2 creatures.
User avatar
slowdive
Site Admin
Site Admin
 
Posts: 2838
Joined: Wed Nov 21, 2012 11:58 pm

Re: Questions about scripts

Postby sfg » Sun Jan 22, 2017 12:56 pm

Awesome stuff! Thanks again for the answers and yours and other people's work on this engine!
sfg
 
Posts: 4
Joined: Fri Jan 20, 2017 9:43 am

Re: Questions about scripts

Postby youngneil1 » Mon Jan 23, 2017 7:10 am

Welcome here, sfg :) . Jer all nailed it perfectly already :D .

More documentation is sorely needed, not only for people dealing with IB first time, but also for eg myself forgetting how subsystems of the toolset work when I havent used them for a while. Problem is, the thingie thats even more needed than documentation is time :lol: .
User avatar
youngneil1
Backer
Backer
 
Posts: 4436
Joined: Sat Dec 08, 2012 7:51 am

Re: Questions about scripts

Postby Zeke » Wed Mar 22, 2017 12:16 am

So it is not possible to change a creature location via script?

Is it possible to change the creature coordnates property? If it is, then effects lke Push could be possible.
User avatar
Zeke
 
Posts: 70
Joined: Mon Mar 20, 2017 5:39 pm

Re: Questions about scripts

Postby slowdive » Wed Mar 22, 2017 2:58 am

There is the capability to change a creature's combat location in IBScript, but effects/spells/traits do not use IBScripts. So to create a spell that changes a PC or creatures location in combat, we would need to add some properties to the Effect class. There is a custom spell, dimension door, that does not use the Effect system and instead uses a custom method:
Code: Select all
public void spDimensionDoor(object src, object trg)
        {
            if (src is Player) //player casting
            {
                Player source = (Player)src;
                Coordinate target = (Coordinate)trg;

                if (IsSquareOpen(target))
                {
                    gv.cc.addLogText("<gn>" + source.name + " teleports to another location</gn><BR>");
                    source.combatLocX = target.X;
                    source.combatLocY = target.Y;
                    source.sp -= gv.cc.currentSelectedSpell.costSP;
                    if (source.sp < 0) { source.sp = 0; }
                }
                else
                {
                    gv.cc.addLogText("<yl>" + source.name + " fails to teleport, square is already occupied or not valid</yl><BR>");
                }
            }
            else if (src is Creature) //creature casting
            {
                Creature source = (Creature)src;
                Coordinate target = (Coordinate)trg;

                if (IsSquareOpen(target))
                {
                    gv.cc.addLogText("<gn>" + source.cr_name + " teleports to another location</gn><BR>");
                    source.combatLocX = target.X;
                    source.combatLocY = target.Y;
                    source.sp -= SpellToCast.costSP;
                    if (source.sp < 0) { source.sp = 0; }
                }
                else
                {
                    gv.cc.addLogText("<yl>" + source.cr_name + " fails to teleport, square is already occupied or not valid</yl><BR>");
                }
            }
        }


So a custom spell like push could use a custom method just like dimension door does.
User avatar
slowdive
Site Admin
Site Admin
 
Posts: 2838
Joined: Wed Nov 21, 2012 11:58 pm

Next

Return to Questions and Answers

Who is online

Users browsing this forum: No registered users and 1 guest

cron