• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

108
Views
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

almost 3 years ago · Juan Pablo Isaza
1 answers
Answer question

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 
}
almost 3 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error