Created
January 3, 2021 09:20
-
-
Save lofcz/21f6413a0f6e0ebf11e2af4332306545 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
data: { | |
working: 0, | |
durability: 20, | |
fuel: 0, | |
maxFuel: 5, | |
trickleInterval: 2, | |
trickleEnergyBase: 8, | |
trickleEnergyAddPerFuel: 2, | |
lastTrickleValue: 0, | |
currentStoredEnergy: 0 | |
}, | |
functions: [ | |
{ | |
name: "trickleHandler", | |
script: [ | |
{ | |
conditionsAll: [ | |
{ | |
left: "fuel", | |
right: 0, | |
compare: ">" | |
} | |
], | |
actions: [ | |
{ | |
type: A_VARIABLE, | |
variable: "lastTrickleValue", | |
operation: "=", | |
value: "{trickleEnergyBase} + {trickleEnergyAddPerFuel} * {fuel}", | |
eval: true | |
}, | |
{ | |
type: A_NOTIFICATION, | |
notification: N_INFO, | |
text: "V peci shořelo uhlí, zbývá {fuel} / {maxFuel} kusů. Získal jsi {lastTrickleValue} energie." | |
}, | |
{ | |
type: A_KERNEL, | |
kernel: K_PLAYER_SET_ENERGY, | |
operation: "+=", | |
value: "lastTrickleValue", | |
}, | |
{ | |
type: A_VARIABLE, | |
variable: "currentStoredEnergy", | |
value: "8 + {fuel} * 2", | |
operation: "-=", | |
eval: true | |
}, | |
{ | |
type: A_VARIABLE, | |
variable: "fuel", | |
value: 1, | |
operation: "-=" | |
}, | |
{ | |
type: A_KERNEL, | |
kernel: K_REFRESH_INVENTORY | |
} | |
] | |
}, | |
{ | |
conditionsAll: [ | |
{ | |
left: "fuel", | |
right: 0, | |
compare: ">" | |
} | |
], | |
actions: [ | |
{ | |
type: A_KERNEL, | |
kernel: K_TASK, | |
task: { | |
script: "trickleHandler", | |
store: "jobId", | |
date: { | |
type: TIMESPAN_FROM_NOW, | |
modifiers: [ | |
{ | |
type: TIMESPAN_EXACT, | |
value: "{trickleInterval}", | |
units: TIMESPAN_SECOND | |
} | |
] | |
} | |
} | |
} | |
] | |
}, | |
{ | |
conditionsAll: [ | |
{ | |
left: "fuel", | |
right: 0, | |
compare: "==" | |
} | |
], | |
actions: [ | |
{ | |
type: A_NOTIFICATION, | |
notification: N_INFO, | |
text: "Pec dohořela" | |
}, | |
{ | |
type: A_VARIABLE, | |
variable: "working", | |
value: 0, | |
operation: "=" | |
} | |
] | |
} | |
] | |
} | |
], | |
dnd: [ | |
{ | |
type: TYPEOF_OBJ_MATERIAL, | |
id: [O_MATERIAL_ORE_COAL], | |
actions: [ | |
{ | |
conditionsAll: [ | |
{ | |
left: "fuel", | |
right: "maxFuel", | |
compare: "<" | |
} | |
], | |
actions: [ | |
{ | |
type: A_VARIABLE, // zvýším uskladněné palivo o 1 | |
variable: "fuel", | |
operation: "+=", | |
value: 1 | |
}, | |
{ | |
type: A_VARIABLE, | |
variable: "currentStoredEnergy", | |
value: "8 + {fuel} * 2", | |
operation: "+=", | |
eval: true | |
}, | |
{ | |
type: A_KERNEL, // přepnu na uhlí | |
kernel: K_SET_TARGET, | |
target: TARGET_OTHER | |
}, | |
{ | |
type: A_KERNEL, // snížíme množství ve stacku o 1, pokud klesne na 0, stack se zničí automaticky | |
kernel: K_CHANGE_AMOUNT_SELF, | |
operation: "-=", | |
value: 1 | |
}, | |
{ | |
type: A_NOTIFICATION, | |
notification: N_INFO, | |
text: "V peci je teď {fuel} / {maxFuel} uhlí" | |
} | |
], | |
post: { | |
exit: true | |
} | |
}, | |
{ | |
actions: [ | |
{ | |
type: A_NOTIFICATION, | |
notification: N_ERROR, | |
text: "Pec je zaplněná a už do ní nemůžeš dát další uhlí" | |
} | |
] | |
} | |
] | |
} | |
], | |
options: [ | |
{ | |
name: "Zapálit", | |
actions: [ | |
{ | |
conditionsAll: [ // aby mohla být pec zapálená | |
{ | |
left: "working", // nesmí ještě hořet | |
right: 0, | |
compare: "==" | |
}, | |
{ | |
left: "fuel", // a musí v ní být nějaké uhlí | |
right: "0", | |
compare: ">" | |
} | |
], | |
actions: [ | |
{ | |
type: A_VARIABLE, // pec hoří | |
variable: "working", | |
value: 1, | |
operation: "=" | |
}, | |
{ | |
type: A_KERNEL, | |
kernel: K_TASK, | |
task: { | |
script: "trickleHandler", | |
store: "jobId", | |
date: { | |
type: TIMESPAN_FROM_NOW, | |
modifiers: [ | |
{ | |
type: TIMESPAN_EXACT, | |
value: "{trickleInterval}", | |
units: TIMESPAN_SECOND | |
} | |
] | |
} | |
} | |
} | |
], | |
post: { | |
exit: true | |
} | |
}, | |
{ | |
conditionsAll: [ | |
{ | |
left: "working", | |
right: 1, | |
compare: "==" | |
} | |
], | |
actions: [ | |
{ | |
type: A_NOTIFICATION, | |
notification: N_ERROR, | |
text: "Počkej než pec dohoří" | |
} | |
], | |
post: { | |
exit: true | |
} | |
}, | |
{ | |
actions: [ | |
{ | |
type: A_NOTIFICATION, | |
notification: N_ERROR, | |
text: "Pec je prázdná, nejprve do ní dej nějaké uhlí" | |
} | |
] | |
} | |
] | |
} | |
], | |
render: [ | |
{ | |
type: UI_LINE, | |
text: "V peci je {fuel} / {maxFuel} uhlí" | |
}, | |
{ | |
type: UI_LINE, | |
text: "Množství uskladněné energie: {currentStoredEnergy}", | |
style: { | |
color: 'yellow', | |
} | |
}, | |
{ | |
type: UI_LINE, | |
text: "Za každé vložené uhlí po jeho spálení získáš <b>8 + (2 * aktuální množství uhlí)</b> energie. Vyplatí se tedy pec pořádně napěchovat!", | |
style: { | |
color: 'darkgray', | |
italics: true | |
} | |
}, | |
{ | |
type: UI_LINE, | |
text: "Pec je schopná spálit jeden kus uhlí za dvě sekundy.", | |
style: { | |
color: 'darkgray', | |
italics: true | |
} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment