Skip to content

Commit 5a4cbb4

Browse files
committed
update 1.2
add new block: CCSystem and CCTextutils Fixed some bug
1 parent 218bb18 commit 5a4cbb4

26 files changed

+3474
-182
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"usedlibrary":["CCTextutils"],"content":{"blocks":{"languageVersion":0,"blocks":[{"type":"ide_start","id":"%k|1C%^t;XMrXr0{%gB|","x":330,"y":270,"inputs":{"DO":{"block":{"type":"variables_set","id":"NSMcwqhVU(1::#UWOflD","fields":{"VAR":{"id":"6z)4i^N`L0rGnHo}k6w~"}},"inputs":{"VALUE":{"block":{"type":"lists_create_with","id":"Rt}My_DC8m7QIYsmta-T","extraState":{"itemCount":3},"inputs":{"ADD0":{"block":{"type":"math_number","id":"7SKw2+Md2.{tznxyfe{T","fields":{"NUM":1}}},"ADD1":{"block":{"type":"math_number","id":"7UV1y^XFKM!,-6RK);`{","fields":{"NUM":2}}},"ADD2":{"block":{"type":"math_number","id":"MrfY2v6g)h3lj7e0jgqE","fields":{"NUM":3}}}}}}},"next":{"block":{"type":"text_print","id":"3+Z|78w,QkD{/[:jPv:e","inputs":{"TEXT":{"shadow":{"type":"text","id":"+OF[F($(eq]G$:h;Kt*w","fields":{"TEXT":"abc"}},"block":{"type":"textutils_serialize","id":"d{!#Az)#[M2rmGXXW,J,","fields":{"COMPACT":false,"ALLOWREPETI":true},"inputs":{"OBJECT":{"block":{"type":"lists_create_with","id":"W~HzfCNp_n@LA6c6fwp~","extraState":{"itemCount":2},"inputs":{"ADD0":{"block":{"type":"variables_get","id":"bVs`6KM30qehpXe901*:","fields":{"VAR":{"id":"6z)4i^N`L0rGnHo}k6w~"}}}},"ADD1":{"block":{"type":"variables_get","id":"@l4-(?lC]/$VetN_E!|^","fields":{"VAR":{"id":"6z)4i^N`L0rGnHo}k6w~"}}}}}}}}}}},"next":{"block":{"type":"text_print","id":"I^mHjxNqwwaU!Or,/m5@","inputs":{"TEXT":{"shadow":{"type":"text","id":"/!sl#s%!LHS,s5h05pQ;","fields":{"TEXT":"abc"}},"block":{"type":"textutils_serialize","id":"t7R?`7;1c%3!.jd.dW9F","fields":{"COMPACT":true,"ALLOWREPETI":false},"inputs":{"OBJECT":{"block":{"type":"variables_get","id":"!yZhT^MMVuSQ:[q|puo`","fields":{"VAR":{"id":"6z)4i^N`L0rGnHo}k6w~"}}}}}}}}}}}}}}}}]},"variables":[{"name":"test","id":"6z)4i^N`L0rGnHo}k6w~"}]}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"usedlibrary":["CCSystem","CCTextutils"],"content":{"blocks":{"languageVersion":0,"blocks":[{"type":"ide_start","id":"?udZVah+}|wlY2LCZ-bl","x":110,"y":150,"inputs":{"DO":{"block":{"type":"variables_set","id":"Q1no.e|r^Ds4Z(cOo6ks","fields":{"VAR":{"id":"|]HEFfXY)7GgpQb83nOc"}},"inputs":{"VALUE":{"block":{"type":"lists_create_with","id":"Qzp}4**d+m``G!B7ydBd","extraState":{"itemCount":0}}}},"next":{"block":{"type":"controls_repeat_ext","id":"h[fG-)EnPfn?;Dw,4JS;","inputs":{"TIMES":{"shadow":{"type":"math_number","id":"0,DMR{6Yro.qGGmsNI!m","fields":{"NUM":10}}},"DO":{"block":{"type":"sys_table_append_data","id":"_{Wr/]apCKw;wuLM!~tb","inputs":{"DATA":{"block":{"type":"math_random_int","id":"/dj{qRb:`dKxV-I6fB:c","inputs":{"FROM":{"shadow":{"type":"math_number","id":"6_%M8#LXu7~[op|p6@i+","fields":{"NUM":1}}},"TO":{"shadow":{"type":"math_number","id":"%dJUjQmbir}H?ZXa!Ghv","fields":{"NUM":10}}}}}},"TABLE":{"block":{"type":"variables_get","id":",7[Gq|+k;K=kAnpK0.dR","fields":{"VAR":{"id":"|]HEFfXY)7GgpQb83nOc"}}}}}}}},"next":{"block":{"type":"text_print","id":"bHx3OISYn{5x.-F2(|Y`","inputs":{"TEXT":{"shadow":{"type":"text","id":"jVr603(C3eOIz#G*N}UC","fields":{"TEXT":"abc"}},"block":{"type":"textutils_serialize","id":"}`]U9*1|Ev{J=[`ru9Q;","fields":{"COMPACT":false,"ALLOWREPETI":false},"inputs":{"OBJECT":{"block":{"type":"lists_sort","id":"EZpHsG`jZ.gBI;D?$b~L","fields":{"TYPE":"NUMERIC","DIRECTION":"1"},"inputs":{"LIST":{"block":{"type":"variables_get","id":"$Uf4s5MK,FWh^4jvKmFo","fields":{"VAR":{"id":"|]HEFfXY)7GgpQb83nOc"}}}}}}}}}}}}}}}}}}}]},"variables":[{"name":"mylist","id":"|]HEFfXY)7GgpQb83nOc"}]}}

