@cat Finally made a module thread 
If the 1:2 thing turns out to be an issue for more users I will look into addressing it.

If the 1:2 thing turns out to be an issue for more users I will look into addressing it.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menufunction hSomeHotspot_Interact() {
if (WalkFace(123, 45, eDirectionLeft)) {
// what happens when the player reaches those coordinates goes in here
}
}
void HandleFadingObjects() {
for (int i = 0; i < Room.ObjectCount; i++) {
if (!object[i].GetProperty("walkbehind_fade")) continue; // skip other objects
int dy = object[i].Y - player.y;
if (dy < 0) continue; // player is in front of object
int hw = Game.SpriteWidth[object[i].Graphic] / 2;
int dx = object[i].X - player.x;
if (dx < -hw || dx > hw) continue; // player not behind horizontally
if (dx < 0) dx = -dx;
object[i].Transparency = (hw - dx) * 100 / hw;
}
}
// header
AudioChannel* channel[5];
// header
import AudioChannel* channel[5];
// script
AudioChannel* channel[5]; export channel; // exporting requires just the name
// Main header script - this will be included into every script in
// the game (local and global). Do not place functions here; rather,
// place import definitions and #define names here to be used by all
// scripts.
function on_key_press(eKeyCode k) {
if (k == eKeyLeftArrow && pos > 0) {
ClaimEvent();
pos--;
oBucket.X = 500 + pos * 70;
}
if (k == eKeyRightArrow && pos < 2) {
ClaimEvent();
pos++;
oBucket.X = 500 + pos * 70;
}
// handle other keys
}
int frames = 0;
bool AfterEvery(int after, int every) {
int gs = GetGameSpeed();
return (frames - gs * after) % (gs * every) == 0;
}
// inside room_RepExec
frames++;
if (frames == GetGameSpeed() * 10000) frames = 0;
if (AfterEvery(0, 5)) {
// do something after 5, 10, 15, etc. seconds
}
if (AfterEvery(2, 5)) {
// do something after 7, 12, 17, etc. seconds
}
// inside some function
cNpc1.Animate(...);
SetTimer(1, GetGameSpeed() * 5); // five seconds from now
// inside room_RepExec()
if (IsTimerExpired(1)) cNpc2.Animate(...);
int pos = 1; // 0, 1 or 2
function on_key_press(eKeyCode k) {
if (k == eKeyLeftArrow && pos > 0) pos--;
if (k == eKeyRightArrow && pos < 2) pos++;
oBucket.X = 500 + pos * 70;
}
// above functions that need it
String npc_text[3]; // show last three lines of dialogue
// inside a function where line is said
storage += "[" + npc_text[0];
npc_text[0] = npc_text[1];
npc_text[1] = npc_text[2];
npc_text[2] = line;
lblNpc.Text = npc_text[0] + "[" + npc_text[1] + "[" + npc_text[2];
bool lampLit = false;
// turn on
lampLit = true;
// check
if (lampLit) ...
Quote from: Custerly on Wed 13/12/2023 02:35:24why does it require the first parameter (dgOpt1) when I've already stated [if (keycode == eKey1) dgOpt1_OnClick...]? That first parameter doesn't seem to actually serve any purpose.
if (control == dgOpt1) ...
else if (control == dgOpt2) ...
...
int choice = control.ID;
int y = 10;
for (int i = 0; i < 5; i++) {
Label* l = gDialog.Controls[i * 2].AsLabel;
Button * b = gDialog.Controls[i * 2 + 1].AsButton;
int h = GetTextHeight(l.Text, l.Font, l.Width);
// resize and position label and button
l.Height = h;
l.Y = y;
b.Height = h;
b.Y = y;
y += h + 5; // next button moves down accordingly, plus 5 pixels
}
Quote from: Dave Gilbert on Tue 12/12/2023 13:36:38Thanks Khris! One question. It looks like your function plays the animation and THEN counts the frames/ms length. Is there a reason why you played the animation beforehand?
// header
import int AnimateFrames(this Character*, int loop, int delay, RepeatStyle repeatStyle = eOnce, BlockingStyle blockingStyle = eBlock, Direction direction = eForwards, int frame = 0, int volume = 100);
// main
int AnimateFrames(this Character*, int loop, int delay, RepeatStyle repeatStyle, BlockingStyle blockingStyle, Direction direction, int frame, int volume) {
this.Animate(loop, delay, repeatStyle, blockingStyle, direction, frame, volume);
int frames = 0;
// TODO: handle eBackwards
for (int i = frame; i < Game.GetFrameCountForLoop(this.View, loop); i++) {
ViewFrame* vf = Game.GetViewFrame(this.View, loop, i);
frames += delay + vf.Speed + 1;
}
return frames;
}
player.LockView(VIEW2);
int frames = player.AnimateFrames(0, 10, eOnce, eNoBlock, eForwards);
int ms = (frames * 1000) / GetGameSpeed();
function textBoxParser_OnActivate(GUIControl* control) {
Parser.ParseText(control.Text); // tell AGS to test understood commands against the current textbox content
if (Parser.Said("quit")) QuitGame(1);
if (Parser.Said("look")) CallRoomScript(1);
if (Parser.Said("take anyword")) {
// ... process take command
}
if (Parser.Said("drop key")) {
player.LoseInventory(iKey);
}
}
// header
struct Conversation {
String options[10];
bool active[10];
int option_count;
import bool AddOption(String text);
import void Run();
};
// main
Conversation convo[5];
// game_start
convo[0].AddOption("Hello");
// elsewhere
convo[current_convo].Run();
By continuing to use this site you agree to the use of cookies. Please visit this page to see exactly how we use these.
Page created in 3.609 seconds with 20 queries.