Question regarding JS/AS integration

Post Reply
User avatar
Johannes
Posts: 1374
Joined: Thu Dec 18, 2008 1:26 am
Contact:

Question regarding JS/AS integration

Post by Johannes » Wed Dec 07, 2011 4:19 am

Hiya guys,

I've been trying to mod the UI a bit, but have not been able to properly integrate the Angelscript function calls in the Javascript elements. I'm almost certain that I'm missing something simple and obvious here, perhaps you can help me out. (It might also just be that what i'm trying to do is currently impossible, in which case I'll feel even dummer.)


Let's take a very simple example. In AS you can simply display some text with:

Code: Select all

SendLevelMessage2("displaytext","derp text here");
Plop that in a hotspot script and it works, no problem.

However if have not yet figured out how to call the same function from within the webkit User Interface, assuming of-course that's possible. For example, in palette.html (the tool palette) I tried repurposing the onclick() of the brush tool (line 95), and would like to do something like

Code: Select all

onclick="Client.SendLevelMessage2('displaytext','derp text here');"
I've tried several permutations, like leaving out the 'Client.' and such, with no luck.


Ultimately I'd like to load UI elements, like a custom window, by clicking a button in either the ribbon or the palette, basically using something like 'gui.AddGUI(...)' etc.


Also, It would be very useful for debugging purposes to write to the console. I found several functions mentions of 'console.warn()' and 'console.error()' in Data/UI/global/util.js but those don't seem to do anything.



Has anyone had any luck trying to create a new window from within The Webkit UI?
Any thoughts would be appreciated.

User avatar
adwuga
Posts: 2176
Joined: Tue Aug 18, 2009 12:09 pm
Location: America... Fuck yeah.

Re: Question regarding JS/AS integration

Post by adwuga » Wed Dec 07, 2011 6:15 pm

Last added buttons to the escape menu, so it's possible.

User avatar
Johannes
Posts: 1374
Joined: Thu Dec 18, 2008 1:26 am
Contact:

Re: Question regarding JS/AS integration

Post by Johannes » Wed Dec 07, 2011 11:25 pm

Talked to Jeff a bit, and he says that what I'm trying to do here might not currently be possible. He mentioned that the 'Client' object is currently not really implemented.

Will keep experimenting, but might not be possible for a while.

User avatar
last
Posts: 2154
Joined: Fri Jan 07, 2011 7:02 am
Location: Estonia

Re: Question regarding JS/AS integration

Post by last » Thu Dec 08, 2011 3:01 pm

First I don't really understand what you want to do.
Do you wan't to display some random text when you press a button in some sort of menu?
Here is a custom menu named Game menu and it is able to display text as a separate window.<br />I clicked on No death mod on/off button and then it displayes me text (No death mod) + a string value. Right now it is 1
Here is a custom menu named Game menu and it is able to display text as a separate window.
I clicked on No death mod on/off button and then it displayes me text (No death mod) + a string value. Right now it is 1
I do almost all that in level.as. Onley buttons and button values are defined in my menu html file

User avatar
Johannes
Posts: 1374
Joined: Thu Dec 18, 2008 1:26 am
Contact:

Re: Question regarding JS/AS integration

Post by Johannes » Thu Dec 08, 2011 3:34 pm

Ah, heh, I think what I was looking for is the GenericCallback function.
See, I knew I was missing something obvious.

Basically I want to make tools like the stacker tool you can get for Gmod: Image
It allows the user to select an object, have the UI update with some info about that object which the user can then change, create new objects with, etc.

So far I had managed to add UI elements fine, but couldn't figure out how to have the UI communicate with the level script.

Anyways, sorry for wasting your time :lol:

Post Reply