GMS2 trigger for event not working properly - gml

(First of all i'm new to all of this so sorry in advance if this was a waste of time)
So I'm creating a game and decided to follow Friendly Cosmonaut's guide on triggers and cutscenes.
(link) https://www.youtube.com/watch?v=LDLxCXexcxk
I followed everything there and created a few custom scripts and everything works like a charm on the first room, but when I try adding a trigger on the second room it just doesn't work at all.
For example, I create a trigger so when it collides with the player object, it makes the screen shake (as a test) and it creates an object in the room. But when the code is the following:
t_scene_info = [
[screen_shake, 6, 1000],
]
(I'll provide code for all functions further in the post)
Nothing happens on collision, but when I change it to:
t_scene_info = [
[screen_shake(6, 1000)],
]
The code runs before even the player has collided, as soon as the trigger object gets created.
(Again, I tried this in the first room with the first 2 triggers, and it works fine.)
Here's the code for:
oCutscene (Create event):
scene_info = -1;
scene = 0;
timer = 0;
scene_info = [
[create_box_at_mouse],
[cutscene_wait, 2],
[create_box_at_mouse],
[cutscene_wait, 4],
[create_box_at_mouse]
];
event_perform(ev_other, ev_user0);
x_dest = -1;
y_dest = -1;
oCutscene (Step event):
script_execute_alt(current_scene[0], current_scene_array);
oCutscene (User event 0):
current_scene = scene_info[scene]
var len = array_length_1d(current_scene) -1;
current_scene_array = -1;
current_scene_array = array_create(len, 0);
array_copy(current_scene_array, 0, current_scene, 1, len);
oTriggerP (Step event) (The trigger that's supposed to execute the code when colliding with the player or playerd (just a dummy)):
if(!instance_exists(oCutscene)){
if(place_meeting(x, y, oPlayerD) || place_meeting(x, y, oPlayer)){
create_cutscene(t_scene_info);
instance_destroy();
}
}
oTriggerP (Create event):
t_scene_info = -1;
create_cutscene (Script):
if(!instance_exists(oCutscene)){
if(place_meeting(x, y, oPlayerD) || place_meeting(x, y, oPlayer)){
create_cutscene(t_scene_info);
instance_destroy();
}
}
cutscene_end_action (Script):
with(oCutscene){
scene++;
if(scene > array_length_1d(scene_info)-1){
instance_destroy();
exit;
}
event_perform(ev_other, ev_user0);
}
cutscene_wait (Script):
with(oCutscene){
scene++;
if(scene > array_length_1d(scene_info)-1){
instance_destroy();
exit;
}
event_perform(ev_other, ev_user0);
}
script_execute_alt (Script):
///#description script_execute_alt
///#arg ind
///#arg [arg1,arg2,...]
var num1 = argument0;
var a = argument1;
var len = array_length_1d(argument1);
switch(len){
case 0 : script_execute(0) break;
case 1 : script_execute(num1, a[0]); break;
case 2: script_execute(num1, a[0], a[1]); break;
case 3: script_execute(num1, a[0], a[1], a[2]); break;
case 4: script_execute(num1, a[0], a[1], a[2], a[3]); break;
case 5: script_execute(num1, a[0], a[1], a[2], a[3], a[4]); break;
case 6: script_execute(num1, a[0], a[1], a[2], a[3], a[4], a[5]); break;
case 7: script_execute(num1, a[0], a[1], a[2], a[3], a[4], a[5], a[6]); break;
case 8: script_execute(num1, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7]); break;
case 9: script_execute(num1, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]); break;
case 10: script_execute(num1, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9]);
break;
case 11: script_execute(num1, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9],
a[10]); break;
case 12: script_execute(num1, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9],
a[10], a[11]); break;
case 13: script_execute(num1, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9],
a[10], a[11], a[12]); break;
case 14: script_execute(num1, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9],
a[10], a[11], a[12], a[13]); break;
case 15: script_execute(num1, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9],
a[10], a[11], a[12], a[13], a[14]); break;
case 16: script_execute(num1, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9],
a[10], a[11], a[12], a[13], a[14], a[15]); break;
case 17: script_execute(num1, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9],
a[10], a[11], a[12], a[13], a[14], a[15], a[16]); break;
case 18: script_execute(num1, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9],
a[10], a[11], a[12], a[13], a[14], a[15], a[16], a[17]); break;
case 19: script_execute(num1, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9],
a[10], a[11], a[12], a[13], a[14], a[15], a[16], a[17], a[18]); break;
case 20: script_execute(num1, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9],
a[10], a[11], a[12], a[13], a[14], a[15], a[16], a[17], a[18], a[19]); break;
}
screen_shake (Script):
///#arg Magnitude
///#arg Time
with(oCamera){
if(argument0 > shake_remain){
shake_magnitude = argument0;
shake_remain = argument0;
shake_length = argument1;
}
cutscene_end_action();
}
Here's the creation code for the 2 triggers in the first room:
First trigger (oTriggerP):
t_scene_info = [
[cutscene_move_character, oPlayerD, 800, 279, false, 1],
[cutscene_wait, 1],
[instance_create_layer, 0, 0, 0, oIntro],
[cutscene_move_character, oPlayerD, 1170, 279, false, 1],
];
Second trigger (Another oTriggerP):
t_scene_info = [
[cutscene_move_character, oPlayerD, 800, 279, false, 1],
[cutscene_wait, 1],
[instance_create_layer, 0, 0, 0, oIntro],
[cutscene_move_character, oPlayerD, 1170, 279, false, 1],
[room_goto(Prehistoric)]
];
I really don't think the cutscene_wait and cutscene_move_character scripts have anything to do with this but I'll throw 'em in just in case
cutscene_wait (Script):
/// #description
/// #arg second
with(oCutscene){
timer++;
if(timer >= argument[0] * room_speed){
timer = 0;
cutscene_end_action();
}
}
cutscene_move_character (Script)
with(oCutscene){
var obj = argument0, relative = argument3, spd = argument4;
if(x_dest == -1){
if(!relative){
x_dest = argument1;
y_dest = argument2;
} else{
x_dest = obj.x + argument1;
y_dest = obj.y + argument2;
}
}
var xx = x_dest;
var yy = y_dest;
with(obj){
sprite_index = sPlayerR;
if(point_distance(x, y, xx, yy) >= spd){
var dir = point_direction(x, y, xx, yy);
var ldirx = lengthdir_x(spd, dir);
var ldiry = lengthdir_y(spd, dir);
if(dir != 0) { image_xscale = sign(ldirx); }
x += ldirx;
y += ldiry;
}else {
x = xx;
y = yy;
with(other){
x_dest = -1;
y_dest = -1;
cutscene_end_action();
}
}
}
}
Thank you in advance for your time and patience, and I apologize if I didn't include something or messed up on anything.

