#add a score by pressing a button and score equals effect
1 messages · Page 1 of 1 (latest)
Do you have a current script with form button? You would i++
Ur just tryn to go up and down on the strength etc.
?
Just tryn to figure out your end goal
Do you want a cap?
Hmm OK, ill take a look and see what cam be done
Maybe.., I do commissions for bigger work that includes expanding the code to infinite possibilities and or database setups etc.
So I don't want to get too deep into it
But I'll take a look for free and see if it's quick or not
I think 255 is the cap in game anyways
For effects
Most of them
But I'll do 100 as any above is high anyways
Look, this won't work in the game... it's probably got some issues but gives you an idea of a fully dynamic approach to adding effects and caps etc.. and applying them.
I used chatgpt 4 to help create this (concept)
import { world, system } from "@minecraft/server";
import { ActionFormData } from "@minecraft/server-ui";
// Configuration for effects with their respective caps
const effectConfig = {
strength: { cap: 100, map: new Map() },
health: { cap: 20, map: new Map() },
// Add more effects here as needed
};
system.runInterval(() => {
for (const player of world.getAllPlayers()) {
Object.entries(effectConfig).forEach(([effectName, {cap, map}]) => {
let level = map.get(player.name) || 0;
if (level <= cap) {
player.runCommandAsync(`effect @a[tag=${effectName}] ${effectName} 1 ${level}`);
}
});
}
});
// Function to create and show the form with dynamic buttons
function showForm(player) {
const form = new ActionFormData().title('Increase Effects');
// Add buttons for each effect
Object.keys(effectConfig).forEach(effectName => {
form.button(`Increase ${effectName.charAt(0).toUpperCase() + effectName.slice(1)} Level`);
});
form.show(player).then(response => {
if (response.selection !== undefined) {
const effectName = Object.keys(effectConfig)[response.selection];
const { cap, map } = effectConfig[effectName];
let currentLevel = map.get(player.name) || 0;
if (currentLevel < cap) {
map.set(player.name, currentLevel + 1);
}
}
});
}```
Concept only
I don't have time to fix for the api if anything is wrong, but gives you a good place to start to make it more advanced handling
You can test to see what errors show
It's suppose to create a new button for each effect you add to the config and each time you press it its suppose to Increment +1
You may not visually see it, there is no scoreboards just values
Values inside the script
You may need to add more visuals like adding a body text to show current
It should be a separate button for each, idk I haven't tested lol
Not sure it even opens
You will have to mess around with it
Okay then shouldn't be hard to add itemUse
Event