#(sebii) Is there a way to set definitions for a world script, before it is being run?

115 messages · Page 1 of 1 (latest)

wise granite
#

I wanna be able to make it easy for my homie to copy paste scripts that fulfill the exact same function, so i'm trying to give him the ability to just have preset definitions that he edits. Is that possible?

fallen cometBOT
#

(sebii) Is there a way to set definitions for a world script, before it is being run?

fallen cometBOT
#

Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.

glacial skiff
#

You would set the definitions to the first couple lines, and they would carry over for the rest of the script

wise granite
glacial skiff
#

Or you could use a task script and set definitions through the run command

#

!l task script

echo mortarBOT
# glacial skiff !l task script

Task script containers are generic script containers for commands that can be run at
any time by command.

Generally tasks will be ran by !command run or !command inject.

The only required key on a task script container is the 'script:' key.


Task_Script_Name:

    type: task

    # When intending to run a task script via the run command with the "def:" argument to pass data through,
    # use this "definitions" key to specify the names of the definitions (in the same order as the "def:" argument will use).
    # You can optionally document a definition with [square brackets]
    definitions: name1|name2[description here]|...

    script:

    - your commands here


Group

Script Container System

glacial skiff
#

!c run

echo mortarBOT
# glacial skiff !c run
Group

queue

Syntax

run [<script>] (path:<name>) (def:<element>|.../defmap:<map>/def.<name>:<value>) (id:<name>) (speed:<value>/instantly) (delay:<value>)

Short Description

Runs a script in a new queue.

Description

Runs a script in a new queue.

You must specify a script object to run.

Optionally, use the "path:" argument to choose a specific sub-path within a script.

Optionally, use the "def:" argument to specify definition values to pass to the script,
the definitions will be named via the "definitions:" script key on the script being ran,
or numerically in order if that isn't specified (starting with <[1]>).

Alternately, use "defmap:<map>" to specify definitions to pass as a MapTag, where the keys wi...

wet kelp
#

would that be more likely to data scripts?

wise granite
# glacial skiff Or you could use a task script and set definitions through the `run` command
#
# QUEST CSDAILY
dgtwo_quest_check:
    type: world
    events:
# START QUEST
        after quests player starts quest:
        - define quest_id <context.quest>
        - if <context.quest> contains 000051:
            - flag <player> quest_000051_kills:0
# KILL GHOUL
        after player kills npc:
        - if <player.quests.active_ids> contains 000051:
            - if <server.npcs_named[Ghoul]> contains <npc>:
# [quest_000051_stage] = QUEST STAGE FLAG from #STAGE CHANGE LOGIC
                - if <player.flag[quest_000051_stage]> = 2:
                    - flag <player> quest_000051_kills:++
                    - if <player.flag[quest_000051_kills]> = 10:
                        - narrate "<&color[<color[orange]>]>You have killed<&color[<color[aqua]>]> <player.flag[quest_000051_kills]>/10<&color[<color[orange]>]> Ghouls." targets:<player>
                        - quests set quest:000051 stage:2
                    - else if <player.flag[quest_000051_kills]> < 10:
                        - narrate "<&color[<color[orange]>]>You have killed<&color[<color[aqua]>]> <player.flag[quest_000051_kills]>/10<&color[<color[orange]>]> Ghouls" targets:<player>
# END QUEST
        after quests player completes quest:
        - if <context.quest> contains 000051:
            - flag <player> quest_000051_kills:!

This is the script... how would i efficiently do this whole thing.
(i have a world_script that handles the quest_xxxxx_stage value.)
Still W.I.P with other stuff in mind

wet kelp
#

they can act as configs

wise granite
wet kelp
#

yes

#

!l data script

echo mortarBOT
# wet kelp !l data script

Data script containers are generic script containers for information that will be referenced by other scripts.

No part of a 'data' script container is ever run as commands.

There are no required keys.

Generally, data is read using the !tag ScriptTag.data_key tag.


data_script_name:

    type: data

    # Your data here
    some_key: some value
    some_list_key:
    - some list value
    some_map_key:
        some_subkey: some value


Group

Script Container System

grim vortex
# wise granite I wanna be able to make it easy for my homie to copy paste scripts that fulfill ...

make a task script that defines everything
then just inject that in every event in your world script

i constantly do this. example:

        on player right clicks block with:skills_item_supernova flagged:skills.supernova:
        - determine passively cancelled
        - ratelimit <player> 0.5s
        - define id supernova
        - inject skills_inject_cooldown_handler
        ...

skills_inject_cooldown_handler:
    type: task
    debug: false
    script:
    - inject skills_inject_skills_get_player_skill_info
    ...

skills_inject_skills_get_player_skill_info:
    type: task
    debug: false
    script:
    - define name <player.flag[skills].keys.first.if_null[null]>
    - define info <player.flag[skills.<[name]>].if_null[null]>

lengthy example aside, i inject skills_inject_cooldown_handler in all relevant events, and then it just figures out a ton of things for me, especially the name and info definitions

#

as for what you're definining, i agree with joenh that you should be using a data script

#

as to how, i'd use what i just sent an example of

wise granite
grim vortex
#

HAHAHAHAHAH no worries man, we've all been through there

wet kelp
#

except for saturo gojo ofc

wise granite
grim vortex
echo mortarBOT
eager grove
#

could you upload that script here please

