GMOD 3D2D Sign with website - lua

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!

Related

keyboard keyisdown is not activating

I am trying to make my paddle move up and down when I press the d and a buttons.
When i press the d and a buttons nothing happens at all... they just sit there.....
anyway the code is below if you know please tell me. thanks
I am aware the indenting is wrong i had to change if for this post:)
window_width = 580
window_height = 420
playerScore = 0
enemyScore = 0
pSpeed = 200
player1Y = 100
player2Y = -20
function love.load()
love.window.setMode(window_width, window_height)
end
function love.draw()
love.graphics.printf('hello pong', 0, window_height / 2 - 6, window_width, 'center')
love.graphics.rectangle("fill", 500, player1Y , 10, 50)
love.graphics.rectangle("fill", 40, 220, 10, 50)
love.graphics.rectangle("fill", 100, 230, 7, 5)
end
function update(dt)
if love.keyboard.isDown('d') then
player1Y = player1Y + pSpeed * dt
elseif love.keyboard.isDown('a') then
player1Y = player1Y + -pSpeed * dt
end
end
Try pSpeed = 10 instead of 200, so your rectangles aren't jumping beyond window_height in 2 steps.
And change colors for each rectangle, so it's easier to see what's happening.
function love.draw()
love.graphics.setColor( 0, 0, 0 ) -- black
love.graphics.printf( 'hello pong', 0, window_height /2 -6, window_width, 'center' )
love.graphics.setColor( 1, 0, 0 ) -- red
love.graphics.rectangle( "fill", 500, player1Y, 10, 50 )
love.graphics.setColor( 0, 1, 0 ) -- green
love.graphics.rectangle( "fill", 40, 220, 10, 50 )
love.graphics.setColor( 0, 0, 1 ) -- blue
love.graphics.rectangle( "fill", 100, 230, 7, 5 )
end
I think you should write "love.update(dt)" instead of writing only "update(dt)". I tried changing that and it worked! Also, indenting does not affect the way your code works in Lua, but it does massively improve readability.

How to repeat an image like css in lua?

https://gyazo.com/d0d0bab65c0a7060972988a5e73c7959
That was achieved by the this:
local x = script.Parent.Smile
local y = script.Parent.Smile2
while true do
x:TweenPosition(UDim2.new(0, 0, 1, 0))
y:TweenPosition(UDim2.new(0, 0, 1, 0))
wait(.1)
x.Position = y.Position + UDim2.new(0, 0, -1, 0)
y.Position = UDim2.new(0, 0, 0, 0)
end
I was wondering if there was a better way to do it and make it smoother(slower)?
If you want it to look as if it endlessly descends, try adding a "Linear" parameter to your tweens. It will keep the tween constant in speed. For example:
local x = script.Parent.Smile
local y = script.Parent.Smile2
while true do
x:TweenPosition(UDim2.new(0, 0, 1, 0),"Out","Linear",0.1)
y:TweenPosition(UDim2.new(0, 0, 1, 0),"Out","Linear",0.1)
wait(.105) -- making sure to tween again after 0.1 seconds, the 0.105 safely accounts for any latency in the game
x.Position = y.Position + UDim2.new(0, 0, -1, 0)
y.Position = UDim2.new(0, 0, 0, 0)
end
Try that script above, if it doesn't work you can blame me for it

Client request for tensorflow serving gives error "Attempting to use uninitialized value fully_connected/biases"