Related

Using shift function along with max function Pandas

I am attempting to create a technical indicator ('Supertrend') using Pandas. The formula for this column is recursive.
(For people familiar with Pinescript, this column will replicate the result of this Pinescript function):
df['st_trendup'] = np.select(df['Close'].shift() > df['st_trendup'].shift(),df[['st_up','st_trendup'.shift()]].max(axis=1),df['st_up'])
The problem occurs in the true part of the np.select()because I cannot call .shift() on a string.
Normally, I would make a new column that uses .shift() beforehand but since this is recursive, I have to do it all in one line.
If possible I'd like to avoid using loops for speed; prefer solutions using native pandas or numpy functions.
What I am looking for
A way to find max function that can accomodate a .shift() call
Columns that are used:
def tr(high,low,close1):
return max(high - low, abs(high - close1), abs(low - close1))
df['st_closeprev'] = df['Close'].shift()
df['st_hl2'] = (df['High']+df['Low'])/2
df['st_tr'] = df.apply(lambda row: tr(row['High'],row['Low'],row['st_closeprev']),axis=1)
df['st_atr'] = df['st_tr'].ewm(alpha = 1/pd,adjust=False,min_periods=pd).mean()
df['st_up'] = df['st_hl2'] - factor * df['st_atr']
df['st_dn'] = df['st_hl2'] + factor * df['st_atr']
df['st_trendup'] = np.select(df['Close'].shift() > df['st_trendup'].shift(),df[['st_up','st_trendup'.shift()]].max(axis=1),df['st_up'])
Sample data obtained by the df.to_dict
{'Date': {0: Timestamp('2021-01-01 09:15:00'),
1: Timestamp('2021-01-01 09:30:00'),
2: Timestamp('2021-01-01 09:45:00'),
3: Timestamp('2021-01-01 10:00:00'),
4: Timestamp('2021-01-01 10:15:00'),
5: Timestamp('2021-01-01 10:30:00'),
6: Timestamp('2021-01-01 10:45:00'),
7: Timestamp('2021-01-01 11:00:00'),
8: Timestamp('2021-01-01 11:15:00'),
9: Timestamp('2021-01-01 11:30:00'),
10: Timestamp('2021-01-01 11:45:00'),
11: Timestamp('2021-01-01 12:00:00'),
12: Timestamp('2021-01-01 12:15:00'),
13: Timestamp('2021-01-01 12:30:00'),
14: Timestamp('2021-01-01 12:45:00'),
15: Timestamp('2021-01-01 13:00:00'),
16: Timestamp('2021-01-01 13:15:00'),
17: Timestamp('2021-01-01 13:30:00'),
18: Timestamp('2021-01-01 13:45:00'),
19: Timestamp('2021-01-01 14:00:00'),
20: Timestamp('2021-01-01 14:15:00'),
21: Timestamp('2021-01-01 14:30:00'),
22: Timestamp('2021-01-01 14:45:00'),
23: Timestamp('2021-01-01 15:00:00'),
24: Timestamp('2021-01-01 15:15:00'),
25: Timestamp('2021-01-04 09:15:00')},
'Open': {0: 31250.0,
1: 31376.0,
2: 31405.0,
3: 31389.4,
4: 31377.5,
5: 31347.8,
6: 31310.8,
7: 31343.4,
8: 31349.5,
9: 31349.9,
10: 31325.1,
11: 31310.9,
12: 31329.0,
13: 31376.0,
14: 31375.5,
15: 31357.4,
16: 31325.0,
17: 31341.1,
18: 31300.0,
19: 31324.5,
20: 31353.3,
21: 31350.0,
22: 31346.9,
23: 31330.0,
24: 31314.3,
25: 31450.2},
'High': {0: 31407.0,
1: 31425.0,
2: 31411.95,
3: 31389.45,
4: 31382.0,
5: 31350.0,
6: 31354.6,
7: 31359.0,
8: 31370.0,
9: 31364.7,
10: 31350.0,
11: 31337.9,
12: 31378.9,
13: 31419.5,
14: 31377.75,
15: 31360.0,
16: 31367.15,
17: 31345.2,
18: 31340.0,
19: 31367.0,
20: 31375.0,
21: 31370.0,
22: 31350.0,
23: 31334.6,
24: 31329.6,
25: 31599.0},
'Low': {0: 31250.0,
1: 31367.95,
2: 31352.5,
3: 31331.65,
4: 31301.4,
5: 31303.05,
6: 31310.0,
7: 31325.05,
8: 31335.35,
9: 31315.35,
10: 31281.9,
11: 31292.0,
12: 31316.25,
13: 31352.05,
14: 31335.0,
15: 31322.0,
16: 31318.25,
17: 31261.55,
18: 31283.3,
19: 31324.5,
20: 31322.0,
21: 31332.15,
22: 31324.1,
23: 31300.15,
24: 31280.0,
25: 31430.0},
'Close': {0: 31375.0,
1: 31398.3,
2: 31386.0,
3: 31377.0,
4: 31342.3,
5: 31311.7,
6: 31345.0,
7: 31349.0,
8: 31344.2,
9: 31327.6,
10: 31311.3,
11: 31325.6,
12: 31373.0,
13: 31375.0,
14: 31357.4,
15: 31326.0,
16: 31345.9,
17: 31300.6,
18: 31324.4,
19: 31353.8,
20: 31345.6,
21: 31341.6,
22: 31332.5,
23: 31311.0,
24: 31285.0,
25: 31558.4},
'Volume': {0: 259952,
1: 163775,
2: 105900,
3: 99725,
4: 115175,
5: 78625,
6: 67675,
7: 46575,
8: 53350,
9: 54175,
10: 96975,
11: 80925,
12: 79475,
13: 147775,
14: 38900,
15: 64925,
16: 52425,
17: 142175,
18: 81800,
19: 74950,
20: 68550,
21: 40350,
22: 47150,
23: 119200,
24: 222875,
25: 524625}}
Change:
df[['st_up','st_trendup'.shift()]].max(axis=1)
to:
df[['st_up','st_trendup']].assign(st_trendup = df['st_trendup'].shift()).max(axis=1)

