Jump to content




Slots help


6 replies to this topic

#1 Zaccaboom97

  • Members
  • 3 posts

Posted 22 October 2013 - 07:07 AM

Title: Slots help

Hey, I have "borrowed" this code here:
http://www.computerc...7-slot-machine/

Here is what I am requesting.

I have a system in place where a possible user of my casino will come in and buy money for a floppy disk with in game items, so if they give a iron nugget (tekkit) then they get +1 on their card.
Then when they wish to play a game such as slots, they put their card in and press the button, causing the game to run.

Now, what I would like is help on how to make the computer firstly detect that a card is in the disk drive, then make it check if it is a positive number, and upon turning the redstone on, deducting the number on the card by one. If there is not a positive number in the card the game does not run.

Anybody willing to help?

Zacc

#2 Zacklogan

  • Members
  • 6 posts
  • Locationterm.getPlayerLocation("Zacklogan")

Posted 22 October 2013 - 09:46 AM

Ok, so to tell if the disk is inserted. Heres a link to the wiki page you will need. http://www.computerc...ki/Os.pullEvent
But you'll need to pull the event disk.
Since I'm at school I can't post a code. If your not helped when I get home I'll edit the post.

Kind regards,
zacklogan

#3 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 22 October 2013 - 01:37 PM

Are you asking if someone is willing to create the code for you? If that's the case I can say that lots of people don't want to create a code for you..
I don't mean to sound harsh but this is a section where people help you out if you stumble upon a problem or something you want help with, This is not a section you can ask for someone to make the code for you, I'd suggest you would have put this in general if you are asking that( You can ask a moderator to move it )

So this is some things you need help with?

Quote

Events
Redstone
Fs API

Events

Redstone

Fs API

So how I would do that when doing +1 with the 'cash' is something like this
Example

And if you want to check if the user has enough 'cash' you can do something like this
Example


#4 Zaccaboom97

  • Members
  • 3 posts

Posted 22 October 2013 - 05:59 PM

View PostHellkid98, on 22 October 2013 - 01:37 PM, said:

*snip*
I keep recieving "Cash:13: attempt to compare string with number expected, got string"

Halp?

#5 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 23 October 2013 - 12:43 AM

Try changing the tonumber part to this
if not tonumber(cash) then
    error("Your error message here", 0)
else
    cash = tonumber(cash)
end


#6 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 23 October 2013 - 12:46 AM

View PostHellkid98, on 23 October 2013 - 12:43 AM, said:

Try changing the tonumber part to this
if not tonumber(cash) then
	error("Your error message here", 0)
else
	cash = tonumber(cash)
end
Or as a "prettier" solution that also doesn't require calling tonumber twice
cash = tonumber(cash)
if not cash then
  error("Your error message here", 0)
end


#7 Zaccaboom97

  • Members
  • 3 posts

Posted 23 October 2013 - 09:59 AM

Tanks all! This worked beautifully and I'm now working on the integration of this into my system.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users