Edit: since I wasn't clear originally, I'm having trouble working out an AS2 inventory with stacking consumables and equippable weapons/armor, my code below is the arrays holding the values I've been working on for years but haven't figured any viable way to make work. I'm looking for help/ideas of how I can make an array hold these values and make them stack
Since about 2008, I've been working on a flash RPG. While I'm making headway, my biggest roadblock is the lack of item system which is becoming increasingly hard to create in AS2 as all of the great coders are slowly refusing to touch flash anymore. It's far too late to start over in a different language, my main file is a well over 500mb .fla
Honestly, I'd pay whoever can figure this out cause this game has a few other issues I'd like help with after this is solved. I'll throw down $50 usd to whoever can make a good item system with these reqs
Has to be able to draw from a database of different item types (consumable, weapon, armor, accessory)
Consumables must be able to "stack" (weapons, armor, accessories dont need to stack)
Consumables must be able to directly affect hp/mp values (heal and the like)
Weapons Armour acc. must have values attached to them so they can affect the character's stats when equipped (ex.strength +10 or something)
Items must be able to be bought and sold
Items must be able to be displayed in text (movieclips of each item is not really necessary)
AS2
Pretty much this below : (Final Fantasy item/inventory example)
File size is not an issue whatsoever, these items must be able to be rendered in game
Literally if possible, use Final Fantasy 7 (or any FF game) as a basis for how the item system should work. If you can get it close to that, I'll pay you immediately. This is the code I was working on...
//ITEM SYSTEM
//this array will hold all items, inside of it, hopefully to be called inside of itself
//0.......1............2........3......4.... array element values
//name, description, effect, price, item type
_global.itemlist = [
//CONSUMABLES
["Sweetroot", "Restores 50 HP", 50, 100, "consumable"],
["Sugarroot", "Restores 100 HP", 100, 500, "consumable"],
["Candyroot", "Fully restores HP", 9999, 5000, "consumable"],
["Bitterroot", "Restores 50 MP", 50, 200, "consumable"],
["Sourroot", "Restores 100 MP", 100, 600, "consumable"],
["Tartroot", "Fully restores MP", 9999, 10000, "consumable"]
];
//0.......1............2....3....4...5....6.....7. array element values
//name, description, user, str, sta, def, mst, item type
_global.weaponlist = [
//WEAPONS
["Secred", "A mysterious zanbato with seals on the blade", "azul", 50, 0, 25, 10, "weapon"],
["Illuminite", "A thin weapon with a diamond rod for focusing light", "aseru", 50, 10, 10, 50, "weapon"],
["Fists", "A bare handed attack", "malforn", 50, 0, 55, 0, "weapon"],
["Kazeshini", "An oddly shaped blade for quick attacks ", "vayle", 20, 10, 25, 10, "weapon"],
["Yamato", "A katana with a blue hilt and a lightweight blade", "aoizi", 50, 20, 35, 50, "weapon"],
["Saleria", "A heavy scythe made from chenre absorbing crystal", "laava", 50, 20, 35, 50, "weapon"]
];
//0.......1............2....3....4...5....6...7 array element values
//name, description, str, sta, def, mst, price, item type
_global.armorlist = [
["Clothes", "light clothing", 0, 10, 10, 0, 500, "armor"],
["Armor", "plated armor", 0, 20, 20, 0, 5000,"armor"],
["Chain", "a thick chain for attack or defense", 20, 10, 10, 0, 500,"armor"],
["Shawl", "thin fabric worn by women", 0, 0, 5, 10, 7000,"armor"],
["Bodysuit", "a thick full body suit", 10, 20, 20, 0, 7500,"armor"],
["Spiked Araments", "armor covered in spikes, increases attack strength", 30, 0, 20, 0, 8000,"armor"]
];
//0.......1............2....3....4...5....6...7 array element values
//name, description, str, sta, def, mst, price, item type
_global.acclist = [
["Blade Ring", "raises attack", 30, 0, 0, 0, 500,"accesory"],
["Vigor Ring", "raises stamina", 0, 30, 0, 0, 500,"accesory"],
["Shield Ring", "raises defense", 0, 0, 30, 0, 500,"accesory"],
["Chenre Ring", "raises mental", 0, 0, 0, 30, 500,"accesory"],
["Knife Ring", "greatly raises attack", 120, 0, 0, 0, 50000,"accesory"],
["Vehemence Ring", "greatly raises stamina", 0, 120, 0, 0, 50000,"accesory"],
["Aegis Ring", "greatly raises defense", 0, 0, 120, 0, 50000,"accesory"],
["Aura Ring", "greatly raises mental", 0, 0, 0, 120, 50000,"accesory"]
];
get item Name with item[0][0];
get item Description with item[0][1];
get item Effect with item[0][2];
Example : If item[0] is being addressed then... (item[0] [0] =
Secred (as Name). Then item[0] [1] = Fists (as Description), and so on. trace(item[0][4]); should trace the name Sweetroot.
Related
I need to create a pdf with a number of images with titles and descriptions.
I would be mapping an array of objects and then inserting them into the document as two columns.
With my understanding of how to do that right now, I would have to figure out a way to position each element dynamically.
const doc = new jsPDF();
doc.text("Some title", 10, 10);
doc.addImage(imageData, "JPEG, 10, 15, 100, 50)
doc.text("Some Desc", 10, 50);
doc.text("Some title", 300, 10);
doc.addImage(imageData, "JPEG, 300, 15, 100, 50)
doc.text("Some Desc", 300, 50);
doc.text("Some title", 10, 150);
doc.addImage(imageData, "JPEG, 10, 135, 100, 50)
doc.text("Some Desc", 10, 200);
// All of this x and y coordinates would have be calculated and not static as they are above
...and so on
//Something like that
If there was a wrapper element that I could relatively position the child elements, and then position the wrapper element in the document that would be a lot better.
However, I don't see a way this can be done. Am I wrong?
I would like to perform some networking benchmarks on my Dask cluster. What is the best way to get detailed information about recent transfers?
Dashboard
Many people use Dask's dashboard for this and watch for the presence of red bars in the task stream plot.
get_task_stream
However, if you're doing benchmarks then maybe the idea of looking at a live plot during computations isn't what you're looking for. You can get that same information by using the dask.distributed.get_task_stream context manager.
>>> from dask.distributed import get_task_stream
>>> with get_task_stream() as ts:
... x.compute()
>>> ts.data
[...]
This will include information about both computations and data transfers, so you'll have to sift through them a bit.
transfer_logs
Also, as of the time of writing this, Dask workers maintain logs of every transfer in the Worker.incoming_transfer_log and Worker.outgoing_transfer_log attributes. You could use the Client.run method to get these.
>>> client.run(lambda dask_worker: dask_worker.incoming_transfer_log)
{'tcp://192.168.1.191:50637': deque([]),
'tcp://192.168.1.191:50638': deque([]),
'tcp://192.168.1.191:50640': deque([{'start': 1558119113.3489196,
'stop': 1558119113.4012725,
'middle': 1558119113.375096,
'duration': 0.0523529052734375,
'keys': {"('dataframe-sum-chunk-5b219ece79c8315870694c0e17df68ee', 0, 27, 0)": 463941,
"('dataframe-sum-chunk-5b219ece79c8315870694c0e17df68ee', 0, 23, 0)": 464477,
"('dataframe-sum-chunk-5b219ece79c8315870694c0e17df68ee', 0, 7, 0)": 463708,
"('dataframe-sum-chunk-5b219ece79c8315870694c0e17df68ee', 0, 15, 0)": 464091,
"('dataframe-sum-chunk-5b219ece79c8315870694c0e17df68ee', 0, 19, 0)": 464826,
"('dataframe-sum-chunk-5b219ece79c8315870694c0e17df68ee', 0, 3, 0)": 463847,
"('dataframe-sum-chunk-5b219ece79c8315870694c0e17df68ee', 0, 11, 0)": 464200},
'total': 3249090,
'bandwidth': 62061312.22384144,
'who': 'tcp://192.168.1.191:50642'},
{'start': 1558119113.3484848,
'stop': 1558119113.4085395,
'middle': 1558119113.3785121,
'duration': 0.060054779052734375,
'keys': {"('dataframe-sum-chunk-5b219ece79c8315870694c0e17df68ee', 0, 12, 0)": 463485,
"('dataframe-sum-chunk-5b219ece79c8315870694c0e17df68ee', 0, 24, 0)": 464183,
"('dataframe-sum-chunk-5b219ece79c8315870694c0e17df68ee', 0, 16, 0)": 464061,
"('dataframe-sum-chunk-5b219ece79c8315870694c0e17df68ee', 0, 4, 0)": 464161,
"('dataframe-sum-chunk-5b219ece79c8315870694c0e17df68ee', 0, 8, 0)": 463925,
"('dataframe-sum-chunk-5b219ece79c8315870694c0e17df68ee', 0, 0, 0)": 464214,
"('dataframe-sum-chunk-5b219ece79c8315870694c0e17df68ee', 0, 20, 0)": 464070},
'total': 3248099,
'bandwidth': 54085604.03074382,
'who': 'tcp://192.168.1.191:50637'},
This is keyed by worker, and gives the start/stop/total bytes/sender/recipient of every transfer. This solution uses internal API though, and so could change at any time.
I'm trying to make a 3D2D Sign that has text on it and displays a website, so that i can walk around it and the website will stay in the same position. So far I have got this code but don't know how to import the website.
include("shared.lua")
function ENT:Initialize()
self:SetMaterial("models/shiny")
self:SetRenderMode(RENDERMODE_NORMAL)
self:SetColor(Color( 0, 0, 0, 255 ))
end
function ENT:Draw()
self:DrawModel()
local ENTPos = self:GetPos()+Vector(0,0,26)
local ENTAng = self:GetAngles()
ENTAng:RotateAroundAxis(ENTAng:Forward(), 0)
ENTAng:RotateAroundAxis(ENTAng:Right(), 270)
ENTAng:RotateAroundAxis(ENTAng:Up(), 90)
local url = "https://www.google.com/"
local webPage = vgui.Create("F1HTML")
webPage:OpenURL(url)
cam.Start3D2D(ENTPos + ENTAng:Up() * 2, ENTAng, 0.5)
draw.RoundedBox( 2, -220, -62.5, 440, 227, Color(0, 0, 0, 255) );--Black Body
draw.RoundedBox( 2, -220, -62.5, 440, 30, Color(255, 0, 0, 255) );--Red Title
local FontNameTitle = "HUDNumber5"
draw.SimpleText( "Server", FontNameTitle, 0, -33, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP)
cam.End3D2D()
end
To display a website in 3D space like you are trying to do, I'd recommend using the 3D2D derma project by HandsomeMatt.
Derma can, as you may already know, be used to open a website in a panel.
Check the Derma Basic Guide on how to use derma.
It allows for you to draw derma panels in a 3D2D space, like you want!
I am using PDFKitten search functionality and found that in this the Special Characters are not able to search (e.g. let say in PDF ther is a word RAVI's and if I search the word it will return NULL value. Please suggest me how do I resolve this issue.
Thanks
In scanner.m there is a function didScanString
void didScanString(CGPDFStringRef pdfString, Scanner *scanner)
{
NSString *tempStr = (NSString *)CGPDFStringCopyTextString(pdfString);
NSLog(#"ScanString==%#",tempStr);
NSString *string = [[scanner stringDetector] appendPDFString:pdfString withFont:[scanner currentFont]];
NSLog(#"didScanString====>>>%#",string);
[ss appendString:string];
[[scanner content] appendString: string];
//NSLog(#"TOTAL: %#",[scanner content]);
}
For example the Search PDF String is MGR KL445's
In the above function two NSLog out put 1st one showing ScanString==MGR KL445™s
and 2nd one nothing will showing.
Your search text RAVI's contains a vertical apostrophe; have you checked whether the PDF does not contain a forward or backward slanted version of that character instead? Those different versions have different character codes after all.
In the context of question PDFKitten is highlighting on wrong position, it became appearant that that library returns ligatures as single ligatured characters instead of 'de-ligaturized' character groups. If your text contains ligatures, that might be the reason.
In the context of the same question, PDFKitten font data parsing turned out to be deficient in some respects. In reaction to that question, a workaround for one such deficiency has been added to the code which in my eyes didn't fix the general case, merely some special cases, cf. the proposal in my answer there.
Furthermore some fonts simply do not contain the information for mapping their glyphs back to unicode characters. You say the Special Characters are not able to search --- maybe those special characters are taken from a different font not supporting parsing.
Theoretically the apostrophe might even have been drawn using graphic, non-text operators. In that case text parsing won't find it.
If none of these ideas explain your case (or you cannot check whether they do), please supply the sample PDF for inspection.
EDIT (taking into account your Brivo MR355 copy.pdf sample file)
I assume that again the apostrophe is troublesome, this time in MR355’s. There are two accurances in the raw page content,
/TT1 1 Tf
0.559 0 Td
(Brivo MR355\222s Ready Bar technology replaces 30 complex inputs with a single control, simplifying scan optimization )Tj
and
/TT1 1 Tf
0.559 0 Td
(Brivo MR355\222s Ready Interface)Tj
Both time the font resource /TT1 is used, and both times the apostrophe is encoded as \222 which is octal for 146 decimal, quoteright in WinAnsiEncoding, trademark in PDFDocEncoding.
/TT1 is
/LastChar 146
/BaseFont /REEDOQ+GEInspira
/Type /Font
/Subtype /TrueType
/Encoding /WinAnsiEncoding
/Widths [232, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 198, 0, 0, 0, 530, 0, 0, 530, 0, 530, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 570, 0, 0, 0, 0, 0, 0, 243, 0, 0, 0, 764, 0, 0, 0, 0, 556, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 545, 545, 482, 545, 509, 297, 545, 544, 210, 0, 0, 210, 836, 544, 537, 545, 545, 341, 437, 317, 544, 474, 736, 471, 474, 427, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 190]
/FontDescriptor 32 0 R
/FirstChar 32
/LastChar being 146 and /Encoding being /WinAnsiEncoding should make it easy for PDFKitten to recognize the \222 as quoteright character.
As one of your comments indicated that you are not using the most current PDFKitten version, I'll do the code analysis based on an older copy, too.
PDFKitten while parsing that font dictionary (setEncodingNamed in Font.m) recognizes the string "WinAnsiEncoding" and stores WinAnsiEncoding (3) from the enum CharacterEncoding (Font.h) in self.encoding; lateron, when converting the raw PDF data to unicode (stringWithPDFString in SimpleFont.m), it calls and returns
NSString *string = [[NSString alloc] initWithData:rawBytes encoding:self.encoding];
But the encoding constants in nsstring.h map
NSJapaneseEUCStringEncoding = 3,
Thus, PDFKitten here tries to decode the raw data as EUC-JP encoded which for byte values >127 should fail miserably while byte values <= 127 are interpreted as ASCII characters.
NSString initWithData returns nil if the initialization fails for some reason (for example if data does not represent valid data for encoding). Thus, PDFKitten drops the whole fragment while processing the PDF data.
At first glance the relevant code parts still are the same in the current code base. Thus, you might want to report an issue at the PDFKitten site concerning character codes > 127 for fonts with /Encoding /WinAnsiEncoding and most likely with `/Mac*Encoding' , too.
Is there a gem in Ruby which can write to an Excel file, with dynamic background coloring based on condition (need to set the color using HEX code)?
I need to write different colors to different cells dynamically based on condition (ex: status filed of a record)
Any help is greatly appreciated.
You may take a look to rexcel
After installation you may check examples/example_color.rb
It creates:
You can set the cell backgrounds dynamically using the Conditional Formating feature of the write_xlsx gem.
Here is an example from the gemfile:
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'rubygems'
require 'write_xlsx'
workbook = WriteXLSX.new('conditional_format.xlsx')
worksheet1 = workbook.add_worksheet
# Light red fill with dark red text.
format1 = workbook.add_format(
:bg_color => '#FFC7CE',
:color => '#9C0006'
)
# Green fill with dark green text.
format2 = workbook.add_format(
:bg_color => '#C6EFCE',
:color => '#006100'
)
# Some sample data to run the conditional formatting against.
data = [
[ 90, 80, 50, 10, 20, 90, 40, 90, 30, 40 ],
[ 20, 10, 90, 100, 30, 60, 70, 60, 50, 90 ],
[ 10, 50, 60, 50, 20, 50, 80, 30, 40, 60 ],
[ 10, 90, 20, 40, 10, 40, 50, 70, 90, 50 ],
[ 70, 100, 10, 90, 10, 10, 20, 100, 100, 40 ],
[ 20, 60, 10, 100, 30, 10, 20, 60, 100, 10 ],
[ 10, 60, 10, 80, 100, 80, 30, 30, 70, 40 ],
[ 30, 90, 60, 10, 10, 100, 40, 40, 30, 40 ],
[ 80, 90, 10, 20, 20, 50, 80, 20, 60, 90 ],
[ 60, 80, 30, 30, 10, 50, 80, 60, 50, 30 ]
]
# This example below highlights cells that have a value greater than or
# equal to 50 in red and cells below that value in green.
caption = 'Cells with values >= 50 are in light red. ' +
'Values < 50 are in light green'
# Write the data.
worksheet1.write('A1', caption)
worksheet1.write_col('B3', data)
# Write a conditional format over a range.
worksheet1.conditional_formatting('B3:K12',
{
:type => 'cell',
:format => format1,
:criteria => '>=',
:value => 50
}
)
# Write another conditional format over the same range.
worksheet1.conditional_formatting('B3:K12',
{
:type => 'cell',
:format => format2,
:criteria => '<',
:value => 50
}
)
workbook.close
The output file will look like this:
I know for sure that writeexcel can do this (see Cell formatting).
One important thing that writeexcel supports Excel 97-2007 formats.