wise granite
#
  • Every quest_questid_kills or _stage i want to be variable.
  • The hard coded stage numbers and kills i want to be variable aswell.
  • The hardcoded "contains 000051" i want to be variable aswell.
  • NPC name i also want variable.
    I know how to do the above.
    i just dont know how i can make it easy for my homie to just set
    QuestID, NPCName, kills, stage...
    Thats what i want to be easy to use for him.
#

cuz there are a shit-ton of quests that will follow. Unique NPC Names, kills depending on the quest, and stages depending on the setup of the stage.

eager grove
#

in that case you probably want a data script like drjoenh said above

#

and have maybe a data script per quest

#

or put everything into a single data script

#

and the logic will happen from relevant world events that read a players state and compare it to the data script

#

e.g. a quest requires you to kill 10 zombies

wise granite
#

yeah, that was my idea atm aswell... But there is a check at the top that checks for "active_ids".
How am i able to not hardcode values in that.

eager grove
#

so you flag the player with the task

#

and then let the kill event read what the player has to kill, compare it to the flag and do your things

#

actually - looking into your script - it seems like you are using a quest plugin?

wise granite
#

"why not let the quest plugin handle what you are doing there?"

eager grove
#

rather "why not let denizen handle everything"

wise granite
#

we're running 1.21.8 and i am usually not a fan of dev versions

#

but we're run into a couple of problems, so we kinda start needing it

#

so i'm running dev version 7222 rn, which works

#

AND

#

I'm hella new to denizen

#

Denizen by itself is already kinda overwhelming

eager grove
wise granite
#

and My friend would need to learn denizen aswell

#

and any person thats able to make quests

#

and using a simple gui that everyone already knows is easier, than me making my own solution 🫠

eager grove
#

there is just no release because mojingle pushes a new version every week

wise granite
#

not a fan of a "dev version" on a live-server, but it is what it is

#

I'm testing the scripts on my local test server ofc.

#

and then transfer them

#

the quest plugin has a small quirk ->
If you have a "kill npc" quest, it has to have an amount of kills per npc thats set.
So if its 100 ghosts, you'd have to kill each unique ghost once

#

because its distinguished by uuid

#

thats why we are going to denizen with this issue

#

have the actual npc in another world, so the quest plugin doesnt trigger its progress response, with copies in the actual world where the player needs to go, and move the quest further using the denizen script

#

but yeah...
Data Container, World container, task container... now i just need to figure out how to put all that together...

#

oh, another quick question.
Can i create subfolders within the scripts folder?

#

to sort the scripts neatly

wet kelp
#

yes

wise granite
noble yarrowBOT
#

+> YAY!!!

polar bayBOT
#
Resolved

Thread closed as resolved.

wise granite
#

ok, i do need help with something attached to this xD

polar bayBOT
#
Thread Reopened

Thread was manually reopened by @wise granite.

wise granite
#

how do i check if a key on a map exists?

#
    type: data
    000051:
        npcname: Ghoul
        kill_amount: 10
        kill_stage: 1
        quest_type: kill

Thats the map.
i already found out, how i can read the map with <script[nameofscript].data_keys[nameofmap.npcname]> for example.
i just need to know how i can check if the map exists.
So in this case -> 000051 exists, but 000052 doesnt.
How can i do an if command, so that it just checks, if it exists?

wet kelp
#

!t script.contains_key

echo mortarBOT
#
Possible Confusion

Did you mean to search for elementtag.contains_text?

wet kelp
#

um

#

what was it

wise granite
minor voidBOT
wet kelp
#

could probably

#

list_keys and contains_single

wise granite
#

because rn, it replies with "li@000051|type|"
and so i can just do = quest_id and it will work. Great, thanks!

#

oh

#

is there a general "exists" operator form?

wet kelp
#

uhhh

#

!t exists

echo mortarBOT
# wet kelp !t exists
Cannot Specify Searched Tag

Multiple possible tags: <schematic[<name>].exists>, <ObjectTag.exists>, <server.scoreboard[<board>].exists>.

wet kelp
#

but what exactly you want?

wise granite
# wet kelp but what exactly you want?

If there is an operator to use in an if command, that denouncens existence of something...
So for example:
- if <player.flag[hahahahalmaooooo]> exists

#

So when its null, it doesnt start the codeblock below

wet kelp
#

!t objecttag.exists

echo mortarBOT
# wet kelp !t objecttag.exists

Returns true if the object exists (is non-null). Returns false if the object doesn't exist, is null, or the tag errored.
This functions as a fallback - meaning, if the tag up to this point errors, that error will be hidden.

Returns

ElementTag(Boolean)

wise granite
#

ah

wet kelp
#

in that case you can ofc use flaggableobject.has_flag[hahahalmaooooo]

wise granite
#

and because it then replies with "true", i dont need an "= true" at the end of my if statement

wet kelp
#

yup

wise granite
#

perfect

#

thats... great

#

ye

#

thanks alot

wet kelp
#

theres also

#

!t if_null

echo mortarBOT
# wet kelp !t if_null

If the object is null (or the tag errors), this will return the input object.
If the object isn't null, the input won't be parsed, and the original object will be returned.
For example, "<player.if_null[<npc>]>" will return the player if there is a player, and otherwise will return the NPC.
This functions as a fallback - meaning, if the tag up to this point errors, that error will be hidden.

Returns

ObjectTag

wet kelp
#

which i love even more

wise granite
#

ooooh

#

if_null ist actually much better

#

because even if it doesnt exist, it might still return a value

#

anyways, thank you!