Skip to content

Commit 1e22acc

Browse files
authored
Merge pull request #52 from Secret-chest/conditions
2 parents b01ce7b + 948c73f commit 1e22acc

File tree

10 files changed

+21
-19
lines changed

10 files changed

+21
-19
lines changed

assets/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"targets":[{"isStage":true,"name":"Stage","variables":{"`jEk@4|i[#Fk?(8x)AV.-my variable":["variabila mea",0]},"lists":{},"broadcasts":{},"blocks":{},"comments":{},"currentCostume":0,"costumes":[{"name":"decor1","dataFormat":"svg","assetId":"cd21514d0531fdffb22204e0ec5ed84a","md5ext":"cd21514d0531fdffb22204e0ec5ed84a.svg","rotationCenterX":240,"rotationCenterY":180}],"sounds":[{"name":"pop","assetId":"83a9787d4cb6f3b7632b4ddfebf74367","dataFormat":"wav","format":"","rate":44100,"sampleCount":1032,"md5ext":"83a9787d4cb6f3b7632b4ddfebf74367.wav"}],"volume":100,"layerOrder":0,"tempo":60,"videoTransparency":50,"videoState":"on","textToSpeechLanguage":"ro"},{"isStage":false,"name":"Personaj1","variables":{},"lists":{},"broadcasts":{},"blocks":{"i0sF-x|[yQ-#%j@rU%f,":{"opcode":"event_whenflagclicked","next":")u+B7H(M9g25%Em.w=5;","parent":null,"inputs":{},"fields":{},"shadow":false,"topLevel":true,"x":360,"y":168},")u+B7H(M9g25%Em.w=5;":{"opcode":"control_forever","next":null,"parent":"i0sF-x|[yQ-#%j@rU%f,","inputs":{"SUBSTACK":[2,"|LMd9D?RO[2$-2d9tSaH"]},"fields":{},"shadow":false,"topLevel":false},"|LMd9D?RO[2$-2d9tSaH":{"opcode":"control_if_else","next":"a,Odr3Ov}z^5Jf(!Hu`y","parent":")u+B7H(M9g25%Em.w=5;","inputs":{"CONDITION":[2,"w!`lxu[+VTbb!a@:2IFM"],"SUBSTACK":[2,"[+(oxNIM5(qM,kq~)/=K"],"SUBSTACK2":[2,"8|07x?GC!6r+k@Gn?Ipk"]},"fields":{},"shadow":false,"topLevel":false},"w!`lxu[+VTbb!a@:2IFM":{"opcode":"sensing_keypressed","next":null,"parent":"|LMd9D?RO[2$-2d9tSaH","inputs":{"KEY_OPTION":[1,"@`Y@ky)Etn+{XJ-{4Vsb"]},"fields":{},"shadow":false,"topLevel":false},"@`Y@ky)Etn+{XJ-{4Vsb":{"opcode":"sensing_keyoptions","next":null,"parent":"w!`lxu[+VTbb!a@:2IFM","inputs":{},"fields":{"KEY_OPTION":["space",null]},"shadow":true,"topLevel":false},"[+(oxNIM5(qM,kq~)/=K":{"opcode":"looks_switchcostumeto","next":null,"parent":"|LMd9D?RO[2$-2d9tSaH","inputs":{"COSTUME":[1,"laZz,h-Z/Z?46wV,!;C*"]},"fields":{},"shadow":false,"topLevel":false},"laZz,h-Z/Z?46wV,!;C*":{"opcode":"looks_costume","next":null,"parent":"[+(oxNIM5(qM,kq~)/=K","inputs":{},"fields":{"COSTUME":["costum2",null]},"shadow":true,"topLevel":false},"8|07x?GC!6r+k@Gn?Ipk":{"opcode":"looks_switchcostumeto","next":null,"parent":"|LMd9D?RO[2$-2d9tSaH","inputs":{"COSTUME":[1,"AVNA2_i-lp8Nh=W*Fvdj"]},"fields":{},"shadow":false,"topLevel":false},"AVNA2_i-lp8Nh=W*Fvdj":{"opcode":"looks_costume","next":null,"parent":"8|07x?GC!6r+k@Gn?Ipk","inputs":{},"fields":{"COSTUME":["costum1",null]},"shadow":true,"topLevel":false},"a,Odr3Ov}z^5Jf(!Hu`y":{"opcode":"control_wait","next":null,"parent":"|LMd9D?RO[2$-2d9tSaH","inputs":{"DURATION":[1,[5,"1"]]},"fields":{},"shadow":false,"topLevel":false}},"comments":{},"currentCostume":0,"costumes":[{"name":"costum1","bitmapResolution":1,"dataFormat":"svg","assetId":"5b8a85774c8c983b993b7d1549b46082","md5ext":"5b8a85774c8c983b993b7d1549b46082.svg","rotationCenterX":47.678985050489445,"rotationCenterY":49.499230353205405},{"name":"costum2","bitmapResolution":1,"dataFormat":"svg","assetId":"1bf03016126b8879eb6228066a9a28a2","md5ext":"1bf03016126b8879eb6228066a9a28a2.svg","rotationCenterX":47.67898252524472,"rotationCenterY":49.49923017660271}],"sounds":[{"name":"Miau","assetId":"83c36d806dc92327b9e7049a565c6bff","dataFormat":"wav","format":"","rate":44100,"sampleCount":37376,"md5ext":"83c36d806dc92327b9e7049a565c6bff.wav"}],"volume":100,"layerOrder":1,"visible":true,"x":0,"y":0,"size":100,"direction":90,"draggable":false,"rotationStyle":"all around"}],"monitors":[],"extensions":[],"meta":{"semver":"3.0.0","vm":"1.2.52","agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36"}}
1+
{"targets":[{"isStage":true,"name":"Stage","variables":{"`jEk@4|i[#Fk?(8x)AV.-my variable":["variabila mea",0]},"lists":{},"broadcasts":{},"blocks":{},"comments":{},"currentCostume":0,"costumes":[{"name":"decor1","dataFormat":"svg","assetId":"cd21514d0531fdffb22204e0ec5ed84a","md5ext":"cd21514d0531fdffb22204e0ec5ed84a.svg","rotationCenterX":240,"rotationCenterY":180}],"sounds":[{"name":"pop","assetId":"83a9787d4cb6f3b7632b4ddfebf74367","dataFormat":"wav","format":"","rate":44100,"sampleCount":1032,"md5ext":"83a9787d4cb6f3b7632b4ddfebf74367.wav"}],"volume":100,"layerOrder":0,"tempo":60,"videoTransparency":50,"videoState":"on","textToSpeechLanguage":"ro"},{"isStage":false,"name":"Personaj1","variables":{},"lists":{},"broadcasts":{},"blocks":{"i0sF-x|[yQ-#%j@rU%f,":{"opcode":"event_whenflagclicked","next":")u+B7H(M9g25%Em.w=5;","parent":null,"inputs":{},"fields":{},"shadow":false,"topLevel":true,"x":360,"y":168},")u+B7H(M9g25%Em.w=5;":{"opcode":"control_forever","next":null,"parent":"i0sF-x|[yQ-#%j@rU%f,","inputs":{"SUBSTACK":[2,"|LMd9D?RO[2$-2d9tSaH"]},"fields":{},"shadow":false,"topLevel":false},"|LMd9D?RO[2$-2d9tSaH":{"opcode":"control_if_else","next":null,"parent":")u+B7H(M9g25%Em.w=5;","inputs":{"CONDITION":[2,"9}u1.m78Mq=qI@[$TT:G"],"SUBSTACK":[2,"[+(oxNIM5(qM,kq~)/=K"],"SUBSTACK2":[2,"8|07x?GC!6r+k@Gn?Ipk"]},"fields":{},"shadow":false,"topLevel":false},"9}u1.m78Mq=qI@[$TT:G":{"opcode":"sensing_mousedown","next":null,"parent":"|LMd9D?RO[2$-2d9tSaH","inputs":{},"fields":{},"shadow":false,"topLevel":false},"[+(oxNIM5(qM,kq~)/=K":{"opcode":"looks_switchcostumeto","next":null,"parent":"|LMd9D?RO[2$-2d9tSaH","inputs":{"COSTUME":[1,"laZz,h-Z/Z?46wV,!;C*"]},"fields":{},"shadow":false,"topLevel":false},"laZz,h-Z/Z?46wV,!;C*":{"opcode":"looks_costume","next":null,"parent":"[+(oxNIM5(qM,kq~)/=K","inputs":{},"fields":{"COSTUME":["costum2",null]},"shadow":true,"topLevel":false},"8|07x?GC!6r+k@Gn?Ipk":{"opcode":"looks_switchcostumeto","next":null,"parent":"|LMd9D?RO[2$-2d9tSaH","inputs":{"COSTUME":[1,"AVNA2_i-lp8Nh=W*Fvdj"]},"fields":{},"shadow":false,"topLevel":false},"AVNA2_i-lp8Nh=W*Fvdj":{"opcode":"looks_costume","next":null,"parent":"8|07x?GC!6r+k@Gn?Ipk","inputs":{},"fields":{"COSTUME":["costum1",null]},"shadow":true,"topLevel":false}},"comments":{},"currentCostume":0,"costumes":[{"name":"costum1","bitmapResolution":1,"dataFormat":"svg","assetId":"5b8a85774c8c983b993b7d1549b46082","md5ext":"5b8a85774c8c983b993b7d1549b46082.svg","rotationCenterX":47.678985050489445,"rotationCenterY":49.499230353205405},{"name":"costum2","bitmapResolution":1,"dataFormat":"svg","assetId":"1bf03016126b8879eb6228066a9a28a2","md5ext":"1bf03016126b8879eb6228066a9a28a2.svg","rotationCenterX":47.67898252524472,"rotationCenterY":49.49923017660271}],"sounds":[{"name":"Miau","assetId":"83c36d806dc92327b9e7049a565c6bff","dataFormat":"wav","format":"","rate":44100,"sampleCount":37376,"md5ext":"83c36d806dc92327b9e7049a565c6bff.wav"}],"volume":100,"layerOrder":1,"visible":true,"x":0,"y":0,"size":100,"direction":90,"draggable":false,"rotationStyle":"all around"}],"monitors":[],"extensions":[],"meta":{"semver":"3.0.0","vm":"1.2.54","agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"}}

