Skip to main content

scratch_test_model/blocks/
expressions.rs

1use crate::attrs::{
2    ArgumentReporterName, DirectDropdownOf, Expression, List, RoundDropdownMenuOf,
3    dropdowns::{
4        LooksBackdropnumbername, LooksCostumenumbername, OperatorMathop, SensingCurrent,
5        SensingDistanceto, SensingOfObject, SensingOfProperty,
6    },
7};
8use scratch_test_model_proc::Block;
9
10#[derive(Debug, PartialEq, Clone, Block)]
11#[block(default_location = inputs)]
12pub enum ExprBlockKind {
13    ArgumentReporterStringNumber {
14        #[block(location = fields)]
15        value: ArgumentReporterName,
16    },
17
18    DataItemnumoflist {
19        #[block(location = fields)]
20        list: List,
21        item: Expression,
22    },
23    DataItemoflist {
24        #[block(location = fields)]
25        list: List,
26        index: Expression,
27    },
28    DataLengthoflist {
29        #[block(location = fields)]
30        list: List,
31    },
32
33    LooksBackdropnumbername {
34        #[block(location = fields)]
35        number_name: DirectDropdownOf<LooksBackdropnumbername>,
36    },
37    LooksCostumenumbername {
38        #[block(location = fields)]
39        number_name: DirectDropdownOf<LooksCostumenumbername>,
40    },
41    LooksSize,
42
43    MotionDirection,
44    MotionIfonedgebounce,
45    MotionXposition,
46    MotionYposition,
47
48    OperatorAdd {
49        num1: Expression,
50        num2: Expression,
51    },
52    OperatorMultiply {
53        num1: Expression,
54        num2: Expression,
55    },
56    OperatorSubtract {
57        num1: Expression,
58        num2: Expression,
59    },
60    OperatorDivide {
61        num1: Expression,
62        num2: Expression,
63    },
64    OperatorMod {
65        num1: Expression,
66        num2: Expression,
67    },
68    OperatorMathop {
69        #[block(location = fields)]
70        operator: DirectDropdownOf<OperatorMathop>,
71        num: Expression,
72    },
73    OperatorRound {
74        num: Expression,
75    },
76    OperatorRandom {
77        from: Expression,
78        to: Expression,
79    },
80    OperatorLength {
81        string: Expression,
82    },
83    OperatorJoin {
84        string1: Expression,
85        string2: Expression,
86    },
87    OperatorLetterOf {
88        letter: Expression,
89        string: Expression,
90    },
91
92    SensingAnswer,
93    /// ```
94    /// # use scratch_test_model::blocks::ExprBlockKindUnit;
95    /// assert_eq!("sensing_dayssince2000", ExprBlockKindUnit::SensingDayssince2000.k_opcode_name());
96    /// ```
97    #[block(opcode = "sensing_dayssince2000")]
98    SensingDayssince2000,
99    SensingDistanceto {
100        distancetomenu: RoundDropdownMenuOf<SensingDistanceto>,
101    },
102    SensingCurrent {
103        #[block(location = fields)]
104        currentmenu: DirectDropdownOf<SensingCurrent>,
105    },
106    SensingOf {
107        #[block(location = fields)]
108        property: DirectDropdownOf<SensingOfProperty>,
109        object: RoundDropdownMenuOf<SensingOfObject>,
110    },
111    SensingUsername,
112    SensingMousex,
113    SensingMousey,
114    SensingLoudness,
115    SensingTimer,
116
117    SoundVolume,
118}