How would I handle stacks?

tinoesroho
Member
 
Posts: 570
Joined: Fri Feb 17, 2012 21:55

How would I handle stacks?

by tinoesroho » Sat May 05, 2012 05:49

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
hit_with = puncher:get_wielded_item()
hit_with_name = hit_with:get_name()
hit_with_count = hit_with:get_count()
if hit_with_name == "moreores:copper_ingot" then
hit_with_count = hit_with:get_count()
total_amount = hit_with_count
    puncher:get_inventory():remove_item("main", hit_with)
puncher:get_inventory():add_item("main", "money:coin_gold hit_with:get_count()")


I'm trying to get my Automated Trader to count stacks of items. Sadly, this doesn't produce pay equal to the stack I feed into it. How can I get this to work?
We are what we create.

I tinker and occasionally make (lousy) mods. Currently building an MMO subgame and updating mods. Pirate Party of Canada member. Sporadic author. 21 years old.

My github:
https://github.com/tinoesroho/
 

Switch5681
Member
 
Posts: 36
Joined: Sat Sep 24, 2011 03:28

by Switch5681 » Wed May 09, 2012 11:15

I don't know the specifics of this language, but it looks like you're removing hit_with and then trying to use it to create your money. Is it possible that hit_with is being disposed when you remove it, so you're trying to use the count of a non-existant item?
 


Return to Minetest General

Who is online

Users browsing this forum: No registered users and 73 guests

cron