Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

172
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

about 4 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 
}
about 4 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 Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!