generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: C#

Previous Thread :: Next Thread 
xSoulStealerx is not online. xSoulStealerx
Joined: 07 May 2008
Total Posts: 1624
19 Oct 2011 02:00 PM
I am posting this here, because the thread on Scripters forum got deleted.

Okay, I know there aren't alot of C Sharp scripters in here, but if there is, this is for you.
How do you use threading? Like, wait() in Roblox. I've tried a lot of different things but for nothing. Some help here?
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
19 Oct 2011 02:04 PM
I think using a wait() (Like in Roblox) is the same as it is in Java, Thread.Sleep(milliseconds)

­<'+1 Post. Ujelly?'>
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
19 Oct 2011 02:05 PM
I think using a wait() (Like in Roblox) in C# is the same as it is in Java, Thread.Sleep(milliseconds)*


­<'+1 Post. Ujelly?'>
Report Abuse
xSoulStealerx is not online. xSoulStealerx
Joined: 07 May 2008
Total Posts: 1624
19 Oct 2011 02:06 PM
I know, it is Thread.Sleep, but somehow it does not work :o
Report Abuse
bikerking200 is not online. bikerking200
Joined: 11 Mar 2010
Total Posts: 5047
19 Oct 2011 02:06 PM
Thread.Sleep(); works? Wow I really need to try that.
Report Abuse
myrco919 is not online. myrco919
Joined: 12 Jun 2009
Total Posts: 13241
19 Oct 2011 02:06 PM
[ Content Deleted ]
Report Abuse
bikerking200 is not online. bikerking200
Joined: 11 Mar 2010
Total Posts: 5047
19 Oct 2011 02:08 PM
Ugh I don`t like making Timers.
Report Abuse
xSoulStealerx is not online. xSoulStealerx
Joined: 07 May 2008
Total Posts: 1624
19 Oct 2011 02:08 PM
Timer isn't what I want, timer just repeats a method over and over again.
Report Abuse
xSoulStealerx is not online. xSoulStealerx
Joined: 07 May 2008
Total Posts: 1624
19 Oct 2011 02:11 PM
Oh god, nevermind, Thread.Sleep() works perfectly fine for me. I think I used it wrong, so ya, thread closed. If you wanna post anyways, do it.
Report Abuse
bikerking200 is not online. bikerking200
Joined: 11 Mar 2010
Total Posts: 5047
19 Oct 2011 02:13 PM
Soul, What program for C# are you using?
Report Abuse
xSoulStealerx is not online. xSoulStealerx
Joined: 07 May 2008
Total Posts: 1624
19 Oct 2011 02:16 PM
Microsoft Visual C# 2010 Express
Report Abuse
bikerking200 is not online. bikerking200
Joined: 11 Mar 2010
Total Posts: 5047
19 Oct 2011 02:17 PM
Oh. Because when I use that one the Error list says that theres no such thing of 'Thread'..
Report Abuse
xSoulStealerx is not online. xSoulStealerx
Joined: 07 May 2008
Total Posts: 1624
19 Oct 2011 02:18 PM
You have to use this:

using System.Threading;



You should search the system a bit, or look for tutorials.
Report Abuse
bikerking200 is not online. bikerking200
Joined: 11 Mar 2010
Total Posts: 5047
19 Oct 2011 02:18 PM
Oh..
Report Abuse
bikerking200 is not online. bikerking200
Joined: 11 Mar 2010
Total Posts: 5047
19 Oct 2011 02:30 PM
o.o Wow some noob F5`ed this thread.
Report Abuse
xSoulStealerx is not online. xSoulStealerx
Joined: 07 May 2008
Total Posts: 1624
19 Oct 2011 02:33 PM
Ok since this is a sticky, lol, could someone debug this for me? :o

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

public static void Main(String[] args)
{
while (true)
{
check();
Thread.Sleep(1000);
}
}

static bool On = false;
static bool ImageOpen = false;

private void button1_Click(object sender, EventArgs e)
{
if (On) On = false; else On = true;
}

private void check()
{
if (On)
{
if (ImageOpen)
{
pictureBox1.Image = null; ImageOpen = false;
}
else
{
pictureBox1.Image = WindowsFormsApplication1.Properties.Resources.lolface; ImageOpen = true;
}
}
else
{
pictureBox1.Image = null;
}
}
}
}



Output:

Error 1 An object reference is required for the non-static field, method, or property 'WindowsFormsApplication1.Form1.check()' C:\Documents and Settings\JP\Local Settings\Application Data\Temporary Projects\WindowsFormsApplication1\Form1.cs 24 17 WindowsFormsApplication1
Report Abuse
bikerking200 is not online. bikerking200
Joined: 11 Mar 2010
Total Posts: 5047
19 Oct 2011 02:34 PM
What is it supose to do?
Report Abuse
xSoulStealerx is not online. xSoulStealerx
Joined: 07 May 2008
Total Posts: 1624
19 Oct 2011 02:35 PM
When you click a button, its supposed to flash an image to nothing and to a face every 1 second.
Report Abuse
bikerking200 is not online. bikerking200
Joined: 11 Mar 2010
Total Posts: 5047
19 Oct 2011 02:36 PM
Lol.
Report Abuse
crazypotato4 is not online. crazypotato4
Joined: 22 Feb 2010
Total Posts: 20000
19 Oct 2011 02:37 PM
private static void check()

?

:D
Report Abuse
xSoulStealerx is not online. xSoulStealerx
Joined: 07 May 2008
Total Posts: 1624
19 Oct 2011 02:39 PM
Nope, sorry, it removes that error but gives 3 more errors.

Error 3 An object reference is required for the non-static field, method, or property 'WindowsFormsApplication1.Form1.pictureBox1' C:\Documents and Settings\JP\Local Settings\Application Data\Temporary Projects\WindowsFormsApplication1\Form1.cs 52 17 WindowsFormsApplication1
Report Abuse
xSoulStealerx is not online. xSoulStealerx
Joined: 07 May 2008
Total Posts: 1624
19 Oct 2011 02:40 PM
The thing is, after that it can't access to pictureBox1.
Report Abuse
bikerking200 is not online. bikerking200
Joined: 11 Mar 2010
Total Posts: 5047
19 Oct 2011 02:42 PM
Wow thats weird..
Report Abuse
crazypotato4 is not online. crazypotato4
Joined: 22 Feb 2010
Total Posts: 20000
19 Oct 2011 02:43 PM
*searches google for the error*

you apparently cant access non-static fields from static methods

you either need to have it be static, or create an instance of Form1

whatever that means
Report Abuse
xSoulStealerx is not online. xSoulStealerx
Joined: 07 May 2008
Total Posts: 1624
19 Oct 2011 02:46 PM
Thanks dude! It was really worth googling :D
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image