advremote.lua

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,49 @@ local ws = assert(http.websocket("ws://127.0.0.1:5133"))
22
print("connected to server")
33

44
local id
5+
local isrunning = true
56

6-
while true do
7-
print("ready")
8-
local message, error = ws.receive()
9-
if message then
10-
print("Received message:", message)
11-
if message == "ping" then
12-
ws.send("pong")
13-
elseif message == "sendcode" then
14-
local file = io.open("main.lua", "w")
15-
print("waiting for code")
16-
local filedata, error = ws.receive()
17-
file:write(filedata)
18-
file:close()
19-
elseif message == "runcode" then
20-
id = multishell.launch({}, "main.lua")
21-
multishell.setTitle(id, "Code")
22-
multishell.setFocus(id)
23-
elseif message == "exit" then
7+
function exitcheck()
8+
while true do
9+
local event = os.pullEventRaw("terminate")
10+
if event == "terminate" then
2411
print("Exiting...")
12+
isrunning = false
13+
ws.close()
2514
break
2615
end
16+
end
17+
end
18+
19+
function main()
20+
while isrunning do
21+
print("ready")
22+
local message, error = ws.receive()
23+
if message then
24+
print("Received message:", message)
25+
if message == "ping" then
26+
ws.send("pong")
27+
elseif message == "sendcode" then
28+
local file = io.open("main.lua", "w")
29+
print("waiting for code")
30+
local filedata, error = ws.receive()
31+
file:write(filedata)
32+
file:close()
33+
elseif message == "runcode" then
34+
id = multishell.launch({}, "main.lua")
35+
multishell.setTitle(id, "Code")
36+
multishell.setFocus(id)
37+
elseif message == "exit" then
38+
print("Exiting...")
39+
break
40+
end
2741

28-
else
29-
print("WebSocket error:", error)
30-
break
42+
else
43+
print("WebSocket error:", error)
44+
break
45+
end
3146
end
3247
end
3348

34-
ws.close()
49+
parallel.waitForAny(exitcheck, main)
50+
print("Exited")

