Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Im trying to make a plugin that can create a lot of house for you and I'm not sure how I could make this... I just want to know if you can spawn some block with a command and how can we spawn them.
Thanks for helping me.
If you want to get a block at a location, you could use
location.getBlock()
Then, to get set the type of the block, you could use:
location.getBlock().setType(material)
So, if you wanted to set the block at 0, 0, 0 in world to cobblestone, you could use:
Location location = new Location(world, 0, 0, 0);
location.getBlock().setType(Material.COBBLESTONE);
If you want to paste large saved structures, you should look into schematics
The short answer: What you are trying to do is very complicated and would take a pretty big effort. In order to spawn a house you need to make some sort of system for reading/writing/building schematics. In theory, a player could type a command to spawn a house and pass a schematic name. Your mod could then load up that schematic and start placing it block by block. Your schematic files could be very simple, using letter to represent blocks.
For example:
C C C
C A C
C C C
The above schematic could load a 3x3 cobblestone layer with air in the center. use the calling players location as the center and build from there.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm using Statistica 64 VB. I wrote a function "Public MyFunction()" in FileLibrary.svb (a collection of useful functions) that I want to be called by a function in FileDoStuff.svb (an analysis).
I tried to include FileLibrary.svb like this in FileDoStuff.svb:
'#Language "WWB-COM"
'#Uses "U:\TestSVB\FileLibrary.svb"
This is the result when I run Main() in FileDoStuff, and the result is the same even if I have FileLibrary open in the application.
"Script error in FileDoStuff.svb
Macro/module does not exist."
Statistica is on the E: drive. However, FileLibrary opens a spreadsheet on U: and has no problem with it. I am able to open FileLibrary from Statistica and test it.
Why would it work to open an external spreadsheet but not call an external macro? The FileLibrary is not saved within Statistica, but neither is the analysis in FileDoStuff. What am I doing wrong?
Also, what's the difference between an SVB and an SVX file?
You know what really helps, as I discovered after hours of trying everything?
Try spelling the entire path name and the entire file name correctly, including spaces, etc. And make sure the slashes go the right way, too. (In my real path/file there are spaces.)
As much as I'd like to delete this whole question, I'm leaving it here to remind us all that sometimes the answer is just that simple. Also, I want to draw more people out who are using Statistica VB because I know there will be more questions.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Suppose my command line utility can send messages with following structure
struct Message {
uint32_t ip;
string id;
}
User must be able to specify host(ipv4+port) and filters on ip and id per host
(allowed network addresses and ids to send). How can I design
clear syntax for such complex option?
The best what I invented is:
--msg-send="192.168.10.2:8080;ip_isin=10.0.0.0/8,172.16.0.1/16;id=one,two"
But something is wrong with it... for example sign = inside is
annoying... Does anybody knows "the silver bullet" for command line arguments with complex structure?
another variant is better:
--msg-send="192.168.10.2:8080{ip 10.0.0.0/8,172.168.0.0/16}{id one,two}"
UPD: msg-send is plural, user can set several hosts with different filters
There's no silver bullet, however, when interacting with humans you should try to follow human way of thinking. You're trying to make the user to compose a complex structure, somewhat resembling JSON format, by hand. Humans are bad at this. From your explanation I get that this structure has three components:
host+port
list of IPs (identified by subnets, CIDR notations,
rangers, whatever your program can handle)
list of string ids
Thus it might be logical to require the user to enter these parameters separately, for example
msg_util.exe --host 192.168.10.2:8080 --allowed_ips 10.0.0.0/8,172.16.0.1/16 --allowed_ids one,two
If you might have many hosts with corresponding allowed IPs and ids, then it'd be quite awkward to enter it from command line alone, and many network utilities (like dig) resort to consume input from files. For example you could have
msg_util.exe --file --host hosts_file --allowed_ips ips_file --allowed_ids ids_file
where each line of hosts_file has corrseponding options in ips_file and ids_file
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Put simply, I have a browser widget I'm using in FLTK Gui toolkit which can be loaded using a file like so.
browser::load("textfile.txt");
The problem is I don't want to create a physical text file, just an invisible one so I can use it as an argument for browser::load above. I plan to use this invisible text file by loading it with the values I'm going to place in my browser....then use it like this.
browser::load("invisible_textfile.txt");
Is it possible to do this in C++?
I have already tried using ifstream::rdbuf() which probably has nothing to do with this. I'm not even sure what to call this so I'm just calling it an invisible textfile for now.
I'm using windows 7 64 bit. MinGW compiler.
Let's say what you want to add is equivalent of text file like this:
One
Two
Three
But you don't want to have the text file. So one piece of code which would do the same thing is this:
const char *lines[] = { "One", "Two", "Three", 0 };
for(int i = 0 ; lines[i] != 0 ; ++i)
browser.add(lines[i]);
Documentation link for that overload of add
Please refine your question, or perhaps ask a new question, if you want more help on how to get lines with your data.
It depends a lot on what browser::load() actually does internally, but let's assume that it will look for your filename and load it.
You probably already know how to read / write a standard file (e.g. http://www.cplusplus.com/doc/tutorial/files/). Now, if you just want to hide the file from the user, you can set OS specific hidden flags (e.g. windows). I'm assuming that's not what you actually want to accomplish here. (You could obviously also create a temporary file that you delete again, but it's not an elegant solution either.)
What you might want to use is a named pipe. Under Linux you can create these with mkfifo and then stream content through those file objects.
The general point is, though, unless the browser API allows you to pass it a complete string holding the text file or a stringstream, you will need a file object.
If your only target system is NTFS, there is a good answer on creating virtual files over here:
How to create a virtual file?
But in the end, you probably want to create an actual file (in your case probably a temporary one, though). I would recommend placing that file into the systems temporary path.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am working on a program that needs to unzip .zip files. After trying several different methods to do this, the only one I could find that worked for all my needs is 7z.exe. It works great as I'm developing since I can just hardcode the location of the executable into the code. However, if anyone else tries to use it, that part won't work. Is there any way to allow them to access this? Thanks!
I suggest you use a compression library (have a look at libarchive: http://www.libarchive.org). If you can't do that, you should ship 7z.exe and its dependencies with your application, putting them in a fixed relative location to your main executable.
Then you get your main executable absolute path using GetModuleFileName, strip and combine with the relative path using PathCchCombine:
char filename[MAX_PATH];
GetModuleFileName(NULL,filename,(sizeof(filename))/(sizeof char));
PathCchRemoveFileSpec(filename,(sizeof(filename))/(sizeof char));
PathCchCombine(filename,(sizeof(filename))/(sizeof char),filename,"./7zip/7zip.exe");
//the absolute path of 7z.exe is now in filename
Documentation for GetModuleFileName:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms683197(v=vs.85).aspx
PathCchRemoveFileSpec:
http://msdn.microsoft.com/en-us/library/hh707092(v=vs.85).aspx
and for PathCchCombine:
http://msdn.microsoft.com/en-us/library/hh707085(v=vs.85).aspx
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 months ago.
Improve this question
I'm we're trying to figure out if there would be a way to convert a .txt file to a .pdf file. Here's the catch. This needs to be done behind the scenes, and on the fly. Meaning, with a radio control selected, OnOK would create a .txt file. Behind the scenes, at run time, we would like for the .txt file to be converted to a .pdf file. Ideally we would like this to be done by running an executable in the background. The executable would take input "File.txt" and output "File.pdf". We're using C++ and Visual Studio 6.
Does anyone have any experience on this? Is this possible?
libHaru may do what you want. Demo.
This a2pdf tool will probably do the trick with minimal effort. Just be sure to turn off perl syntax highlighting.
http://perl.jonallen.info/projects/a2pdf
I recommend using this open source library.
Once you have the base for generating PDF documents programmatically, you would still need a method for converting the text to the PDF elements, while keeping the text flow and word wrapping. This article may help. Please pay attention to the DoText(StreamReader sr) function. It takes text and purge it into separate lines within the PDF document, keeping the rendered within the margins.
On of the simpler methods that has worked for 3 decades e.g. more than one quarter of a century is place a postscript header before the text then use ghostscript ps2pdf it is the same method as used by some commercial apps such as acrobat
at its most basic
Copy heading.ps file.txt printfile.ps
GS -sDEVICE=pdfwrite printfile.ps printfile.pdf
Master Example can be seen here
How to modify this plaintext-to-PDF-converting PostScript from 1992 to actually specify a page size?