block.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ def evaluateBlockValue(self, eventContainer=eventContainer.EventContainer):
9191
return KEY_MAPPING[self.getMenuValue("key_option")] in eventContainer.keys
9292
elif self.opcode == "operator_not": # not <>
9393
return not self.target.blocks[self.getBlockInputValue("operand")].evaluateBlockValue(eventContainer)
94+
elif self.opcode == "sensing_mousedown": # mouse down?
95+
return pygame.mouse.get_pressed()[0]
9496

9597
# Returns block input value
9698
def getBlockInputValue(self, inputId):

config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
# Project file name
2626
# If in test mode, set the Scratch project file to load.
27-
projectFileName: str = "projects/ChangeColourWithElse.sb3"
27+
projectFileName: str = "projects/MouseDown.sb3"
2828

2929
# Download cache size
3030
# Number of recent downloaded projects stored. 0 means infinity.

eventContainer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ def __init__(self):
33
self.keys = set()
44
self.keyEvents = set()
55
self.otherEvents = set()
6-

main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
along with this program. If not, see <https://www.gnu.org/licenses/>.
2020
"""
2121

22-
__version__ = "v0.4.0"
22+
__version__ = "v0.5.0"
2323
__author__ = "Secret-chest"
2424

2525
import tkinter.simpledialog

projects/MouseDown.sb3

40.8 KB
Binary file not shown.

projects/VariableStorage.sb3

11.9 KB
Binary file not shown.

sb3Unpacker.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import zipfile as zf
1010
import json
1111
import config
12-
import target, costume, sound, block, variable, monitor # , broadcast
12+
import target, costume, sound, block, monitor # , broadcast
1313
from pathlib import Path
1414
import io
1515
import pygame
@@ -82,6 +82,10 @@ def sb3Unpack(sb3):
8282
s.name = soundObj["name"]
8383
t.sounds.append(s)
8484

85+
# Get variables
86+
for variable in targetObj["variables"]:
87+
t.variables[variable] = targetObj["variables"][variable]
88+
8589
# Set blocks to their correct values
8690
for blockId, blockObj in targetObj["blocks"].items():
8791
b = block.Block()

target.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,14 @@ def __init__(self):
2727
self.rotationStyle = "all around" # all around, left-right or do not rotate
2828
self.sprite = None
2929
self.name = ""
30+
31+
# Variable functions
32+
def getVariableValue(self, varId):
33+
return self.variables[varId][1]
34+
35+
def getVariableName(self, varId):
36+
return self.variables[varId][0]
37+
38+
def setVariableValue(self, varId, newValue):
39+
self.variables[varId][1] = newValue
40+
return newValue

variable.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)