- D1 Meta Docs - Denizen Script -
Home Page / Pi to one million places / Contact mcmonkey / Donate / Paste Scripts / Denizen Help /
You are browsing as a guest.
Login | Register








The script repo is an archive of historical scripts. For modern scripts, or to post your own, please use the Scripts forum section.





A Calculator - simple, and gui


By dr_lennon
Created: 2017/03/01 03:08:36 UTC-08:00 (7 years and 298 days ago)
Edited: 2017/03/01 06:38:45 UTC-08:00 (7 years and 297 days ago)
Likes: 2

Denizen Version: 1.0.1 snapshot
Script Version: 1.0 snapshot
Description:

this is the simple GUI Calculator
run calc or c command.

can used to make a simple result

support +, -, *, / and Memory
digit support 2 point below.

thanks for reading

showcase here
https://youtu.be/lMsubN2jZFY


Download script | View raw script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
29500

#############################
# simple GUI Calculator
# scripted by dr_lennon
# 2017/3/1
# version 1.0
# special thanks to mcmonkey, blackcoyote, anthony, and Other Dev.
#############################

easy_command_inv_calculator:
    type: inventory
    title"GUI - calculator"
    size: 54
    definitions:
        b: i@eci_blank
        d1: i@eci_calculator_number_button[display_name=<&9>1;quantity=1]
        d2: i@eci_calculator_number_button[display_name=<&9>2;quantity=2]
        d3: i@eci_calculator_number_button[display_name=<&9>3;quantity=3]
        d4: i@eci_calculator_number_button[display_name=<&9>4;quantity=4]
        d5: i@eci_calculator_number_button[display_name=<&9>5;quantity=5]
        d6: i@eci_calculator_number_button[display_name=<&9>6;quantity=6]
        d7: i@eci_calculator_number_button[display_name=<&9>7;quantity=7]
        d8: i@eci_calculator_number_button[display_name=<&9>8;quantity=8]
        d9: i@eci_calculator_number_button[display_name=<&9>9;quantity=9]
        d0: i@eci_calculator_number_button_0[display_name=<&9>0]
        d00: i@eci_calculator_number_button_0[display_name=<&9>00]
        dot: i@eci_calculator_number_button_dot
        ac: i@eci_calculator_ac
        c: i@eci_calculator_c
        confirm: i@eci_calculator_confirm[lore=<&6>result :<&b><player.flag[eci_calc_display_value]||0>]
        equal: i@eci_calculator_equal[display_name=<&a>=;base_color=red;patterns=li@white/stripe_top|white/stripe_bottom|white/stripe_middle]
        plus: i@eci_calculator_operation[display_name=<&a>+;base_color=white;patterns=li@red/stripe_middle|red/stripe_center]
        minus: i@eci_calculator_operation[display_name=<&a>-;base_color=white;patterns=li@red/stripe_middle]
        multiply: i@eci_calculator_operation[display_name=<&a>÷;base_color=white;patterns=li@red/stripe_downleft]
        divide: i@eci_calculator_operation[display_name=<&a>X;base_color=white;patterns=li@red/cross]
        mr: i@eci_calculator_memory[display_name=<&9>MR;lore=<&6>memory - <&b><player.flag[eci_calc_memory_value]||0>]
        mc: i@eci_calculator_memory[display_name=<&9>MC]
        m+: i@eci_calculator_memory[display_name=<&9>M+]
        m-: i@eci_calculator_memory[display_name=<&9>M-]
        display1: i@eci_calculator_display[display_name=<&6>1;base_color=white;patterns=li@BLACK/SQUARE_TOP_LEFT|WHITE/BORDER|BLACK/STRIPE_CENTER]
        display2: i@eci_calculator_display[display_name=&62;base_color=white;patterns=li@BLACK/STRIPE_TOP|WHITE/RHOMBUS_MIDDLE|BLACK/STRIPE_DOWNLEFT|BLACK/STRIPE_BOTTOM|WHITE/BORDER]
        display3: i@eci_calculator_display[display_name=&63;base_color=white;patterns=li@BLACK/STRIPE_MIDDLE|WHITE/STRIPE_LEFT|BLACK/STRIPE_BOTTOM|BLACK/STRIPE_RIGHT|BLACK/STRIPE_TOP|WHITE/BORDER]
        display4: i@eci_calculator_display[display_name=&64;base_color=BLACK;patterns=li@WHITE/HALF_HORIZONTAL|BLACK/STRIPE_LEFT|WHITE/STRIPE_BOTTOM|BLACK/STRIPE_RIGHT|BLACK/STRIPE_MIDDLE|WHITE/BORDER]
        display5: i@eci_calculator_display[display_name=&65;base_color=white;patterns=li@BLACK/STRIPE_BOTTOM|BLACK/STRIPE_DOWNRIGHT|WHITE/CURLY_BORDER|BLACK/SQUARE_BOTTOM_LEFT|BLACK/STRIPE_TOP|WHITE/BORDER]
        display6: i@eci_calculator_display[display_name=&66;base_color=BLACK;patterns=li@WHITE/HALF_HORIZONTAL_MIRROR|BLACK/STRIPE_RIGHT|WHITE/STRIPE_TOP|BLACK/STRIPE_BOTTOM|BLACK/STRIPE_LEFT|WHITE/BORDER]
        display7: i@eci_calculator_display[display_name=&67;base_color=white;patterns=li@BLACK/STRIPE_TOP|WHITE/DIAGONAL_RIGHT|BLACK/STRIPE_DOWNLEFT|BLACK/SQUARE_BOTTOM_LEFT|WHITE/BORDER]
        display8: i@eci_calculator_display[display_name=&68;base_color=BLACK;patterns=li@WHITE/STRIPE_CENTER|BLACK/STRIPE_BOTTOM|BLACK/STRIPE_TOP|BLACK/STRIPE_MIDDLE|WHITE/BORDER]
        display9: i@eci_calculator_display[display_name=9;base_color=BLACK;patterns=li@WHITE/HALF_HORIZONTAL|BLACK/STRIPE_LEFT|WHITE/STRIPE_BOTTOM|BLACK/STRIPE_TOP|BLACK/STRIPE_RIGHT|WHITE/BORDER]
        display0: i@eci_calculator_display[display_name=0;base_color=white;patterns=li@BLACK/STRIPE_TOP|BLACK/STRIPE_BOTTOM|BLACK/STRIPE_RIGHT|BLACK/STRIPE_LEFT|WHITE/BORDER]
        displaydot: i@eci_calculator_display[display_name=dot;base_color=white;patterns=li@BLACK/SQUARE_BOTTOM_LEFT|WHITE/BORDER]
        displaydash: i@eci_calculator_display[display_name=-;base_color=white;patterns=li@BLACK/stripe_middle]

    procedural items:
        - define list li@
        - if <player.flag[eci_calc_display_value].mod[1]> > 0 {
            - define display <player.flag[eci_calc_display_value].round_to[2].to_list> }
        else {
            - define display <player.flag[eci_calc_display_value].to_list> }
        - define blank_digit <def[b]>
        - define redual_digit <el@9.sub[<def[display].size||li@>].max[0]>
        - repeat <def[redual_digit]> {
            - define list <def[list].include[<def[blank_digit]>]> }

        - foreach <def[display]> {
            - if <def[value]> = <el@-> {
                - define list <def[list].include[<def[displaydash]>]> }
            - if <def[value]> = <&dot> {
                - define list <def[list].include[<def[displaydot]>]> }
            else {
                - define number display<def[value]>
                - define list <def[list].include[<def[<def[number]>]>]> }
        }
        - determine <def[list]> 

    slots: 
        - "[b] [b] [b] [b] [eci_message] [b] [b] [b] [b]"
        - "[b] [mr] [b] [d1] [d2] [d3] [plus] [b] [b]"
        - "[b] [m+] [ac] [d4] [d5] [d6] [minus] [b] [b]"
        - "[b] [m-] [c] [d7] [d8] [d9] [multiply] [confirm] [b]"
        - "[b] [mc] [d00] [d0] [dot] [equal] [divide] [b] [b]"
        - "[] [] [] [] [] [] [] [] []"

