What I currently code in toolset and engine

Discuss anything in general about the IceBlink Engine + Toolset project (or anything else) here.

What I currently code in toolset and engine

Postby youngneil1 » Sat Jun 27, 2015 1:49 pm

So, in order to avoid redundant double work I think it's good to make as transparent as possible what I currently (well, try to ;) ) work on in toolset and engine.

Current project: Expand engine (and to some extent mayhaps toolset) in order to have scripts understand more object properties and (old script) function calls, e.g. ga_ stuff.

Most of my work will happen in IBScriptEngine.cs, I guess.

Let's roll :D !
User avatar
youngneil1
Backer
Backer
 
Posts: 4046
Joined: Sat Dec 08, 2012 7:51 am

Re: What I currently code in toolset and engine

Postby youngneil1 » Sat Jun 27, 2015 5:20 pm

How about such approach for public void DoFunction(string line) from IBScriptEngine.cs (basically using gaController from ScriptFunctions.cs):

Code: Select all
 
 public void DoFunction(string line)
        {
            string[] parms = GetParameters(line);

            try
            {
                string prm1 = parms[0];
                string prm2 = parms[1];
                string prm3 = parms[2];
                string prm4 = parms[3];

                string output = line.Split('~', '(')[1];
                output += ".cs";

                gv.sf.gaController(output, prm1, prm2, prm3, prm4);
            }
            catch
            {
            }
           
            /*
                if (line.StartsWith("~gaTakeItem("))
                {
                    gaTakeItem(parms);
                }
                else if (line.StartsWith("~gaShowFloatyTextOnMainMap("))
                {
                    gaShowFloatyTextOnMainMap(parms);
                }
             */

        }
User avatar
youngneil1
Backer
Backer
 
Posts: 4046
Joined: Sat Dec 08, 2012 7:51 am

Re: What I currently code in toolset and engine

Postby youngneil1 » Sat Jun 27, 2015 6:33 pm

Added os and og support:

Code: Select all
public void DoFunction(string line)
        {
            string[] parms = GetParameters(line);

            try
            {
                string prm1 = parms[0];
                string prm2 = parms[1];
                string prm3 = parms[2];
                string prm4 = parms[3];

                string sub = line.Substring(1, 2);
               
                if (sub == "ga")
                {
               
                string output = line.Split('~', '(')[1];
                output += ".cs";
                gv.sf.gaController(output, prm1, prm2, prm3, prm4);
                }

                if (sub == "og")
                {

                    string output = line.Split('~', '(')[1];
                    output += ".cs";
                    gv.sf.ogController(output, prm1, prm2, prm3, prm4);
                }

                if (sub == "os")
                {

                    string output = line.Split('~', '(')[1];
                    output += ".cs";
                    gv.sf.osController(output, prm1, prm2, prm3, prm4);
                }

            }
            catch
            {
            }
           
            /*
                if (line.StartsWith("~gaTakeItem("))
                { 
                    gaTakeItem(parms);
                }
                else if (line.StartsWith("~gaShowFloatyTextOnMainMap("))
                {
                    gaShowFloatyTextOnMainMap(parms);
                }
             */

        }
User avatar
youngneil1
Backer
Backer
 
Posts: 4046
Joined: Sat Dec 08, 2012 7:51 am

Re: What I currently code in toolset and engine

Postby youngneil1 » Sat Jun 27, 2015 8:15 pm

Adding properties will have to happen in different places ofIBScriptEngine.cs it seems:

1. In region Object Property Assignment (function Player Assignment and ModAssignment so far)
2. In the ReplaceParameter function

Will be LOTS of additions, but totally worth it :D .
User avatar
youngneil1
Backer
Backer
 
Posts: 4046
Joined: Sat Dec 08, 2012 7:51 am

Re: What I currently code in toolset and engine

Postby youngneil1 » Sat Jun 27, 2015 8:50 pm

Same idea as above for gc_ type:

Code: Select all
public int GetFunctionConditionalCheckReturnValue(string rightSide)
        {
            string[] parms = GetParameters(rightSide);

            try
            {
                string prm1 = parms[0];
                string prm2 = parms[1];
                string prm3 = parms[2];
                string prm4 = parms[3];

                string output = rightSide.Split('~', '(')[1];
                output += ".cs";
                gv.sf.gcController(output, prm1, prm2, prm3, prm4);
                if (gv.mod.returnCheck)
                {
                    return 1;
                }
                else
                {
                    return -1;
                }
            }
            catch
            {
                return -1;
            }

            /*if (rightSide.StartsWith("~gcCheckItem("))
            {
                gcCheckItem(parms);
            }
            return -1;*/
        }
User avatar
youngneil1
Backer
Backer
 
Posts: 4046
Joined: Sat Dec 08, 2012 7:51 am

Re: What I currently code in toolset and engine

Postby slowdive » Sat Jun 27, 2015 9:18 pm

