prompt / alert plugin

Get help using Construct 2

Post » Fri Nov 18, 2011 8:46 pm

I'm juste learning very basic plugin writing.
I try to make an alert with the text that be inputed in the addstringparam.

So here is my action in the edittime.js

// Actions
AddStringParam("Set the text", "The text to set in the alert box.");
AddAction (0, 0, "Set text to display", "General", "Display: {0}", "Display text in an alert box", "SetText")

and here is my action in the runtime.js

// Actions
     pluginProto.acts = {};
     var acts = pluginProto.acts;
     
     acts.SetText = function (text)
     {
          alert(text);
     };

I don't really know javascript but have some basics. This way doesn't display anything.
Can you help me to solve that basic problem.
Thxsepteven2011-11-18 23:29:06
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Post » Fri Nov 18, 2011 8:50 pm

I don't know if it is just for learning or if you need it, but alert is already implemented in the browser object.

So if you need it, insert a browser object to your project. And if it is for learning, you can check the sources in c2\exporters\HTML5\plugins\browser.

EDIT: @septseven: Also be sure to check the SDK it links to good JS ressources.Kyatric2011-11-18 20:54:59
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Fri Nov 18, 2011 8:52 pm

Both :)
I'm gonna take a look to that right now. Thanks
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Post » Fri Nov 18, 2011 11:28 pm

I'm trying to do the same thing with "prompt" command.
I would know (because I didn't find the answer, in the SDK or on the web)
how to recup a value (string or numbers) from the prompt ? I would like to use it as expression, as get text of the text object.

In the same time, is it possible to know if a button of the prompt command is clicked ?

Thanks a lot for your helpsepteven2011-11-18 23:41:35
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Post » Sat Nov 19, 2011 12:00 am

Have you checked Mozilla's Javascript Guide - https://developer.mozilla.org/en/JavaScript/Guide and Mozilla's Javascript Reference - https://developer.mozilla.org/en/JavaScript/Reference ?

C2 forum can help on specific points/questions but learning javascript is something well-documented enough and you have to learn it on your own first.

EDIT: also Prompt seems to be linked to DOM, and ash advice not to mess with it in the SDK. I'm not sure there nevertheless.
But if you're starting with C2, you really shouldn't take the plugin route at first. Read the tutorials about C2 first and explore its "officials" plugins and the plugins provided by the community too.Kyatric2011-11-19 00:08:22
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Sat Nov 19, 2011 12:20 am

Yes I'm totally agree. But I'm curious, and I've worked for many years on Multimedia Fusion (and I still do) from clickteam, so I understand all basics of construct (which are not so different).
As I already explained, I don't do games but personal/professional apps, and unfortunately, C2 hasn't got already enough of plugins for that kind of using. That's why I try to add just some really simple features (as an input dialog)
That's my way of discovering ;) I can understand quickly javascript, as C2, but I'm not sure to well understand the way that plugin scripting and original javascript language are linked... You know what I mean ?
Merci toi ;)
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Post » Sat Nov 19, 2011 1:36 am

Plugin scripting is built on top of javascript.
JS is the language to use, with its rules, syntax, standard functions, etc...
Plugins (the SDK) are written in javascript and in such a way that it's interfaced with C2's events system.

This article from Scirra's blog might be a good read too. It clearly identifies each parts of C2 and their interactions/implications.
I can understand the feel to need more than there is actually, but I'm pretty sure text box, button, text, array, ajax, browser and webstorage objects + events system can already let you make nice functionning apps.
What more do you need ?
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Sat Nov 19, 2011 6:20 pm

Thanks you Kyatric, I'll read it and take a closer look to JS.
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Post » Sat Nov 19, 2011 7:30 pm

try to use this plugin
or see it as example...
B
4
S
1
G
1
Posts: 36
Reputation: 949

Post » Sun Nov 20, 2011 1:01 am

Finally, I figured out. I already did three options for my plugins, and it works. Thanks you all.

I may share it when it'll be finished.
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 24 guests