how to plot the loss from the log file

The below mentioned are the loss values generated in the file 'log'(the iterations are actually more than this what I listed below). Attached the screenshot of the contents of the log file for ref. How to plot the Iteration (x-axis) vs Loss (y-axis) from these contents in the 'log' file ?
0: combined_hm_loss: 0.17613089
1: combined_hm_loss: 0.20243575
2: combined_hm_loss: 0.07203530
3: combined_hm_loss: 0.03444689
4: combined_hm_loss: 0.02623464
5: combined_hm_loss: 0.02061908
6: combined_hm_loss: 0.01562270
7: combined_hm_loss: 0.01253260
8: combined_hm_loss: 0.01102418
9: combined_hm_loss: 0.00958306
10: combined_hm_loss: 0.00824807
11: combined_hm_loss: 0.00694697
12: combined_hm_loss: 0.00640630
13: combined_hm_loss: 0.00593691
14: combined_hm_loss: 0.00521284
15: combined_hm_loss: 0.00445185
16: combined_hm_loss: 0.00408901
17: combined_hm_loss: 0.00377806
18: combined_hm_loss: 0.00314004
19: combined_hm_loss: 0.00287649
enter image description here
try this:
import pandas as pd
import numpy as np
import io
data = '''
index combined_hm_loss
0: 0.17613089
1: 0.20243575
2: 0.07203530
3: 0.03444689
4: 0.02623464
5: 0.02061908
6: 0.01562270
7: 0.01253260
8: 0.01102418
9: 0.00958306
10: 0.00824807
11: 0.00694697
12: 0.00640630
13: 0.00593691
14: 0.00521284
15: 0.00445185
16: 0.00408901
17: 0.00377806
18: 0.00314004
19: 0.00287649
'''
df = pd.read_csv(io.StringIO(data), delim_whitespace=True)
ax = df.plot.area(y='combined_hm_loss')
ax.invert_yaxis()

