HELP coffee machine

Discussion about Mods for Prison Architect

Moderator: NBJeff

DarknessEyes
level2
level2
Posts: 105
Joined: Sat Apr 26, 2014 11:47 pm

Re: HELP coffee machine

Postby DarknessEyes » Mon Oct 19, 2015 10:03 pm

Brento666 wrote:(so a) Machine with 3 slots
Slot0 = Coffee Beans loadded
Slot1 = Coffee mug
Slot2 = empty/prisoner


Only gonna need 2 slots...
The provider in needs.txt cant be the coffee machine, imagine that the slot0 is empty... The prisoner gets stuck in the machine. Since i cant find a way to kick the prisoners im doing the following

1) Slot0 is loaded with a stack of 10 coffee beans
2) One unit of beans is deleted
3) The machine spawns one coffee mug

The needs.txt
Object CoffeeMug

Unless someone call tell me a way to prevent prisoners from using the machine when its out of beans...

In chads mod he uses

Code: Select all

if this.waterLeft > 0 then
  this.Slot0.i = -1
  this.Slot0.u = -1
else
  this.Slot0 = this.Id
end


This seems to make the slot used by inmates occupied but it doesnt seem to be working...

Edited:

The following code removes the stack of coffee beans from slot0 and makes it available to use but this cant be used for prisoners, for some reason they get deleted.. lol

Code: Select all

  stack = GetObject("Stack",this.Slot0.i);
  this.Slot0.i = -1;
  this.Slot0.u = -1;
  stack.Loaded = false;
User avatar
Brento666
level3
level3
Posts: 290
Joined: Wed Sep 02, 2015 9:23 pm

Re: HELP coffee machine

Postby Brento666 » Tue Oct 20, 2015 12:39 am

Code: Select all

if this.waterLeft > 0 then
  this.Slot0.i = -1
  this.Slot0.u = -1
else
  this.Slot0 = this.Id
end

I have seen the locking behavior fail in unsuspected ways when you set slots to something.Id, I always use .Id.i and .Id.u.

Anyway, I generally don't know why else prisoners wouldn't leave your sleep satisfying machine, after getting a 0 sleep need set... unless it is something like slowly providing some other need like comfort(?)

You can go the coffee pre spawn way, if I understand your new idea, but can you still charge them money in that setup?
DarknessEyes
level2
level2
Posts: 105
Joined: Sat Apr 26, 2014 11:47 pm

Re: HELP coffee machine

Postby DarknessEyes » Tue Oct 20, 2015 1:32 am

Brento666 wrote:

Code: Select all

if this.waterLeft > 0 then
  this.Slot0.i = -1
  this.Slot0.u = -1
else
  this.Slot0 = this.Id
end

I have seen the locking behavior fail in unsuspected ways when you set slots to something.Id, I always use .Id.i and .Id.u.

Anyway, I generally don't know why else prisoners wouldn't leave your sleep satisfying machine, after getting a 0 sleep need set... unless it is something like slowly providing some other need like comfort(?)

You can go the coffee pre spawn way, if I understand your new idea, but can you still charge them money in that setup?


It provides 0.00 sleep in needs.txt, the need is changed inside script user.Needs.Sleep = 0; But i want to block them from using the machine if the machine is out of coffee beans
User avatar
Brento666
level3
level3
Posts: 290
Joined: Wed Sep 02, 2015 9:23 pm

Re: HELP coffee machine

Postby Brento666 » Tue Oct 20, 2015 2:59 am

Maybe you could do this with a custom blocker object, then temporarily stick that in the prisoners slot?

I totally get what you're saying, prisoners keep coming when the machines Id is set to self... (that 'should' block it from use, but have never gotten that to work here either)

Or maybe, hopefully someone else reading here knows how to do it and will reply to inform us... :roll:
User avatar
aubergine18
level2
level2
Posts: 231
Joined: Sun Jul 05, 2015 3:24 pm

Re: HELP coffee machine

Postby aubergine18 » Tue Oct 20, 2015 4:57 am

If you're still having probs not being able to stop prisoners using machine when it's out of stock, another trick you could try...

1. Define dummy version of machine in materials.txt that uses same sprite, but obviously different Name value

2. When proper machine runs out of stock:

Code: Select all

function outOfStock()
  local dummy = Object.Spawn( 'DummyMachine', this.Pos.x, this.Pos.y )
  -- set orientation
  dummy.Or.x, dummy.Or.y = this.Or.x, this.Or.y
  -- nuke real machine
  this.Delete()
end


3. The dummy machine is the one that does AutoOrder and gets replenished.

4. When dummy machine is replenished, it spawns a real machine in same position (similar to above) and then deletes itself (the dummy machine).

5. The real machine defaults to being fully stocked. Prisoners use it to get their brews.