I created a LSTM RNN model for text classification on tensorflow and exported the savedModel successfully. I tested the model using savedModel CLI and everything seems to be working fine. However I am trying to create a client that can make a request and get a result. I have been following this tensorflow serving inception example (more specifically inception_client.py) for reference. This works well with the inception model but I am not sure how to change the request for my own model. How exactly should I change the request?
My signature and saving the model:
# Build the signature_def_map.
classification_signature = signature_def_utils.build_signature_def(
inputs={signature_constants.CLASSIFY_INPUTS: classification_inputs},
outputs={
signature_constants.CLASSIFY_OUTPUT_CLASSES:
classification_outputs_classes,
},
method_name=signature_constants.CLASSIFY_METHOD_NAME)
legacy_init_op = tf.group(
tf.tables_initializer(), name='legacy_init_op')
#add the sigs to the servable
builder.add_meta_graph_and_variables(
sess, [tag_constants.SERVING],
signature_def_map={
signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY:
classification_signature
},
assets_collection=tf.get_collection(tf.GraphKeys.ASSET_FILEPATHS),
legacy_init_op=tf.group(assign_filename_op))
print ("added meta graph and variables")
builder.save()
print("model saved")
The model takes in inputs_ as the input which is a list of list of numbers ( [[1,3,4,5,2]] ).
inputs_ = tf.placeholder(tf.int32, [None, None], name="input_ints")
How I am using the savedModel CLI (returns right results):
$ saved_model_cli run --dir ./python2_SavedModelFinalInputInts --tag_set serve --signature_def 'serving_default' --input_exprs inputs='[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2634, 758, 938, 579, 1868, 1894, 24, 651, 572, 32, 1847, 232]]'
More information about the savedModel:
$ saved_model_cli show --dir ./python2_prediction_SavedModelFinalInputInts --all
MetaGraphDef with tag-set: 'serve' contains the following SignatureDefs:
signature_def['serving_default']:
The given SavedModel SignatureDef contains the following input(s):
inputs['inputs'] tensor_info:
dtype: DT_INT32
shape: (-1, -1)
name: inputs/input_ints:0
The given SavedModel SignatureDef contains the following output(s):
outputs['outputs'] tensor_info:
dtype: DT_FLOAT
shape: (1, 1)
name: predictions/fully_connected/Sigmoid:0
Method name is: tensorflow/serving/predict
How I am trying to create a request in the client code:
request1 = predict_pb2.PredictRequest()
request1.model_spec.name = 'mnist'
request1.model_spec.signature_name = signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY
request1.inputs[signature_constants.PREDICT_INPUTS].CopyFrom(tf.contrib.util.make_tensor_proto(input_nums, shape=[1,100],dtype=tf.int32))
response = stub.Predict(request1,1.0)
result_dict = { 'Analyst Rating': str(response.message) }
return jsonify(result_dict)
I am getting the following error:
[2017-11-29 19:03:29,318] ERROR in app: Exception on /analyst_rating [POST]
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/local/lib/python2.7/dist-packages/flask_restful/__init__.py", line 480, in wrapper
resp = resource(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/flask/views.py", line 84, in view
return self.dispatch_request(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/flask_restful/__init__.py", line 595, in dispatch_request
resp = meth(*args, **kwargs)
File "restApi.py", line 91, in post
response = stub.Predict(request,1)
File "/usr/local/lib/python2.7/dist-packages/grpc/beta/_client_adaptations.py", line 309, in __call__
self._request_serializer, self._response_deserializer)
File "/usr/local/lib/python2.7/dist-packages/grpc/beta/_client_adaptations.py", line 195, in _blocking_unary_unary
raise _abortion_error(rpc_error_call)
AbortionError: AbortionError(code=StatusCode.FAILED_PRECONDITION, details="Attempting to use uninitialized value fully_connected/biases
[[Node: fully_connected/biases/read = Identity[T=DT_FLOAT, _class=["loc:#fully_connected/biases"], _output_shapes=[[1]], _device="/job:localhost/replica:0/task:0/cpu:0"](fully_connected/biases)]]")
127.0.0.1 - - [29/Nov/2017 19:03:29] "POST /analyst_rating HTTP/1.1" 500 -
{"message": "Internal Server Error"}
Update:
Changing the signature of the model from a classification signature to a prediction signature seemed to work. I also changed the legacy_init_op to legacy_init_op as defined from assign_filename_op which I was using for Assets organization initially.
Changing the model signature from classification to a prediction signature seemed to return results.
prediction_signature = (tf.saved_model.signature_def_utils.build_signature_def(
inputs={signature_constants.PREDICT_INPUTS: prediction_inputs},
outputs={signature_constants.PREDICT_OUTPUTS: prediction_outputs},
method_name=tf.saved_model.signature_constants.PREDICT_METHOD_NAME))
legacy_init_op = tf.group(tf.tables_initializer(), name='legacy_init_op')
#add the sigs to the servable
builder.add_meta_graph_and_variables(
sess, [tag_constants.SERVING],
signature_def_map={
signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY:
prediction_signature
},
# assets_collection=tf.get_collection(tf.GraphKeys.ASSET_FILEPATHS),
legacy_init_op=legacy_init_op)
I am not entirely sure how the client request should be for a model with classification signature or why it was not working.
(If anyone has an explanation, I will select that as the correct answer.)

AS2 Final Fantasy type Inventory

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.

In PDFKitten Special Character Searching not possible

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.

Resources