Creating a Dropdown menu in Plotly from Pandas

I've had a look at the following link but its not very clear https://plot.ly/pandas/dropdowns/.
I have the following figure generated in plotly but would like a dropdown menu (of A, B and C) to select and display the respective line only
import pandas as pd
import plotly
plotly.offline.init_notebook_mode()
import plotly.offline as py
from plotly.graph_objs import *
df = pd.DataFrame({'freq': {0: 0.01, 1: 0.02, 2: 0.029999999999999999, 3: 0.040000000000000001, 4: 0.050000000000000003, 5: 0.059999999999999998, 6: 0.070000000000000007, 7: 0.080000000000000002, 8: 0.089999999999999997, 9: 0.10000000000000001, 10: 0.01, 11: 0.02, 12: 0.029999999999999999, 13: 0.040000000000000001, 14: 0.050000000000000003, 15: 0.059999999999999998, 16: 0.070000000000000007, 17: 0.080000000000000002, 18: 0.089999999999999997, 19: 0.10000000000000001, 20: 0.01, 21: 0.02, 22: 0.029999999999999999, 23: 0.040000000000000001, 24: 0.050000000000000003, 25: 0.059999999999999998, 26: 0.070000000000000007, 27: 0.080000000000000002, 28: 0.089999999999999997, 29: 0.10000000000000001}, 'kit': {0: 'B', 1: 'B', 2: 'B', 3: 'B', 4: 'B', 5: 'B', 6: 'B', 7: 'B', 8: 'B', 9: 'B', 10: 'A', 11: 'A', 12: 'A', 13: 'A', 14: 'A', 15: 'A', 16: 'A', 17: 'A', 18: 'A', 19: 'A', 20: 'C', 21: 'C', 22: 'C', 23: 'C', 24: 'C', 25: 'C', 26: 'C', 27: 'C', 28: 'C', 29: 'C'}, 'SNS': {0: 91.198979591799997, 1: 90.263605442199989, 2: 88.818027210899999, 3: 85.671768707499993, 4: 76.23299319729999, 5: 61.0969387755, 6: 45.1530612245, 7: 36.267006802700003, 8: 33.0782312925, 9: 30.739795918400002, 10: 90.646258503400006, 11: 90.306122449, 12: 90.178571428600009, 13: 89.498299319699996, 14: 88.435374149599994, 15: 83.588435374200003, 16: 75.212585034, 17: 60.969387755100001, 18: 47.278911564600001, 19: 37.627551020399999, 20: 90.986394557800011, 21: 90.136054421799997, 22: 89.540816326499993, 23: 88.690476190499993, 24: 86.479591836799997, 25: 82.397959183699996, 26: 73.809523809499993, 27: 63.180272108800004, 28: 50.935374149700003, 29: 41.241496598699996}, 'FPR': {0: 1.0953616823100001, 1: 0.24489252678500001, 2: 0.15106142277199999, 3: 0.104478605177, 4: 0.089172822253300005, 5: 0.079856258734300009, 6: 0.065881413455800009, 7: 0.059892194050699996, 8: 0.059892194050699996, 9: 0.0578957875824, 10: 0.94097291541899997, 11: 0.208291741532, 12: 0.14773407865800001, 13: 0.107805949291, 14: 0.093165635189999998, 15: 0.082518134025399995, 16: 0.074532508152000007, 17: 0.065881413455800009, 18: 0.062554069341799995, 19: 0.061888600519100001, 20: 0.85313103081100006, 21: 0.18899314567100001, 22: 0.14107939043000001, 23: 0.110467824582, 24: 0.099820323417899995, 25: 0.085180009316599997, 26: 0.078525321088700001, 27: 0.073201570506399985, 28: 0.071870632860800004, 29: 0.0705396952153}})
fig = {
'data': [
{
'x': df[df['kit']==kit]['FPR'],
'y': df[df['kit']==kit]['SNS'],
'name': kit,
} for kit in ['A', 'B', 'C']
],
}
py.iplot(fig)
I'm not sure how to do this directly from plotly; however, you can use interact function from ipywidgets library.
In your case it will be the following:
from ipywidgets import interact
df = pd.DataFrame({'freq': {0: 0.01, 1: 0.02, 2: 0.029999999999999999, 3: 0.040000000000000001, 4: 0.050000000000000003, 5: 0.059999999999999998, 6: 0.070000000000000007, 7: 0.080000000000000002, 8: 0.089999999999999997, 9: 0.10000000000000001, 10: 0.01, 11: 0.02, 12: 0.029999999999999999, 13: 0.040000000000000001, 14: 0.050000000000000003, 15: 0.059999999999999998, 16: 0.070000000000000007, 17: 0.080000000000000002, 18: 0.089999999999999997, 19: 0.10000000000000001, 20: 0.01, 21: 0.02, 22: 0.029999999999999999, 23: 0.040000000000000001, 24: 0.050000000000000003, 25: 0.059999999999999998, 26: 0.070000000000000007, 27: 0.080000000000000002, 28: 0.089999999999999997, 29: 0.10000000000000001}, 'kit': {0: 'B', 1: 'B', 2: 'B', 3: 'B', 4: 'B', 5: 'B', 6: 'B', 7: 'B', 8: 'B', 9: 'B', 10: 'A', 11: 'A', 12: 'A', 13: 'A', 14: 'A', 15: 'A', 16: 'A', 17: 'A', 18: 'A', 19: 'A', 20: 'C', 21: 'C', 22: 'C', 23: 'C', 24: 'C', 25: 'C', 26: 'C', 27: 'C', 28: 'C', 29: 'C'}, 'SNS': {0: 91.198979591799997, 1: 90.263605442199989, 2: 88.818027210899999, 3: 85.671768707499993, 4: 76.23299319729999, 5: 61.0969387755, 6: 45.1530612245, 7: 36.267006802700003, 8: 33.0782312925, 9: 30.739795918400002, 10: 90.646258503400006, 11: 90.306122449, 12: 90.178571428600009, 13: 89.498299319699996, 14: 88.435374149599994, 15: 83.588435374200003, 16: 75.212585034, 17: 60.969387755100001, 18: 47.278911564600001, 19: 37.627551020399999, 20: 90.986394557800011, 21: 90.136054421799997, 22: 89.540816326499993, 23: 88.690476190499993, 24: 86.479591836799997, 25: 82.397959183699996, 26: 73.809523809499993, 27: 63.180272108800004, 28: 50.935374149700003, 29: 41.241496598699996}, 'FPR': {0: 1.0953616823100001, 1: 0.24489252678500001, 2: 0.15106142277199999, 3: 0.104478605177, 4: 0.089172822253300005, 5: 0.079856258734300009, 6: 0.065881413455800009, 7: 0.059892194050699996, 8: 0.059892194050699996, 9: 0.0578957875824, 10: 0.94097291541899997, 11: 0.208291741532, 12: 0.14773407865800001, 13: 0.107805949291, 14: 0.093165635189999998, 15: 0.082518134025399995, 16: 0.074532508152000007, 17: 0.065881413455800009, 18: 0.062554069341799995, 19: 0.061888600519100001, 20: 0.85313103081100006, 21: 0.18899314567100001, 22: 0.14107939043000001, 23: 0.110467824582, 24: 0.099820323417899995, 25: 0.085180009316599997, 26: 0.078525321088700001, 27: 0.073201570506399985, 28: 0.071870632860800004, 29: 0.0705396952153}})
def plot_it(kit):
fig = {
'data': [
{
'x': df[df['kit']==kit]['FPR'],
'y': df[df['kit']==kit]['SNS'],
'name': kit
}
]
}
py.iplot(fig)
interact(plot_it, kit=('A', 'B', 'C'))