6. Change materials.txt so the real machine is not available from the menu; instead user places dummy machine (without really knowing that) causing the initial stock to be delivered. Then dummy machine swaps itself for real machine that prisoners use. Real machine runs out of stock... swaps itself with dummy machine (which prisoners can't use)... rinse, wash, repeat.
User avatar
aubergine18
level2
level2
Posts: 231
Joined: Sun Jul 05, 2015 3:24 pm

Re: HELP coffee machine

Postby aubergine18 » Tue Oct 20, 2015 4:58 am

BTW... try Brento's blocker object idea first. Could have an "Out of Stock" sign that goes in the slot hehe. If that works would be much simpler than my approach.
DarknessEyes
level2
level2
Posts: 105
Joined: Sat Apr 26, 2014 11:47 pm

Re: HELP coffee machine

Postby DarknessEyes » Tue Oct 20, 2015 5:41 pm

In real life u go to machines before u find out their out of stock so i dont mind prisoners going to machine when its out of stock. The problem is that they get stuck in the machine.

Gonna try bento approach, if it doesnt work im gonna make it:

Stacks of beans get loaded into slot0
Stack of beans gets deleted and this.stock = this.stock + stack.Quantity
If the stock is >= 1 and slot1 is empty then one coffee mug spawns at slot1.

Needs.txt redirects prisoners to coffee mug instead of machine

Edited:

Omg, i got it...

this.Slot0 = this.Id.; doesnt work...

But

this.Slot1.i = this.Id.i;
this.Slot1.u = this.Id.u;

Does what i want!!! The inmates still go to machine but they leave it right after.

How do i attach an object to a slot?

Code: Select all

delivery = Object.Spawn("Coffee",this.Pos.x,this.Pos.y);
this.Slot1.i = delivery.Id.i;
this.Slot1.u = delivery.Id.u;


This moves the coffee to position 0 0 (top left of map)
DarknessEyes
level2
level2
Posts: 105
Joined: Sat Apr 26, 2014 11:47 pm

Re: HELP coffee machine

Postby DarknessEyes » Tue Oct 20, 2015 11:07 pm

Finished... Since i dont have any sprites i changed the coffee into a Snacks vending machine (default drink machine)
And added an Arcade machine (the game have an unused sprite)

Snack machine:
Requires restocking of snacks
Max of 10 snacks can be loaded at a time (If the stock reaches 4 or less you can load another stack of 10 snacks making the real max 14 snacks)
Every 600 secs the accountant do the job "collect money" to unload the cash from machines.
Then the workers move the bags of money to exports.

Known issue: If the machine runs out of stock the same prisoner can keep checking the machine, however he doesn't get stuck.

Arcade machine:
Doesnt require restocking.
Every 600 secs the accountant do the job "collect money" to unload the cash from machines.
Then the workers move the bags of money to exports.

Suggestion?
There is a mug, so im gonna end making the coffee machine, anyone have sprites? :)
User avatar
Brento666
level3
level3
Posts: 290
Joined: Wed Sep 02, 2015 9:23 pm

Re: HELP coffee machine

Postby Brento666 » Wed Oct 21, 2015 12:24 am

Sweet, so the accountant is finally going places!!

Perhaps I'll have time to throw some images together in a couple of days... (It usually takes me a couple of passes to get things looking fitting, and I have other mods to work on right now...)

If we do fix a new machine, let's then create a fresh mod based on your setup now, but maybe tweaked a little for more ingredients/slots.

Maybe more dynamic timing for the money collecting... Maybe, in a later iteration, some Styrofoam cups that leave trash around, needing to be swept up...


Send me a steam invite if you want to start creating some new but style appropriate machines a little laters! Be it Coffee (or Tea) !
(my nick is the same on steam) :mrgreen:
DarknessEyes
level2
level2
Posts: 105
Joined: Sat Apr 26, 2014 11:47 pm

Re: HELP coffee machine

Postby DarknessEyes » Wed Oct 21, 2015 12:26 am

Brento666 wrote:Sweet, so the accountant is finally going places!!

Perhaps I'll have time to throw some images together in a couple of days... (It usually takes me a couple of passes to get things looking fitting, and I have other mods to work on right now...)

If we do fix a new machine, let's then create a fresh mod based on your setup now, but maybe tweaked a little for more ingredients/slots.

Maybe more dynamic timing for the money collecting... Maybe, in a later iteration, some Styrofoam cups that leave trash around, needing to be swept up...


Send me a steam invite if you want to start creating some new but style appropriate machines a little laters! Be it Coffee (or Tea) !
(my nick is the same on steam) :mrgreen:


Made some changes. going to test it a little and then im gonna leave an url here with the mod

Machines no longer poo bags of money after each use, accountant needs to unload the money.
The accountant unloads the money when it reaches $50 or every 900secs.
Tooltips show stock (snack machine only), cash and time remain until next cash colletion (the 900s delay).Gonna add latter a total amount of units sold/games played
User avatar
aubergine18
level2
level2
Posts: 231
Joined: Sun Jul 05, 2015 3:24 pm

Re: HELP coffee machine

Postby aubergine18 » Wed Oct 21, 2015 2:53 am

