Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

176
Vistas
Sugarcube game editing using for loops

I'm very new to Sugarcube, I learned that you can edit values by inspecting on the browser. My question is how do you use a loop to change the value of a bunch of things at once? For instance if a game looks like this

ShoppingCart

Milk cost=10

Meat cost=20

Bread cost=30

How do I make a loop to say

for i in ShoppingCart:

i.cost = 10;

end

or something to that effect? I have some coding knowledge of other languages but not this. Until now I've been doing

SugarCube.State.variables.ShoppingCart.Milk=10

SugarCube.State.variables.ShoppingCart.Meat=10

SugarCube.State.variables.ShoppingCart.Bread=10

but its getting tedious, please help

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

For in loops through key

const cart = SugarCube.State.variables.ShoppingCart
for(let i in cart) {
   if(cart[i].cost != undefined ) continue; 
   cart[i].cost = 10 
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda