ID:168777
 
(Forge being an obj)
        Forge
icon_state="forge"
density=1
verb
Forge()
set category="Temp"
set src in oview(1)
var/b=locate(/obj/Items/IronOre)in usr.contents
if(b)
if(!usr.forging)
usr.nomotion=1
usr.forging=1
usr<<"You begin to forge an Iron Ore..."
sleep(50)
if(prob(50))
if(usr.amount<10)
del(b)
usr.amount++
new /obj/Items/IronIngot(usr)
usr << "You created an Iron Ingot!"
else
del(b)
new /obj/Items/IronIngot(usr.loc)
usr << "You created an Iron Ingot, but you can't carry it!"
sleep(10)
usr.nomotion=0
usr.forging=0
else
usr << "You failed to make an Iron Ingot."
del(b)
usr.amount--
sleep(10)
usr.nomotion=0
usr.forging=0

What I'm trying to accomplish here is I wish it to, when the user uses the verb, pop up an input for a number. I'd like this number not to be over the amount var for the user(Amount being a variable used to limit inventory space)(As in, the user's current space left([usr.amount] out of 30) must not be exceeded by the input number), it also must equal or be less than the amount of /obj/IronOre in the user's inventory(and of course, must not equal 0). After said input, it should switch to a screen to select an ore type(Only types in the usr's inventory(typesof(/obj/ore)in usr.contents?), which path would be /obj/ore, and then move the inputted number's amount of the selected ore into something(list?), and proceed to loop through a forging code for each ore in the list.

Lamens terms: All I need is to know how to have a num input be applied to an object, i.e. you enter the number 5 and 5 of an object are removed from your inventory and sent to a list.

Either a push in the right direction or an explained fix would be most helpful.
Set a var to the input
var/input = input(blah,blah,blah)


To do the rest, use a while loop. Like
while(var/i=1)
if(usr.var>10)
i--
else
usr << "Var is too big!"
usr.var = input(blah, blah, blah)
In response to Nukes4U
Nukes4U wrote:
Set a var to the input
> var/input = input(blah,blah,blah)
>

To do the rest, use a while loop. Like
> while(var/i=1)
> if(usr.var>10)
> i--
> else
> usr << "Var is too big!"
> usr.var = input(blah, blah, blah)

Either you're misunderstanding me(I'm not trying to have an inventory limit; I already have that.), or I'm not getting what you're saying.
As in:
var/items=list(typesof(var/obj/ore/O)in usr.contents)
for(O in items)
//Forging code

But that would forge every item in the user's inventory, and I want a set amount.
What I'm trying to accomplish here is I wish it to, when the user uses the verb, pop up an input for a number. I'd like this number not to be over the amount var for the user(Amount being a variable used to limit inventory space)(As in, the user's current space left([usr.amount] out of 30) must not be exceeded by the input number), it also must equal or be less than the amount of /obj/IronOre in the user's inventory(and of course, must not equal 0). After said input, it should switch to a screen to select an ore type(Only types in the usr's inventory(typesof(/obj/ore)in usr.contents?), which path would be /obj/ore, and then move the inputted number's amount of the selected ore into something(list?), and proceed to loop through a forging code for each ore in the list.


mob/proc/MyProc()
var/Ino = 0
for( var/obj/IronOre/IO in src.contents )
Ino += 1
continue
if( !Ino )
src << "I guess you don't want to forge..";
return
var/bIsValid // I think this might be a waste, but you never know.
while( !bIsValid )
var/A = input( "Please input a number ( Change this )", "Number" ) as num
if( !A )
src << "You must input a number greater than 0!"
continue;
if( A >= src.amount )
src << "The number is too high!"
continue;
bIsValid = 1
var/oType = input( "Which type of ore would you like?" , "Type?" ) as typesof( /obj/ore ) in src.contents
var/list/Ores = new( Ino )
for( var/obj/ore in src.contents )
if( !Ino )
break;
else
Ores.Add( ore )
src.contents.Remove( ore )
Ino -= 1
continue
for( var/obj/ore/A in Ores )
//Forging code


Not tested, but it should work.



In response to Audeuro
Sunde.dm:44:error: Bad input type: /obj/Ore
Sunde.dm:44:error: input type (/obj/Ore) must be atomic (area, turf, obj, or mob).
Sunde.dm:44:error: Bad input type: typesof

Got that on the Otype variable.
In response to Sinoflife

As in:
> var/items=list(typesof(var/obj/ore/O)in usr.contents)
> for(O in items)
> //Forging code
>

But that would forge every item in the user's inventory, and I want a set amount.

Alright, so instead of a for(), use a while().
In response to Nukes4U
Okay, lets try this. I put what I need help on below the code I wrote.
        Forge
icon_state="forge"
density=1
verb
Forge()
set category="Temp"
set src in oview(1)
var
O=locate(typesof(/obj/Ore)in usr.contents)
N
E
I=input("What kind of ore?","Forge")in list(O,"Cancel")
if(I!="Cancel")
N=input("How many of this ore?","Forge") as null|num
if(!N)
return
if(N>usr.amount-N)
usr << "You don't have enough room for all of these!"
return
else
//Some kind of check to see if N isn't greater than the amount of the selected ore the usr has
/*I.amount+=N;E=list(I.amount of I)(Just as an example or something)
for(I in E)
*Forging Code*/

In response to Nukes4U
Nukes4U wrote:
To do the rest, use a while loop. Like
> while(var/i=1)
> if(usr.var>10)
> i--
> else
> usr << "Var is too big!"
> usr.var = input(blah, blah, blah)


That while() loop makes absolutely no sense whatsoever. The condition is all wrong, and the code inside makes little more sense. You don't seem to really know what you're doing here. It'd probably be best before offering help to others in the future if you have a grasp of the fundamentals.

Lummox JR
In response to Sinoflife
        Forge
icon_state="forge"
density=1
verb
Forge()
set category="Temp"
set src in oview(1)
var/OT
for(var/obj/Ore/O in usr.contents)
OT+=1
var/I=input("What kind of ore?","Forge")in list(O,"Cancel")
if(I!="Cancel")
var/N=input("How many of this ore?","Forge") as null|num
if(N<=0)
return
else
if(N>usr.amount-N)
usr << "You don't have enough room for all of these!"
return
else
if(N>OT)
usr<<"You don't have this much ore!"
return
else
var/N1 = 0
for(var/obj/Ore/O1 in usr.contents)
if(N1 >= N)
..()
else
N1 += 1
usr.contents.Remove(O1)
//Forging Code
In response to FinalFantasyFreak
                                    var/N1 = 0
for(var/obj/Ore/O1 in usr.contents)
if(N1 >= N)
..()
else
N1 += 1
if(!usr.forging)
usr.nomotion=1
usr.forging=1
usr<<"You begin to forge an [O]..."
sleep(50)
if(prob(50))
if(usr.amount<10)
del(O1)
new I(usr)
usr << "You forged an [O]!"
else
del(O1)
usr.amount--
new I(usr.loc)
usr << "You created an [O], but you can't carry it!"
sleep(10)
usr.nomotion=0
usr.forging=0
else
usr << "You failed to make an [O]."
del(O1)
usr.amount--
sleep(10)
usr.nomotion=0
usr.forging=0


Lots of bugs with the whole thing(combined with FFF's code)

When it asks what type of ore to forge, it only shows the first one found.
When you input a number over 1 and it starts to forge, if it works then I get a runtime error saying that I is null.type.
If it fails, the second forge and on, the type becomes null somehow as in it will say "You begin to forge .".
In response to Lummox JR
Lummox JR wrote:
Nukes4U wrote:
To do the rest, use a while loop. Like
> > while(var/i=1)
> > if(usr.var>10)
> > i--
> > else
> > usr << "Var is too big!"
> > usr.var = input(blah, blah, blah)
>
> That while() loop makes absolutely no sense whatsoever. The condition is all wrong, and the code inside makes little more sense. You don't seem to really know what you're doing here. It'd probably be best before offering help to others in the future if you have a grasp of the fundamentals.
>
> Lummox JR

Lol thanks for not closing the
</pre> tag, you effectively killed the word wrap. XD

Hiead

In response to Lummox JR
Lummox JR wrote:
Nukes4U wrote:
To do the rest, use a while loop. Like
> > while(var/i=1)
> > if(usr.var>10)
> > i--
> > else
> > usr << "Var is too big!"
> > usr.var = input(blah, blah, blah)
>

That while() loop makes absolutely no sense whatsoever. The condition is all wrong, and the code inside makes little more sense. You don't seem to really know what you're doing here. It'd probably be best before offering help to others in the future if you have a grasp of the fundamentals.

Lummox JR

Thats some pretty bad code, ill admit. I was using var at the end there as just a general statment, like
usr.somevar = input(whatever)

The idea is to keep checking until somevar is the right size.
Hopefully that makes more sense
In response to Nukes4U
Nukes4U wrote:
Thats some pretty bad code, ill admit. I was using var at the end there as just a general statment, like
usr.somevar = input(whatever)

The idea is to keep checking until somevar is the right size.

Except that's not what you put as the condition in your while() loop.

Lummox JR