Yes, the DoFunction() controller passing to gv.sf.gaController() is definitely the way to go for ~ga...great idea. Should probably do something similar for ~gc by running through the gv.sf.gcController and then checking the gv.mod.returnCheck bool value in GetFunctionConditionalCheckReturnValue() and returning "1" for true and "0" for false to the DoNumberAssignment() function.

I was think that we wouldn't need the os_ and og_ anymore since the DoObjectPropertyAssignment() and the ReplaceParameter() will be the new way to set and get object properties.

When adding ga_ and gc_ Functions you will need to touch:
-DoFunction() for ~ga
-DoNumberAssignment() for ~gc
-GetFunctionConditionalCheckReturnValue() for ~gc
-add to the #region ga or gc Functions if needed

When adding object properties (%...) you will need to touch:
-DoObjectPropertyAssignment()
-ReplaceParameter()
-add to the #region Object Property Assignment as needed
User avatar
slowdive
Site Admin
Site Admin
 
Posts: 2659
Joined: Wed Nov 21, 2012 11:58 pm

Re: What I currently code in toolset and engine

Postby youngneil1 » Sat Jun 27, 2015 9:26 pm

Ah, thanks for the heads up :-), I tried something like above for gc_, too.

Indeed, os_ and og_ will likely be not needed. Then again, it's already done and it were just a few lines :) .

Concerning adding in all those properties: Copying a code block, then using a local "find and replace" on marked code concerning the property to be exchanged provides a good workflow speed :D .

Also, I added *=,/= and a modulo operation (./.= as symbol for %= with the later) at various places in IBScriptEngine.cs for faster scripting speed later on.
User avatar
youngneil1
Backer
Backer
 
Posts: 4046
Joined: Sat Dec 08, 2012 7:51 am

Re: What I currently code in toolset and engine

Postby slowdive » Sat Jun 27, 2015 9:36 pm

Awesome! Look forward to trying out some scripts. I have one running in Unwanted Guests (added it a few commits ago for testing IBScriptEngine):

Code: Select all
//test script for floaty text
msg("each player losses 1 hp")
for (@i = 0; @i < #numPlayers; @i ++)
   %Player[@i].hp -= 1   
next


I placed it on a trigger just right and down a bit from the home. So triggers are currently working for testing IBscripts.

The way I envisioned using ~gc in IBscripts would look something like this:

Code: Select all
@ret = ~gcCheckForItem(dagger01,1)

if @ret = 1
  //do some stuff
endif
User avatar
slowdive
Site Admin
Site Admin
 
Posts: 2659
Joined: Wed Nov 21, 2012 11:58 pm

Re: What I currently code in toolset and engine

Postby slowdive » Sat Jun 27, 2015 11:58 pm

I'm wondering if there is a way to perform the Object Property Assignments more directly. Some way to automatically convert a string to the corresponding object property, convert a string to the operator. This way instead of all the if-else if statements to find the EndsWith() and then all the if-else if statements to find the operator, we could just do something like:
gv.mod.playerList[indexNum].ConvertToProperty(element[0]).Operator(element[1], val)
This is all made up stuff of course, but it would be cool if there was a way to do the whole assignment in one line for each object class.

Maybe something here is useful:
http://stackoverflow.com/questions/1089 ... ring-value
http://stackoverflow.com/questions/7086 ... in-c-sharp
User avatar
slowdive
Site Admin
Site Admin
 
Posts: 2659
Joined: Wed Nov 21, 2012 11:58 pm

Re: What I currently code in toolset and engine

Postby youngneil1 » Sun Jun 28, 2015 12:59 pm

Awesome! Look forward to trying out some scripts. I have one running in Unwanted Guests (added it a few commits ago for testing IBScriptEngine):


Great to see a script as an example of syntax. Will test some stuff via triggers later on, should be fun :D .

The way I envisioned using ~gc in IBscripts would look something like this:


That looks very handy, an intuitive way to use the gc_ checks.

I'm wondering if there is a way to perform the Object Property Assignments more directly.


Yep, I tried something like that a while ago, see here:

viewtopic.php?f=45&t=380&p=4486&hilit=dictionary#p4486

Looked like this in the end:

Code: Select all
Dictionary<string, object> stringToObject = new Dictionary<string, object>();
stringToObject["sf.gm.playerList.PCList[0]"] = sf.gm.playerList.PCList[0];
PropertyInfo propertyInfo = stringToObject["sf.gm.playerList.PCList[0]"].GetType().GetProperty("SPMax");
int value = (int)stringToObject["sf.gm.playerList.PCList[0]"].GetType().GetProperty("SPMax").GetValue(stringToObject["sf.gm.playerList.PCList[0]"], null);
value += 2000;
propertyInfo.SetValue(stringToObject["sf.gm.playerList.PCList[0]"], Convert.ChangeType(value, propertyInfo.PropertyType), null);


On the other hand it works really quite fast the "copy block, find old property and replace with new property via batch function" way. Only a few seconds per entry.
User avatar
youngneil1
Backer
Backer
 
Posts: 4046
Joined: Sat Dec 08, 2012 7:51 am

Next

Return to General IceBlink Project Discussions

Who is online

Users browsing this forum: No registered users and 2 guests

cron