## flag clear task
easy_command_inv_calculator_clear_task:
    type: task
    script:
    - ^flag player eci_calc_buffer_value:!
    - ^flag player eci_calc_result_value:!
    - ^flag player eci_calc_oper_value:!
    - ^flag player eci_calc_equal_value:!
    - ^flag player eci_calc_memory_value:!
    - ^flag player eci_calc_dot_position:0
    - ^flag player eci_calc_display_value:!

## calculator handler
easy_command_inv_calculator_handler:
    type: world
    events:

        on player clicks in easy_command_inv_calculator:
        - determine cancelled
        on player drags in easy_command_inv_calculator:
        - determine cancelled

        on player clicks eci_calculator_confirm in easy_command_inv_calculator:
        - narrate "<&6>result <&b><player.flag[eci_calc_display_value]>"
        - ~run easy_command_inv_calculator_clear_task
        - inventory close


        #clicks 1-9
        on player clicks eci_calculator_number_button in easy_command_inv_calculator:
        - if <player.flag[eci_calc_equal_value]||null> == true {
            - flag player eci_calc_result_value:!
            - flag player eci_calc_equal_value:! }

        - define initial <player.flag[eci_calc_buffer_value]||0>
        ## point below
        - if <player.flag[eci_calc_dot_position]||0> > 0 {
            - define belowdot <el@10.power[<player.flag[eci_calc_dot_position]>]>
            - define digitadd <def[initial].mul[<def[belowdot]>].add[<context.item.quantity>].div[<def[belowdot]>].round_to[6]>
            - flag player eci_calc_dot_position:+:1 }
        else {
            - define digitadd <def[initial].mul[10].add[<context.item.quantity>]> }

        - flag player eci_calc_buffer_value:<def[digitadd]>
        - flag player eci_calc_display_value:<player.flag[eci_calc_buffer_value]>

        - inventory open d:in@easy_command_inv_calculator

        #0 or 00
        on player clicks eci_calculator_number_button_0 in easy_command_inv_calculator:
        - if <player.flag[eci_calc_equal_value]||null> == true {
            - flag player eci_calc_result_value:!
            - flag player eci_calc_equal_value:! }
        - define initial <player.flag[eci_calc_buffer_value]||0>
        - choose <context.item.display>:
            - case "<&9>0":
                - if <player.flag[eci_calc_dot_position]||0> > 0 {
                    - flag player eci_calc_dot_position:+:1
                    - queue clear }
                - define digitadd <def[initial].mul[10]>
            - case "<&9>00":
                - if <player.flag[eci_calc_dot_position]||0> > 0 {
                    - flag player eci_calc_dot_position:+:2
                    - queue clear }
                - define digitadd <def[initial].mul[100]>
        - flag player eci_calc_buffer_value:<def[digitadd]>
        - flag player eci_calc_display_value:<player.flag[eci_calc_buffer_value]>

        - inventory open d:in@easy_command_inv_calculator

        ## dot
        on player clicks eci_calculator_number_button_dot in easy_command_inv_calculator:
        - if <player.flag[eci_calc_dot_position]> > 0 queue clear
        - flag player eci_calc_dot_position:1

        ## allclear
        on player clicks eci_calculator_ac in easy_command_inv_calculator:
        - ~run easy_command_inv_calculator_clear_task
        - inventory open d:in@easy_command_inv_calculator


        ### clear 
        on player clicks eci_calculator_c in easy_command_inv_calculator:
        - if  <player.flag[eci_calc_dot_position]||0> == 1 {
            - flag player eci_calc_dot_position:0
            - queue clear }
        else if <player.flag[eci_calc_dot_position]||0> >= 2 {
            - define belowdot <el@10.power[<player.flag[eci_calc_dot_position].sub[2]>]>
            - flag player eci_calc_buffer_value:<player.flag[eci_calc_buffer_value].mul[<def[belowdot]>].round_down.div[<def[belowdot]>]>
            - flag player eci_calc_dot_position:-:1
            - if <player.flag[eci_calc_dot_position]> == 1 flag player eci_calc_dot_position:0 }
        else {
            - flag player eci_calc_buffer_value:<player.flag[eci_calc_buffer_value].div[10].round_down> }

        - flag player eci_calc_display_value:<player.flag[eci_calc_buffer_value]>
        - inventory open d:in@easy_command_inv_calculator

        ## mr, mc, m+, m-
        on player clicks eci_calculator_memory in easy_command_inv_calculator:
        - choose <context.item.display>:
            - case "<&9>MR":
                - flag player eci_calc_buffer_value:<player.flag[eci_calc_memory_value]>
                - flag player eci_calc_display_value:<player.flag[eci_calc_memory_value]>
            - case "<&9>MC":
                - flag player eci_calc_memory_value:0
            - case "<&9>M+":
                - flag player eci_calc_memory_value:+:<player.flag[eci_calc_display_value]>
            - case "<&9>M-":
                - flag player eci_calc_memory_value:-:<player.flag[eci_calc_display_value]>
        - inventory open d:in@easy_command_inv_calculator

        # operator + - * /
        on player clicks eci_calculator_operation in easy_command_inv_calculator:
        - flag player eci_calc_dot_position:0
        - if <player.flag[eci_calc_equal_value]||null> == true {
            - flag player eci_calc_equal_value:! }
        - if <player.has_flag[eci_calc_result_value]> == true && <player.has_flag[eci_calc_oper_value]> == true && <player.has_flag[eci_calc_buffer_value]> == true {
            - if <player.flag[eci_calc_oper_value]> == <&a>+ {
                - flag player eci_calc_result_value:+:<player.flag[eci_calc_buffer_value]> }
            else if <player.flag[eci_calc_oper_value]> == <&a>- {
                - flag player eci_calc_result_value:-:<player.flag[eci_calc_buffer_value]> }
            else if <player.flag[eci_calc_oper_value]> == <&a>÷ {
                - flag player eci_calc_result_value:/:<player.flag[eci_calc_buffer_value]> }
            else if <player.flag[eci_calc_oper_value]> == <&a>X {
                - flag player eci_calc_result_value:*:<player.flag[eci_calc_buffer_value]> }
            - flag player eci_calc_buffer_value:!
            - flag player eci_calc_oper_value:<context.item.display>
            - flag player eci_calc_display_value:<player.flag[eci_calc_result_value]>
            - queue clear
        }
        - flag player eci_calc_oper_value:<context.item.display>
        - if <player.has_flag[eci_calc_buffer_value]> {
            - flag player eci_calc_result_value:<player.flag[eci_calc_buffer_value]>
            - flag player eci_calc_buffer_value:! }
        - inventory open d:in@easy_command_inv_calculator

        # = button
        on player clicks eci_calculator_equal in easy_command_inv_calculator:
        - flag player eci_calc_dot_position:0
        - choose <player.flag[eci_calc_oper_value]||0>:
            - case "0":
                - flag player eci_calc_result_value:<player.flag[eci_calc_buffer_value]>
            - case "<&a>+":
                - flag player eci_calc_result_value:+:<player.flag[eci_calc_buffer_value]>
            - case "<&a>-":
                - flag player eci_calc_result_value:-:<player.flag[eci_calc_buffer_value]>
            - case "<&a>÷":
                - flag player eci_calc_result_value:/:<player.flag[eci_calc_buffer_value]>
            - case "<&a>X":
                - flag player eci_calc_result_value:*:<player.flag[eci_calc_buffer_value]>
        - flag player eci_calc_buffer_value:!
        - flag player eci_calc_display_value:<player.flag[eci_calc_result_value]>
        - flag player eci_calc_equal_value:true
        - inventory open d:in@easy_command_inv_calculator

## press buttons
eci_blank:
    type: item
    Material: gray_stained_glass_pane
    display name' '
eci_message:
    type: item
    Material: workbench
    display name'<&6>calculator'
eci_calculator_memory:
    type: item
    material: chest
eci_calculator_number_button_dot:
    type: item
    Material: ink
    display name<&9>.
eci_calculator_number_button:
    type: item
    Material: lime_dye
eci_calculator_number_button_0:
    type: item
    Material: gray_dye
eci_calculator_display:
    type: item
    material: banner
eci_calculator_AC:
    type: item
    Material: bone_meal
    display name<&c>AC
eci_calculator_C:
    type: item
    Material: light_gray_dye
    display name<&c>C
eci_calculator_confirm:
    type: item
    Material: compass
    display name<&a>print output
eci_calculator_operation:
    type: item
    Material: banner
eci_calculator_equal:
    type: item
    Material: banner


easy_command:
    type: command
    name: calc
    aliases:
    - c
    description: The calculator
    usage:
    - /calc - open your gui calculator
    script:
    - run easy_command_inv_calculator_clear_task instantly
    - inventory open d:in@easy_command_inv_calculator







View History