blocks/CCSettings/generator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ luaGenerator.forBlock['settings_define'] = function(block, generator) {
2929
if (def != "") {
3030
option.default = def
3131
}
32-
if (type != "") {
32+
if (type != "") {
3333
option.type = type
3434
}
3535
var exportedoption = exportWithEquals(option);

blocks/CCSystem/block_design.json

Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
{
2+
"sysos_pullevent": {
3+
"message0": "Pull %1 event",
4+
"args0": [
5+
{
6+
"type": "input_value",
7+
"name": "EVENT",
8+
"check": "String"
9+
}
10+
],
11+
"output": "Multiple",
12+
"colour": 0,
13+
"tooltip": "Pause execution of the current thread and waits for any events matching filter.",
14+
"helpUrl": "https://tweaked.cc/module/os.html#v:pullEvent"
15+
},
16+
"sysos_pullrawevent": {
17+
"message0": "Pull raw %1 event",
18+
"args0": [
19+
{
20+
"type": "input_value",
21+
"name": "EVENT",
22+
"check": "String"
23+
}
24+
],
25+
"output": "Multiple",
26+
"colour": 0,
27+
"tooltip": "Pause execution of the current thread and waits for events, including the terminate event.",
28+
"helpUrl": "https://tweaked.cc/module/os.html#v:pullEventRaw"
29+
},
30+
"sysos_version": {
31+
"message0": "Get system version",
32+
"output": "String",
33+
"colour": 0,
34+
"tooltip": "Get the current CraftOS version (for example, CraftOS 1.9)."
35+
},
36+
"sysos_run": {
37+
"message0": "Run %1\nEnvironment %2\nArgs %3",
38+
"args0": [
39+
{
40+
"type": "input_value",
41+
"name": "RUN",
42+
"check": "String"
43+
},
44+
{
45+
"type": "input_value",
46+
"name": "ENV",
47+
"check": "Array"
48+
},
49+
{
50+
"type": "input_value",
51+
"name": "ARGS",
52+
"check": "Multiple"
53+
}
54+
],
55+
"previousStatement": null,
56+
"nextStatement": null,
57+
"colour": 0,
58+
"tooltip": "Run the program at the given path with the specified environment and arguments.",
59+
"helpUrl": "https://tweaked.cc/module/os.html#v:run"
60+
},
61+
"sysos_queue_event": {
62+
"message0": "Add event %1 to queue with args %2",
63+
"args0": [
64+
{
65+
"type": "input_value",
66+
"name": "EVENT",
67+
"check": "String"
68+
},
69+
{
70+
"type": "input_value",
71+
"name": "ARGS",
72+
"check": "Multiple"
73+
}
74+
],
75+
"previousStatement": null,
76+
"nextStatement": null,
77+
"colour": 0,
78+
"tooltip": "Adds an event to the event queue. This event can later be pulled with os.pullEvent."
79+
},
80+
"sysos_start_timer": {
81+
"message0": "Start timer at %1",
82+
"args0": [
83+
{
84+
"type": "input_value",
85+
"name": "TIME",
86+
"check": "Number"
87+
}
88+
],
89+
"output": "Number",
90+
"colour": 0,
91+
"tooltip": "Starts a timer that will run for the specified number of seconds. Once the timer fires, a timer event will be added to the queue with the ID returned from this function as the first parameter.",
92+
"helpUrl": "https://tweaked.cc/module/os.html#v:startTimer"
93+
},
94+
"sysos_cancel_timer": {
95+
"message0": "Stop timer id %1",
96+
"args0": [
97+
{
98+
"type": "input_value",
99+
"name": "ID",
100+
"check": "Number"
101+
}
102+
],
103+
"previousStatement": null,
104+
"nextStatement": null,
105+
"colour": 0,
106+
"tooltip": "Cancels a timer previously started with startTimer. This will stop the timer from firing."
107+
},
108+
"sysos_set_alarm": {
109+
"message0": "Set alarm to %1",
110+
"args0": [
111+
{
112+
"type": "input_value",
113+
"name": "TIME",
114+
"check": "Number"
115+
}
116+
],
117+
"output": "Number",
118+
"colour": 0,
119+
"tooltip": "Sets an alarm that will fire at the specified in-game time."
120+
},
121+
"sysos_cancel_alarm": {
122+
"message0": "Stop alarm id %1",
123+
"args0": [
124+
{
125+
"type": "input_value",
126+
"name": "ID",
127+
"check": "Number"
128+
}
129+
],
130+
"previousStatement": null,
131+
"nextStatement": null,
132+
"colour": 0,
133+
"tooltip": "Cancels an alarm previously started with setAlarm."
134+
},
135+
"sysos_shutdown": {
136+
"message0": "Shutdown computer",
137+
"previousStatement": null,
138+
"colour": 0,
139+
"tooltip": "Shuts down the computer immediately."
140+
},
141+
"sysos_reboot": {
142+
"message0": "Restart computer",
143+
"previousStatement": null,
144+
"colour": 0,
145+
"tooltip": "Reboots the computer immediately."
146+
},
147+
"sysos_get_computer_id": {
148+
"message0": "Get computer id",
149+
"output": "Number",
150+
"colour": 0,
151+
"tooltip": "Returns the ID of the computer."
152+
},
153+
"sysos_get_computer_label": {
154+
"message0": "Get computer label",
155+
"output": "String",
156+
"colour": 0,
157+
"tooltip": "Returns the label of the computer, or nil if none is set."
158+
},
159+
"sysos_set_computer_label": {
160+
"message0": "Set computer label to %1",
161+
"args0": [
162+
{
163+
"type": "input_value",
164+
"name": "LABEL",
165+
"check": "String"
166+
}
167+
],
168+
"previousStatement": null,
169+
"nextStatement": null,
170+
"colour": 0,
171+
"tooltip": "Set the label of this computer."
172+
},
173+
"sysos_clock": {
174+
"message0": "Get Uptime",
175+
"output": "String",
176+
"colour": 0,
177+
"tooltip": "Returns the number of seconds that the computer has been running."
178+
},
179+
"sysos_time": {
180+
"message0": "Get time of %1",
181+
"args0": [
182+
{
183+
"type": "field_dropdown",
184+
"name": "LOCATE",
185+
"options": [
186+
["In Game World", "ingame"],
187+
["UTC", "utc"],
188+
["Local", "local"]
189+
]
190+
}
191+
],
192+
"output": null,
193+
"colour": 0,
194+
"tooltip": "Returns the current time depending on the string passed in. This will always be in the range [0.0, 24.0)."
195+
},
196+
"sysos_day": {
197+
"message0": "Get day of %1",
198+
"args0": [
199+
{
200+
"type": "field_dropdown",
201+
"name": "LOCATE",
202+
"options": [
203+
["In Game World", "ingame"],
204+
["UTC", "utc"],
205+
["Local", "local"]
206+
]
207+
}
208+
],
209+
"output": null,
210+
"colour": 0,
211+
"tooltip": "Returns the day depending on the locale specified."
212+
},
213+
"sysos_epoch": {
214+
"message0": "Get epoch of %1",
215+
"args0": [
216+
{
217+
"type": "field_dropdown",
218+
"name": "LOCATE",
219+
"options": [
220+
["In Game World", "ingame"],
221+
["UTC", "utc"],
222+
["Local", "local"]
223+
]
224+
}
225+
],
226+
"output": null,
227+
"colour": 0,
228+
"tooltip": "Returns the number of milliseconds since an epoch depending on the locale."
229+
},
230+
"sysos_date": {
231+
"message0": "Format date with patten %1 from time %2",
232+
"args0": [
233+
{
234+
"type": "input_value",
235+
"name": "FORMAT",
236+
"check": "String"
237+
},
238+
{
239+
"type": "input_value",
240+
"name": "TIME",
241+
"check": "Number"
242+
}
243+
],
244+
"output": null,
245+
"colour": 0,
246+
"tooltip": "Returns a date string (or table) using a specified format string and optional time to format.",
247+
"helpUrl": "https://cplusplus.com/reference/ctime/strftime/"
248+
}
249+
}

0 commit comments

Comments
 (0)