Verilog: cannot be driven by primitive or continous assignment

Verilog: cannot be driven by primitive or continous assignment
ok, its giving me this error on on every line that I do an instance of FullAdder 32 bit.
module Multiplier_S(output reg [63:0] f_result, input [31:0] a, input [31:0] b);
wire [31:0] sum1,sum2,sum3,sum4,sum5,sum6,sum7,sum8,sum9,sum10,sum11,sum12,sum13,sum14,
sum15,sum16,sum17,sum18,sum19,sum20,sum21,sum22,sum23,sum24,sum25,sum26,sum27,sum28,
sum29,sum30,sum31;
wire [31:0] and1,and2,and3,and4,and5,and6,and7,and8,and9,and10,and11,and12,and13,and14,
and15,and16,and17,and18,and19,and20,and21,and22,and23,and24,and25,and26,and27,and28,
and29,and30,and31,and32;
reg [63:0] result;
//bit0
AND_Bank a_1(and1, a[0], b);
initial begin
result[0] = and1[0];
end
Shift_Right_32bit shift1(and1, 1, and1);
initial begin
and1[31]=1'b0;
end
//bit 1
AND_Bank a_2(and2, a[1], b);
FullAdder_32bit adder1(sum1, result[1], and2, and1);
//bit 2
AND_Bank a_3(and3, a[2], b);
FullAdder_32bit adder2(sum2, result[2], and3, sum1);
//bit 3
AND_Bank a_4(and4, a[3], b);
FullAdder_32bit adder3(sum3, result[3], and4, sum2);
//bit 4
AND_Bank a_5(and5, a[4], b);
FullAdder_32bit adder4(sum4, result[4], and5, sum3);
//bit 5
AND_Bank a_6(and6, a[5], b);
FullAdder_32bit adder5(sum5, result[5], and6, sum4);
//bit 6
AND_Bank a_7(and7, a[6], b);
FullAdder_32bit adder6(sum6, result[6], and7, sum5);
//bit 7
AND_Bank a_8(and8, a[7], b);
FullAdder_32bit adder7(sum7, result[7], and8, sum6);
//bit 8
AND_Bank a_9(and10, a[8], b);
FullAdder_32bit adder8(sum8, result[8], and9, sum7);
//bit 9
AND_Bank a_10(and11, a[9], b);
FullAdder_32bit adder9(sum9, result[9], and10, sum8);
//bit 10
AND_Bank a_11(and12, a[10], b);
FullAdder_32bit adder10(sum10, result[10], and11, sum9);
//bit 11
AND_Bank a_12(and13, a[11], b);
FullAdder_32bit adder11(sum11, result[11], and12, sum10);
//bit 12
AND_Bank a_13(and14, a[12], b);
FullAdder_32bit adder12(sum12, result[12], and13, sum11);
//bit 13
AND_Bank a_14(and15, a[13], b);
FullAdder_32bit adder13(sum13, result[13], and14, sum12);
//bit 14
AND_Bank a_15(and16, a[14], b);
FullAdder_32bit adder14(sum14, result[14], and15, sum13);
//bit 15
AND_Bank a_16(and17, a[15], b);
FullAdder_32bit adder15(sum15, result[15], and16, sum14);
//bit 16
AND_Bank a_17(and18, a[16], b);
FullAdder_32bit adder16(sum16, result[16], and17, sum15);
//bit 17
AND_Bank a_18(and19, a[17], b);
FullAdder_32bit adder17(sum17, result[17], and18, sum16);
//bit 18
AND_Bank a_19(and20, a[18], b);
FullAdder_32bit adder18(sum18, result[18], and19, sum17);
//bit 19
AND_Bank a_20(and21, a[19], b);
FullAdder_32bit adder19(sum19, result[19], and20, sum18);
//bit 20
AND_Bank a_21(and22, a[20], b);
FullAdder_32bit adder20(sum20, result[20], and21, sum19);
//bit 21
AND_Bank a_22(and23, a[21], b);
FullAdder_32bit adder21(sum21, result[21], and22, sum20);
//bit 22
AND_Bank a_23(and24, a[22], b);
FullAdder_32bit adder22(sum22, result[22], and23, sum21);
//bit 23
AND_Bank a_24(and25, a[23], b);
FullAdder_32bit adder23(sum23, result[23], and24, sum22);
//bit 24
AND_Bank a_25(and25, a[24], b);
FullAdder_32bit adder24(sum24, result[24], and25, sum23);
//bit 25
AND_Bank a_26(and26, a[25], b);
FullAdder_32bit adder25(sum25, result[25], and26, sum24);
//bit 26
AND_Bank a_27(and27, a[26], b);
FullAdder_32bit adder26(sum26, result[26], and27, sum25);
//bit 27
AND_Bank a_28(and28, a[27], b);
FullAdder_32bit adder27(sum27, result[27], and28, sum26);
//bit 28
AND_Bank a_29(and29, a[28], b);
FullAdder_32bit adder28(sum28, result[28], and29, sum27);
//bit 29
AND_Bank a_30(and30, a[29], b);
FullAdder_32bit adder29(sum29, result[29], and30, sum28);
//bit 30
AND_Bank a_31(and31, a[30], b);
FullAdder_32bit adder30(sum30, result[30], and31, sum29);
//bit 31
AND_Bank a_32(and32, a[31], b);
FullAdder_32bit adder31(sum31, result[31], and32, sum30);
//bit 63 al 32
initial begin
result[62:32] = sum31[30:0];
end
if(a[31] || b[31])
begin
initial begin
result[63] = 1'b0;
end
end
else
begin
initial begin
result[63] = 1'b1;
end
end
initial begin
f_result[63:0] = result[31:0];
end
endmodule
and here is the full adder module:
module FullAdder_32bit(output [31:0] result, output reg carry, input [31:0] a, input [31:0] b);
reg [32:0] temp_sum;
initial begin
temp_sum = a + b;
checkCarryFlag;
assign result = temp_sum[31:0];
end
task checkCarryFlag;
begin
if( temp_sum[32] == 1 )
begin
carry = 1;
end
else carry = 0;
end
endtask
endmodule
and here is the command console with one error, but its really for everytime I call on the full adder. I am a begginer on verilog, and wish to learn why I am getting all these errors. thanks in advance.
When connecting modules the output of an instance must drive a wire.
For example
module top
wire block_wire_output;
block u_block(
.block_reg_output( block_wire_output)
);
endmodule
module block(
output reg block_reg_output
);
initial begin
block_reg_output =1'b1;
end
endmodule
In your code you have reg [63:0] result; being driven by the output port of an instance. This breaks the above rule, and result should be declared as a wire (wire [63:0] result;). This does mean that you can not define part of result in an initial or always block. Your use of initial does not look to be correct as they are only evaluated once. It looks like you really wanted to use:
assign result[0] = and1[0];