If you can upload source to github as well, will make it easier to do performance tweaks, bug fixes, etc.
DarknessEyes
level2
level2
Posts: 105
Joined: Sat Apr 26, 2014 11:47 pm

Re: HELP coffee machine

Postby DarknessEyes » Thu Oct 22, 2015 5:41 pm

Each time i solve a bug another one shows up...

I'm getting stuff (inmate, coffee mug and/or the machine) teleported to pos 0 0...

I tried to make an item like the serving table.

2 Slots, one for restock and one to spawn the "food", the inmate needs.txt send them to "eat" slot1,
However I'm not able to spawn the coffee mug and attach it to slot1...

I looked at save files and the properties of any item in a slot are the following:

Code: Select all

spawn = Object.Spawn("CoffeeMug",this.Pos.x,this.Pos.y);
this.Slot1.i = spawn.Id.i;
this.Slot1.u = spawn.Id.u;
spawn.CarrierId.i = this.Id.i;
spawn.CarrierId.u = this.Id.u;
spawn.Loaded = true;
spawn.Pos.x = this.Pos.x;
spawn.Pos.y = this.Pos.y;


The coffee mug gets attached to slot1 but gets teleported to position 0 , 0 and for some reason i cant change it from the script machine...

Now im gonna try to script the mug...
Oncreate: save the current spawn position.
Then detect when the inmate eats it...

Another solution is to use someone idea from a previous post:
When the machine is full of coffee beans spawn one object with "Hidden" attached to slot0 just to block it.
When the machine run out coffee beans spawn one object with "Hidden" attached to slot1 just to block it.
Doesnt matter much if the item goes to 0 ,0 position in this case.
User avatar
Brento666
level3
level3
Posts: 290
Joined: Wed Sep 02, 2015 9:23 pm

Re: HELP coffee machine

Postby Brento666 » Thu Oct 22, 2015 7:08 pm

Hey why block both slots?

once he pays, give him the boost in needs via script then:
set his carrying to the new coffeemug
set the Coffeemug carried to the prisoner

have code in the mug to delete shortly after being dropped, no needs on the mug.

Something like that should work.

Again with the need provider specified to slot 1, why block slot 0 at all?
User avatar
aubergine18
level2
level2
Posts: 231
Joined: Sun Jul 05, 2015 3:24 pm

Re: HELP coffee machine

Postby aubergine18 » Thu Oct 22, 2015 7:37 pm

I assume you've got the correct Marker setup in the Sprite setting? Each slot needs it's own Marker, with the Index (in the Marker) being the Slot number.

If your machine has multiple sprites that you're switching between using SubType, then each applicable sprite will need to define the markers. Chad's sprite editor makes it easier to get the settings for markers: http://chadsmods.rdkf.net/tools/spriteeditor/

Note: If you're using a sprite from the base game, the markers will need defining in objects.spritebank
DarknessEyes
level2
level2
Posts: 105
Joined: Sat Apr 26, 2014 11:47 pm

Re: HELP coffee machine

Postby DarknessEyes » Thu Oct 22, 2015 9:15 pm

Code: Select all

this.Hidden = true;

:( Why object doesnt hide :/

aubergine18 wrote:I assume you've got the correct Marker setup in the Sprite setting? Each slot needs it's own Marker, with the Index (in the Marker) being the Slot number.

If your machine has multiple sprites that you're switching between using SubType, then each applicable sprite will need to define the markers. Chad's sprite editor makes it easier to get the settings for markers: http://chadsmods.rdkf.net/tools/spriteeditor/

Note: If you're using a sprite from the base game, the markers will need defining in objects.spritebank


Using default ones atm.
Do you know whats the warning message icon sprite? The one that shows up over cctvs/servos when their not wired?

Brento666 wrote:Hey why block both slots?

once he pays, give him the boost in needs via script then:
set his carrying to the new coffeemug
set the Coffeemug carried to the prisoner

have code in the mug to delete shortly after being dropped, no needs on the mug.

Something like that should work.

Again with the need provider specified to slot 1, why block slot 0 at all?


The current setup im trying is
Slot0 is where the coffee beans are loaded.
Slot1 to be used by inmates.
needs.txt redirects prisoners to slot1

The stack if beans is deleted and the variable this.stock increases. Once the max stock is reached i must block the slot or the workers will move another box into the empty slot. (I only dont want another box in there because it looks bad)
I need to block slot1 when the machine runs out of beans. If it runs out of beans the prisoners keep going to the machine and might get stuck,...

The other solution i might try:
Slot0 is where the coffee beans are loaded.
Slot1 is where the coffee mug is spawned
needs.txt redirects prisoners to mug

Same thing for stock.
Spawn one mug at slot1 and decrease this.stock by one

Edited:

Object.Spawn(name,x,y) seems to be bugged... the object is spawned at 0 ,0... Any1 know why?!?

Return to “Modding”

Who is online

Users browsing this forum: No registered users and 6 guests