Page 1 of 1

Store Language Stack

Posted: Wed Nov 23, 2016 9:49 am
by a_bertrand
The next step of my engine in my opinion is to open the door to more complex coding involving game owners to develop things like player market or auctions.

For that a couple of things need to be implemented like:
- Being able to show a "dialog"
- Being able to put some stuff on the dialog with input boxes, buttons and more
- Being able to process those inputs and react to the buttons
- Being able to save data for the game like "object on sale", query, update and delete those entries

Up to the last point all is pretty clear and easy to implement even if you will not use HTML to fill the form but more an enhanced BB code to avoid XSS and nasty JS injections.

The last point however requires async calls, as the call will basically call back the backend and receive the data from it. Ideally the script should be blocked till the result come back and therefore makes the script coding much easier like:

Code: Select all

var toShow="";
var query=Storage.Select('itemsOnSale');
while(Storage.NextRow(query))
{
   toShow+=Storage.GetValue('Name')+"\n";
}
Display.Dialog(toShow);
To be able to do that, I need to store my script stack after the Storage.Select and restore it when I get the data from the server, however I believe I will have to heavily touch my scripting language to be able to do so. Annoying.

What do you think? Would you prefer a linear call like in this example or a system with callbacks?

Re: Store Language Stack

Posted: Wed Nov 23, 2016 2:37 pm
by hallsofvallhalla
man that is a tough one. I like what you are trying to do here but i could understand if it is to much changing of your current script system. I think in the end as long as the feature is there players will be happy.

Re: Store Language Stack

Posted: Wed Nov 23, 2016 3:53 pm
by a_bertrand
I think I got it running... wasn't all that simple really:
https://www.dotworldmaker.com/test_parser.html

Click on the "test" button, and you should see a couple of messages coming then a pause then it continues. The stack should be preserved with all the variables values and everything... Hopefully...

Re: Store Language Stack

Posted: Wed Nov 23, 2016 4:01 pm
by hallsofvallhalla
Dude thats quite awesome

Re: Store Language Stack

Posted: Wed Nov 23, 2016 4:13 pm
by a_bertrand
Thanks... was more complex than I expected and took a lot more time than expected to have it working. That's how it works:

I have now a new function in my script env which "stores" the current stack and once the stack has been saved in a JS object it pass that stack to a callback function.
The function can then do whatever it want and then "rebuild" the script env from the stack and the script env will be back at the same position as before and continue the execution, with all the loops, ifs, function calls stacked exactly as they was.