Convert CGKeyCode to character

I have not been able to find out how to convert a CGKeyCode to the corresponding character.
So how do you do it?
Here is a function from the RUI project with a partial table.
char * keyStringForKeyCode(int keyCode)
{
// Proper key detection seems to want a switch statement, unfortunately
switch (keyCode) {
case 0: return("a");
case 1: return("s");
case 2: return("d");
case 3: return("f");
case 4: return("h");
case 5: return("g");
case 6: return("z");
case 7: return("x");
case 8: return("c");
case 9: return("v");
// what is 10?
case 11: return("b");
case 12: return("q");
case 13: return("w");
case 14: return("e");
case 15: return("r");
case 16: return("y");
case 17: return("t");
case 18: return("1");
case 19: return("2");
case 20: return("3");
case 21: return("4");
case 22: return("6");
case 23: return("5");
case 24: return("=");
case 25: return("9");
case 26: return("7");
case 27: return("-");
case 28: return("8");
case 29: return("0");
case 30: return("]");
case 31: return("o");
case 32: return("u");
case 33: return("[");
case 34: return("i");
case 35: return("p");
case 36: return("RETURN");
case 37: return("l");
case 38: return("j");
case 39: return("'");
case 40: return("k");
case 41: return(";");
case 42: return("\\");
case 43: return(",");
case 44: return("/");
case 45: return("n");
case 46: return("m");
case 47: return(".");
case 48: return("TAB");
case 49: return("SPACE");
case 50: return("`");
case 51: return("DELETE");
case 52: return("ENTER");
case 53: return("ESCAPE");
// some more missing codes abound, reserved I presume, but it would
// have been helpful for Apple to have a document with them all listed
case 65: return(".");
case 67: return("*");
case 69: return("+");
case 71: return("CLEAR");
case 75: return("/");
case 76: return("ENTER"); // numberpad on full kbd
case 78: return("-");
case 81: return("=");
case 82: return("0");
case 83: return("1");
case 84: return("2");
case 85: return("3");
case 86: return("4");
case 87: return("5");
case 88: return("6");
case 89: return("7");
case 91: return("8");
case 92: return("9");
case 96: return("F5");
case 97: return("F6");
case 98: return("F7");
case 99: return("F3");
case 100: return("F8");
case 101: return("F9");
case 103: return("F11");
case 105: return("F13");
case 107: return("F14");
case 109: return("F10");
case 111: return("F12");
case 113: return("F15");
case 114: return("HELP");
case 115: return("HOME");
case 116: return("PGUP");
case 117: return("DELETE"); // full keyboard right side numberpad
case 118: return("F4");
case 119: return("END");
case 120: return("F2");
case 121: return("PGDN");
case 122: return("F1");
case 123: return("LEFT");
case 124: return("RIGHT");
case 125: return("DOWN");
case 126: return("UP");
default:
// Unknown key, bail and note that RUI needs improvement
fprintf(stderr, "%ld\tKey\t%c (DEBUG: %d)\n", currenttime, keyCode);
exit(EXIT_FAILURE);
}
}
Almost the same code as in answer of Gourneau, but for Swift language
(!!!) These mappings are only true in the U.S. QWERTY keyboard layout
extension CGKeyCode {
func keyStringForKeyCode() -> String {
switch (self) {
case 0: return "A"
case 1: return "S"
case 2: return "D"
case 3: return "F"
case 4: return "H"
case 5: return "G"
case 6: return "Z"
case 7: return "X"
case 8: return "C"
case 9: return "V"
// what is 10?
case 11: return "B"
case 12: return "Q"
case 13: return "W"
case 14: return "E"
case 15: return "R"
case 16: return "Y"
case 17: return "T"
case 18: return "1"
case 19: return "2"
case 20: return "3"
case 21: return "4"
case 22: return "6"
case 23: return "5"
case 24: return "="
case 25: return "9"
case 26: return "7"
case 27: return "-"
case 28: return "8"
case 29: return "0"
case 30: return "]"
case 31: return "O"
case 32: return "U"
case 33: return "["
case 34: return "I"
case 35: return "P"
case 36: return "RETURN"
case 37: return "L"
case 38: return "J"
case 39: return "'"
case 40: return "K"
case 41: return ";"
case 42: return "\\"
case 43: return ","
case 44: return "/"
case 45: return "N"
case 46: return "M"
case 47: return "."
case 48: return "TAB"
case 49: return "SPACE"
case 50: return "`"
case 51: return "DELETE"
case 52: return "ENTER"
case 53: return "ESCAPE"
// some more missing codes abound, reserved I presume, but it would
// have been helpful for Apple to have a document with them all listed
case 65: return "."
case 67: return "*"
case 69: return "+"
case 71: return "CLEAR"
case 75: return "/"
case 76: return "ENTER" // numberpad on full kbd
case 78: return "-"
case 81: return "="
case 82: return "0"
case 83: return "1"
case 84: return "2"
case 85: return "3"
case 86: return "4"
case 87: return "5"
case 88: return "6"
case 89: return "7"
case 91: return "8"
case 92: return "9"
case 96: return "F5"
case 97: return "F6"
case 98: return "F7"
case 99: return "F3"
case 100: return "F8"
case 101: return "F9"
case 103: return "F11"
case 105: return "F13"
case 107: return "F14"
case 109: return "F10"
case 111: return "F12"
case 113: return "F15"
case 114: return "HELP"
case 115: return "HOME"
case 116: return "PGUP"
case 117: return "DELETE" // full keyboard right side numberpad
case 118: return "F4"
case 119: return "END"
case 120: return "F2"
case 121: return "PGDN"
case 122: return "F1"
case 123: return "LEFT"
case 124: return "RIGHT"
case 125: return "DOWN"
case 126: return "UP"
default:
// Unknown key, bail and note that RUI needs improvement
print("ERROR: Key: \(self)" )
return "ERROR: Key: \(self)"
}
}
}