Understanding lists and variable components to blockly script

683 views
Skip to first unread message

Loasil Jarise

unread,
Apr 25, 2017, 10:16:41 AM4/25/17
to CoSpaces Scripting
Hello, 

I'm new to Blockly and I'm looking for information on how to use the lists component and the variable component in Blockly. I think a breakdown on all the options beyond the abbreviated forms in the help section would actually be great and super useful, but right now, I'm just trying to figure out the lists and variables. 

I want to create a sort of dialogue within the environment between the viewer and the items, where the item responds appropriately based off of the option from a set list of possible phrases that the viewer can choose from. Is this how the list function can be used? If so, how? and If not, what can I do to make this happen?

As for the variable, I'm just wondering how this can be used, and what it means by making one.

Thanks


Daniel Pers

unread,
Apr 25, 2017, 6:43:37 PM4/25/17
to CoSpaces Scripting
Hi,
I also have those kinds of needs.
I think a bilboard is missing in CoSpaces (with Blockly).
Here is a solution using lists of sentences (which can be completed).
The program automatically generates lists of clickable objects that give the possibilitie to choose in the content of each sentence list.
My program in Play mode : http://edu.cospac.es/4tWR
To see the code : http://edu.cospac.es/4tWR
Does that correspond to your need?

Daniel, STEM teacher in France

Benjamin Singh

unread,
Apr 26, 2017, 4:26:29 AM4/26/17
to CoSpaces Scripting
Hi Loasil,

we're going to have tutorials on our website soon which will explain these concepts. But I try to explain.

You can think of a variable as a container which holds a certain value (e.g. a number). The value in this container can change (hence variable).


This is a simple example with three variables called "a", "b" and "sum".


1. First we assign the numerical value 0 to the variable "sum".

2. Then we assign the value 2 to the variable "a" and the value 3 to the variable "b".

3. Now we add "a" and "b" and assign the result to the variable "sum" (the value of "sum" changed from 0 to 5).

4. We use the variable "sum" for the "say" block.


Link to the example space: https://cospac.es/iH9B



Similar to a variable you can think of a list also as a container. The difference is that it can hold multiple values (or variables) like a box.



Lists are often used in conjunction with loops like in this example.


1. We create a list called "phrases". The list holds 3 different phrases (but could also be numbers or other variables).

2. Then we use a "for each" loop to iterate over the elements in the list.

3. For every element in the list the woman says the value of the element and the program pauses for 2 seconds.


Link to the example space: https://cospac.es/Av3J



The examples here were somewhat arbitrary. The use cases for variables and lists are very diverse. It depends on what you want to do. I didn't really understand what you're trying to do. How should your program exactly look like? The viewer should be able to choose a phrase and then the item will respond with a certain phrase?


Benjamin


Loasil Jarise

unread,
Apr 28, 2017, 5:46:31 PM4/28/17
to CoSpaces Scripting
As an update to what I am trying to accomplish:

I teach World Languages. I want to create an interactive game environment within CoSpaces, where my students can ultimately receive challenges and adventures from the items in the environment (therefore interacting appropriately within a given simulation, as a form of assessment). Emphasis on the game element. In order for them to have a more active interaction, I want for the students to think about how they would respond in the given context and see the effects of that response. I essentially want them to have the chance of saying the wrong thing. And only saying the right thing can let them advance in the environment.

So I want for there to be: 1- a list of possible responses from which they can choose in order to interact with the items and environment (because a response can lead to one corresponding action or the other) 2: a way to make a dialogue look 'natural' within the play mode (the student activates the item on click, and 'communicates' with it depending on how they and the item respond to each other

Right now, I am able to make a challenge 'appear' when the student finds it, and start the discussion necessary for the student to understand what the challenge is (pic 1), but I have no way of making the dialogue responsive for good or for bad (pic 2 is my attempt, which is obviously not working, cause I am stuck. but I also just added 'uh no, no thank you'. I wanted one option to just pop up for a 'starting level' challenge). This is my play mode, where the challenge is given by the woman, staring with the mark above her head: https://cospac.es/CNnR

I don't expect a pop up screen to arrive on the play mode naturally for my students to then choose an option and watch the environment change to match their response like a true game, but I'm thinking that the list option may lead to something that can work. I'm trying to see if anyone knows that set of code. And if it doesn't work, then how are lists used variously? (I have received some info on this from Benjamin Singh) 

As I'm writing this, and looking at the first two responses, maybe something like floating buttons made from posters writing surfaces that appear as needed?


As for the variable function, I would just like more information on that.

(This may be convoluted, but I really want to make this happen with CoSpaces. Thanks!)
Message has been deleted
Message has been deleted

Loasil Jarise

unread,
Apr 28, 2017, 5:55:18 PM4/28/17
to CoSpaces Scripting
Hi, 

Thanks! I'm pretty sure yours will lead me into the right direction, but I'm not able to see the coding you used through the link; it still directs to the Play Mode. Thanks!

Loasil Jarise

unread,
Apr 28, 2017, 5:56:19 PM4/28/17
to CoSpaces Scripting
Thank you for your help! Yes, I do want the item to respond appropriately to whatever my viewer deems as their response in the situation. From what your list example shows, it is more commonly used to cycle through cued responses?

Daniel Pers

unread,
Apr 29, 2017, 4:51:54 PM4/29/17
to CoSpaces Scripting
Sorry I didn't see your message.
If you want to see the code of my space with this link: http://edu.cospac.es/R4Fu
you have to create a student account on CoSpaces Edu from this link:
Then, if you click on the link of my space (http://edu.cospac.es/R4Fu), you can access a copy of my space on your CoSpaces account, which you can edit and use freely.
Please note that I can see your copy from my teacher account, I can even coallorate with you to modify it for example (this is the principle of CoSpaces Edu).
Be careful, when I update my space on my account, the link remains the same but your copy is not updated. If you click the link again, a new copy (update) will appear in your account.

Unfortunately I can't really understand what you want to do with your students. You should describe the desired behavior with a concrete example.
I would be glad to be able to help you but your version of CoSpaces does not favor collaborative work.

Daniel

Daniel Pers

unread,
Apr 30, 2017, 3:09:49 PM4/30/17
to CoSpaces Scripting
Hi,
Here is an example I share on Facebook :
I test solutions with Blockly to interact with 3D objects, possibly in motion, using buttons and pop-up pick lists.
For Play mode only: http://edu.cospac.es/Wl8m
To see the code in CoSpaces Edu: http://edu.cospac.es/OGGD

Daniel Pers

Reply all
Reply to author
Forward
0 new messages