Store Language Stack

Need help with an engine or coding not on the list? Need help with a game or the website and forums here? Direct all questions here.

Store Language Stack

Postby a_bertrand » Wed Nov 23, 2016 4:49 am

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?
Creator of Dot World Maker
Mad programmer and annoying composer
User avatar
a_bertrand
New Worlds Engine creator
 
Posts: 1517
Joined: Mon Feb 25, 2013 8:46 am
Has thanked: 15 times
Been thanked: 23 times

Re: Store Language Stack

Postby hallsofvallhalla » Wed Nov 23, 2016 9:37 am

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.
User avatar
hallsofvallhalla
Site Admin
 
Posts: 11942
Images: 13
Joined: Wed Apr 22, 2009 6:29 pm
Location: mobile, al
Has thanked: 11 times
Been thanked: 158 times
Blog: View Blog (3)

Re: Store Language Stack

Postby a_bertrand » Wed Nov 23, 2016 10:53 am

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...
Creator of Dot World Maker
Mad programmer and annoying composer
User avatar
a_bertrand
New Worlds Engine creator
 
Posts: 1517
Joined: Mon Feb 25, 2013 8:46 am
Has thanked: 15 times
Been thanked: 23 times

Re: Store Language Stack

Postby hallsofvallhalla » Wed Nov 23, 2016 11:01 am

Dude thats quite awesome
User avatar
hallsofvallhalla
Site Admin
 
Posts: 11942
Images: 13
Joined: Wed Apr 22, 2009 6:29 pm
Location: mobile, al
Has thanked: 11 times
Been thanked: 158 times
Blog: View Blog (3)

Re: Store Language Stack

Postby a_bertrand » Wed Nov 23, 2016 11:13 am

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.
Creator of Dot World Maker
Mad programmer and annoying composer
User avatar
a_bertrand
New Worlds Engine creator
 
Posts: 1517
Joined: Mon Feb 25, 2013 8:46 am
Has thanked: 15 times
Been thanked: 23 times


Return to Advanced Help and Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron

x